summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2023-12-14 12:11:16 +0100
committerSimon Rettberg2023-12-14 12:11:16 +0100
commitaf09a5cf8ad76b156e4a48d77ecfada9c6402325 (patch)
treee61d7ba8a8b21830470ef3e000bf26fa14b4aed2
parent[kiosk-chromium] Properly fix auto reload/restart (diff)
downloadmltk-af09a5cf8ad76b156e4a48d77ecfada9c6402325.tar.gz
mltk-af09a5cf8ad76b156e4a48d77ecfada9c6402325.tar.xz
mltk-af09a5cf8ad76b156e4a48d77ecfada9c6402325.zip
[idleaction] Log shutdown/reboot/.. details in exam mode
We have a report about spurious reboots of machines in exam mode while in use, so try to rule out that this was caused by idle-daemon logic by logging any such action it would perform through a wrapper script.
-rwxr-xr-xcore/modules/idleaction/data/opt/openslx/scripts/idle-daemon-launcher1
-rwxr-xr-xcore/modules/idleaction/data/opt/openslx/scripts/idle-daemon-trigger-wrapper41
2 files changed, 42 insertions, 0 deletions
diff --git a/core/modules/idleaction/data/opt/openslx/scripts/idle-daemon-launcher b/core/modules/idleaction/data/opt/openslx/scripts/idle-daemon-launcher
index 640ef9fb..62a919ee 100755
--- a/core/modules/idleaction/data/opt/openslx/scripts/idle-daemon-launcher
+++ b/core/modules/idleaction/data/opt/openslx/scripts/idle-daemon-launcher
@@ -29,6 +29,7 @@ if [ -z "${SLX_EXAM}" ]; then
else
# Exam mode active
CMD="$CMD --min-idle 7200" # Ignore schedule if idle time is lower than 2h
+ CMD="$CMD --cmd /opt/openslx/scripts/idle-daemon-trigger-wrapper" # Use wrapper for slxlog
# Add additional times -- We might miss tightly scheduled ones because of --min-idle
if [ -n "$SLX_SHUTDOWN_SCHEDULE" ]; then
SLX_SHUTDOWN_SCHEDULE="$SLX_SHUTDOWN_SCHEDULE 23:00 4:00"
diff --git a/core/modules/idleaction/data/opt/openslx/scripts/idle-daemon-trigger-wrapper b/core/modules/idleaction/data/opt/openslx/scripts/idle-daemon-trigger-wrapper
new file mode 100755
index 00000000..0aa681ff
--- /dev/null
+++ b/core/modules/idleaction/data/opt/openslx/scripts/idle-daemon-trigger-wrapper
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+# Executed by the idle-daemon with the desired action:
+# reboot, poweroff, kexec, suspend
+# Normally this is done directly by the idle-daemon, but
+# we use this wrapper script in exam mode so we can report
+# to slx-admin what is happening, and provide idle-daemon
+# logs so we can reconstruct why, hopefully.
+
+[ "$UID" != 0 ] && exit 1
+
+action="$1"
+
+case "$action" in
+reboot|poweroff|suspend|kexec)
+ sleep 1
+ conf=$( mktemp || echo "/tmp/id-$RANDOM-$RANDOM" )
+ {
+ echo "Command:"
+ ps aux | grep -F idle-daemon
+ echo "Config:"
+ grep -F -e TIMEOUT= -e SCHEDULE= /opt/openslx/config
+ echo "Journal:"
+ journalctl -u idle-daemon.service --no-pager
+ echo "Now:"
+ date
+ } &> "$conf"
+ slxlog -s "exam-idledaemon" "Exam mode: Executing action '$action'" "$conf"
+ if [ "$action" = kexec ]; then
+ systemctl --no-block isolate kexec.target
+ else
+ systemctl --no-block "$action"
+ fi
+ ;;
+*)
+ slxlog "exam-idledaemon" "Exam mode: Unknown action '$action' from idle-daemon"
+ exit 1
+ ;;
+esac
+
+exit 0