2006-12-11 01:52:36 +01:00
|
|
|
{bash, event, utillinux}:
|
2006-11-23 23:53:16 +01:00
|
|
|
|
|
|
|
assert event == "reboot"
|
|
|
|
|| event == "halt"
|
|
|
|
|| event == "system-halt"
|
|
|
|
|| event == "power-off";
|
2006-11-20 21:50:52 +01:00
|
|
|
|
|
|
|
{
|
2006-11-23 23:53:16 +01:00
|
|
|
name = "sys-" + event;
|
2006-11-20 21:50:52 +01:00
|
|
|
|
|
|
|
job = "
|
2006-11-23 23:53:16 +01:00
|
|
|
start on ${event}
|
2006-11-20 21:50:52 +01:00
|
|
|
|
|
|
|
script
|
|
|
|
exec < /dev/tty1 > /dev/tty1 2>&1
|
|
|
|
echo \"\"
|
|
|
|
echo \"<<< SYSTEM SHUTDOWN >>>\"
|
|
|
|
echo \"\"
|
|
|
|
|
2006-12-11 01:52:36 +01:00
|
|
|
export PATH=${utillinux}/bin:$PATH
|
|
|
|
|
2006-11-20 22:19:34 +01:00
|
|
|
# Do an initial sync just in case.
|
|
|
|
sync || true
|
|
|
|
|
|
|
|
# Unmount file systems.
|
|
|
|
umount -n -a || true
|
|
|
|
|
|
|
|
# Remount / read-only
|
|
|
|
mount -n -o remount,ro /dontcare / || true
|
|
|
|
|
|
|
|
# Final sync.
|
|
|
|
sync || true
|
|
|
|
|
2006-11-20 21:50:52 +01:00
|
|
|
# Right now all events above power off the system.
|
2006-11-23 23:53:16 +01:00
|
|
|
if test ${event} = reboot; then
|
|
|
|
exec reboot -f
|
|
|
|
else
|
|
|
|
exec halt -f -p
|
|
|
|
fi
|
2006-11-20 21:50:52 +01:00
|
|
|
end script
|
|
|
|
";
|
|
|
|
|
|
|
|
}
|