summaryrefslogtreecommitdiffstats
path: root/core/modules/idleaction/data
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-26 13:35:03 +0100
committerSimon Rettberg2017-11-26 13:35:03 +0100
commitf0e99d0ba7c123f5f9ee1a3068969b72eeea96fe (patch)
treeb519f0d6afc8e847b1b31a1be76499e84888476c /core/modules/idleaction/data
parent[idleaction] Support suspend (diff)
downloadmltk-f0e99d0ba7c123f5f9ee1a3068969b72eeea96fe.tar.gz
mltk-f0e99d0ba7c123f5f9ee1a3068969b72eeea96fe.tar.xz
mltk-f0e99d0ba7c123f5f9ee1a3068969b72eeea96fe.zip
[idleaction] Set wakeup alarm two minutes early to prevent race
If the wakeup is scheduled exactly at the time a scheduled shutdown is, the cronjob for the shutdown would not run, as the client is still about to wake up at that time. If we wake up two minutes early, the cron daemon should have enough time to fully wake up, notice the clock jump, and then finally trigger the scheduled shutdown.
Diffstat (limited to 'core/modules/idleaction/data')
-rwxr-xr-xcore/modules/idleaction/data/opt/openslx/scripts/systemd-idleaction_init10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/modules/idleaction/data/opt/openslx/scripts/systemd-idleaction_init b/core/modules/idleaction/data/opt/openslx/scripts/systemd-idleaction_init
index 983dfcec..ae8af404 100755
--- a/core/modules/idleaction/data/opt/openslx/scripts/systemd-idleaction_init
+++ b/core/modules/idleaction/data/opt/openslx/scripts/systemd-idleaction_init
@@ -39,8 +39,14 @@ if [ -n "$SCHEDULE" ]; then
[ -z "$HOUR" -o -z "$MINUTE" ] && continue
[ "$HOUR" -lt 0 -o "$HOUR" -gt 23 ] && continue
[ "$MINUTE" -lt 0 -o "$MINUTE" -gt 59 ] && continue
- TS=$(date --date "$TODAY $t" +%s)
- [ "$TS" -le "$NOW" ] && TS=$(date --date "$TOMORROW $t" +%s)
+ # wake up 2 minutes early; for the shutdown/reboot times this is required
+ # so the actual cronjob for the shutdown/reboot will run.
+ # Otherwise, since the wakeup will take some seconds, the actual cronjob
+ # will not trigger, since it lies a few seconds in the past.
+ # For the scheduled wakeups this would't be needed, but two minutes
+ # early shouldn't hurt anyone.
+ TS=$(date --date "-2 minutes $TODAY $t" +%s)
+ [ "$TS" -le "$NOW" ] && TS=$(date --date "-2 minutes $TOMORROW $t" +%s)
if [ -z "$NEXT" ] || [ "$NEXT" -gt "$TS" ]; then
NEXT="$TS"
fi