summaryrefslogtreecommitdiffstats
path: root/remote/modules
diff options
context:
space:
mode:
authorJonathan Bauer2014-03-25 17:40:40 +0100
committerJonathan Bauer2014-03-25 17:40:40 +0100
commitb3204d96717244e2c2a187ecf48f3bde80bab874 (patch)
treeb74a4ce5af2039d1e327bfaabd960bd59747ad70 /remote/modules
parentwoopsie, the return ;) (diff)
downloadtm-scripts-b3204d96717244e2c2a187ecf48f3bde80bab874.tar.gz
tm-scripts-b3204d96717244e2c2a187ecf48f3bde80bab874.tar.xz
tm-scripts-b3204d96717244e2c2a187ecf48f3bde80bab874.zip
[idleaction] added support for SLX_REBOOT_SHUTDOWN
Diffstat (limited to 'remote/modules')
-rwxr-xr-xremote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script13
-rwxr-xr-xremote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_reboot6
2 files changed, 18 insertions, 1 deletions
diff --git a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
index 746f2f47..b68c27f8 100755
--- a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
+++ b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-cron_script
@@ -39,6 +39,8 @@ if [ -n "${SLX_LOGOUT_TIMEOUT}" ]; then
else
loginctl terminate-session "$ses"
fi
+ else # xprintidle did not work
+ IS_IDLE=no
fi
continue # Done with this session, skip normal tty/ssh checks
fi
@@ -103,7 +105,7 @@ invalid_time ()
return 0
}
-if [ -n "$SLX_SHUTDOWN_SCHEDULE" ] && [ ! -e "$CRONFILE" ]; then
+if [ -n "$SLX_SHUTDOWN_SCHEDULE" -o -n "$SLX_REBOOT_SCHEDULE" ] && [ ! -e "$CRONFILE" ]; then
echo "# OpenSLX: Trigger poweroff at certain time of day" > "$CRONFILE"
echo "SHELL=/bin/ash" >> "$CRONFILE"
echo "PATH=/usr/sbin:/usr/bin:/sbin:/bin:/opt/openslx/usr/sbin:/opt/openslx/usr/bin:/opt/openslx/sbin:/opt/openslx/bin" >> "$CRONFILE"
@@ -116,5 +118,14 @@ if [ -n "$SLX_SHUTDOWN_SCHEDULE" ] && [ ! -e "$CRONFILE" ]; then
[ "$MINUTE" -lt 0 -o "$MINUTE" -gt 59 ] && invalid_time && continue
echo "$MINUTE $HOUR * * * root /opt/openslx/scripts/idleaction-scheduled_poweroff" >> "$CRONFILE"
done
+ # do it again for SLX_REBOOT_SCHEDULE
+ for time in $SLX_REBOOT_SCHEDULE; do
+ HOUR=${time%%:*}
+ MINUTE=${time##*:}
+ [ -z "$HOUR$MINUTE" ] && invalid_time && continue
+ [ "$HOUR" -lt 0 -o "$HOUR" -gt 23 ] && invalid_time && continue
+ [ "$MINUTE" -lt 0 -o "$MINUTE" -gt 59 ] && invalid_time && continue
+ echo "$MINUTE $HOUR * * * root /opt/openslx/scripts/idleaction-scheduled_reboot" >> "$CRONFILE"
+ done
fi
diff --git a/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_reboot b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_reboot
new file mode 100755
index 00000000..fa3adf65
--- /dev/null
+++ b/remote/modules/idleaction/data/opt/openslx/scripts/idleaction-scheduled_reboot
@@ -0,0 +1,6 @@
+#!/bin/ash
+
+# TODO: Warn user, wait 5 minutes, etc...
+
+echo 'b' > /proc/sysrq-trigger
+