aboutsummaryrefslogtreecommitdiff
path: root/rc.shutdown
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2009-08-25 12:57:02 +0200
committerThomas Bächler <thomas@archlinux.org>2009-08-25 12:57:02 +0200
commitcfabb85924f35c636550609b332d088aaae9941f (patch)
treedb508828fde2166a8accfd3251da461642812057 /rc.shutdown
parent76bb11cb8b5374ff2bba79afc80c408f61779f0c (diff)
downloadinitscripts-cfabb85924f35c636550609b332d088aaae9941f.tar.xz
Implement a hook-system that allows to add custom code to the initscripts at certain places
A function add_hook can be called from functions.d to register a hook function. The existing hooks are based on suggestions from Michael Towers (larch) and on the implementation of initscripts-extras-fbsplash which currently uses the strings passed to stat_busy and stat_done for this. More hooks can be added if requested. The implementation uses associative arrays and will thus only work with bash 4 or later
Diffstat (limited to 'rc.shutdown')
-rwxr-xr-xrc.shutdown8
1 files changed, 8 insertions, 0 deletions
diff --git a/rc.shutdown b/rc.shutdown
index e2a4a84..5921e1c 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -6,6 +6,8 @@
. /etc/rc.conf
. /etc/rc.d/functions
+run_hook start rc.shutdown
+
# avoid staircase effect
/bin/stty onlcr
@@ -41,6 +43,8 @@ if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
done
fi
+run_hook prekillall rc.shutdown
+
# Terminate all processes
stat_busy "Sending SIGTERM To Processes"
/sbin/killall5 -15 &> /dev/null
@@ -52,6 +56,8 @@ stat_busy "Sending SIGKILL To Processes"
/bin/sleep 1
stat_done
+run_hook postkillall rc.shutdown
+
stat_busy "Saving Random Seed"
RANDOM_SEED=/var/lib/misc/random-seed
[ -d $(dirname $RANDOM_SEED) ] || mkdir -p $(dirname $RANDOM_SEED)
@@ -132,6 +138,8 @@ stat_busy "Remounting Root Filesystem Read-only"
/bin/mount -n -o remount,ro /
stat_done
+run_hook poweroff rc.shutdown
+
# Power off or reboot
if [ "$RUNLEVEL" = "0" ]; then
printsep