diff options
author | Simon Rettberg | 2018-10-12 16:58:09 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-10-12 16:58:09 +0200 |
commit | 910c715f7c870afd8a963913d4c98e509c6b26b8 (patch) | |
tree | 0b28b427a7c039bb888e26950dda6fd5c4d440ea /core/modules/idleaction | |
parent | [idleaction] Move idle-file to /run/openslx/... (diff) | |
download | mltk-910c715f7c870afd8a963913d4c98e509c6b26b8.tar.gz mltk-910c715f7c870afd8a963913d4c98e509c6b26b8.tar.xz mltk-910c715f7c870afd8a963913d4c98e509c6b26b8.zip |
[idleaction] Update shutdown timestamp on scheduled action
In case a shutdown/reboot/... is manually triggered (i.e. via web
interface), the according timestamp won't be in the idleaction hint file
for the xscreensaver hack. Update the timestamp in case a reboot is
imminent, so the screeensaver can update the countdown.
Diffstat (limited to 'core/modules/idleaction')
-rwxr-xr-x | core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action b/core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action index df9fd65c..7cfb557d 100755 --- a/core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action +++ b/core/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_action @@ -69,6 +69,21 @@ if [ -z "$DELAY" ] && [ "$NUM" = "0" ]; then exit 0 fi +NOW=$(date +%s) +timeout=$(( 300 + NOW )) # 5 minute delay for logged in user +if [ -n "$DELAY" ] && [ "$DELAY" -gt 0 ]; then + timeout=$(( timeout + ( DELAY * 60 ) )) +fi + +for f in /run/openslx/idleaction-*; do + [ -f "$f" ] || continue + grep -q '^shutdownDeadline=' "$f" || continue + RET=$(awk -F= '{if ($1 == "shutdownDeadline") { print $2; exit } }' "$f") + if [ -z "$RET" ] || [ "$RET" -eq 0 ] || ! [ "$RET" -lt "$timeout" ]; then + sed -i "s/^shutdownDeadline=.*$/shutdownDeadline=$timeout/" "$f" + fi +done + runaction () { # Someone logged in or delay requested [ -n "$DETACH" ] && sleep 1 |