blob: 0aa681ffbf7d7a092d74e13bdf738e1d70e5f087 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
|