Enable active suspension
This commit is contained in:
parent
37c6675a4f
commit
42b0b57742
@ -4,6 +4,7 @@
|
|||||||
repoFile="$(dirname "$0")/repos"
|
repoFile="$(dirname "$0")/repos"
|
||||||
dryRun=''
|
dryRun=''
|
||||||
preventSleep=''
|
preventSleep=''
|
||||||
|
suspend=''
|
||||||
|
|
||||||
varDir=/var/lib/bup-backup-trigger
|
varDir=/var/lib/bup-backup-trigger
|
||||||
triggerFile="$varDir/trigger"
|
triggerFile="$varDir/trigger"
|
||||||
@ -33,6 +34,9 @@ do
|
|||||||
--no-sleep)
|
--no-sleep)
|
||||||
preventSleep=y
|
preventSleep=y
|
||||||
;;
|
;;
|
||||||
|
--suspend)
|
||||||
|
suspend=y
|
||||||
|
;;
|
||||||
--log)
|
--log)
|
||||||
log="$2"
|
log="$2"
|
||||||
shift
|
shift
|
||||||
@ -105,12 +109,30 @@ getNextStart() {
|
|||||||
date -d "@$(cat "$triggerFile")" "+%Y-%m-%d %H:%M"
|
date -d "@$(cat "$triggerFile")" "+%Y-%m-%d %H:%M"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
goToSleep() {
|
||||||
|
nextStart=$(getNextStart)
|
||||||
|
echo "Going to sleep until $nextStart"
|
||||||
|
rtcwake --mode disk --date "$nextStart"
|
||||||
|
}
|
||||||
|
|
||||||
if ! triggerLiesInPast
|
if ! triggerLiesInPast
|
||||||
then
|
then
|
||||||
echo "The timestamp in the trigger event lies in the future. Waiting further."
|
echo "The timestamp in the trigger event lies in the future. Waiting further."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "$suspend"]
|
||||||
|
then
|
||||||
|
if [ -f "$lockFile" -o -n "$preventSleep" ]
|
||||||
|
then
|
||||||
|
echo "Failed to go to sleep while lock file is present or sleep prevention given."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
goToSleep
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
echo "The backup script is triggered."
|
echo "The backup script is triggered."
|
||||||
|
|
||||||
while read line
|
while read line
|
||||||
@ -139,9 +161,7 @@ else
|
|||||||
then
|
then
|
||||||
echo "Skipping sleeping due to lock file existence."
|
echo "Skipping sleeping due to lock file existence."
|
||||||
else
|
else
|
||||||
nextStart=$(getNextStart)
|
goToSleep
|
||||||
echo "Going to sleep until $nextStart"
|
|
||||||
rtcwake --mode disk --date "$nextStart"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user