core/larch-live/etc/rc.larch.shutdown
2010-05-21 22:16:47 +00:00

34 lines
793 B
Bash
Executable File

#!/bin/bash
# rc.larch.shutdown
# This replaces rc.shutdown in inittab
# 2009.08.30
# Create shutdown script dynamically from normal rc.shutdown.
# (until such as a time as the needed hooks are included in rc.shutdown upstream)
if grep "^run_hook()" /etc/rc.d/functions &>/dev/null; then
sed -i "s|^\.|#.|" /etc/rc.d/functions.d/000addhooks
exec /etc/rc.shutdown
else
sed -i "s|^#\.|.|" /etc/rc.d/functions.d/000addhooks
fi
# Build a modified version of rc.shutdown dynamically
newfile=/.livesys/shutdown
cp -f /etc/rc.shutdown ${newfile}
# Insert before 'Saving Random Seed'
sed '/Random/ i\
run_hook shutdown_postkillall
' -i ${newfile}
# Insert before line '# Power off or reboot'
sed '/Power/ i\
run_hook shutdown_poweroff
' -i ${newfile}
# Run the script
. ${newfile}