From cfabb85924f35c636550609b332d088aaae9941f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20B=C3=A4chler?= Date: Tue, 25 Aug 2009 12:57:02 +0200 Subject: 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 --- rc.shutdown | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'rc.shutdown') 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 -- cgit v1.2.3