diff options
-rw-r--r-- | functions | 35 | ||||
-rwxr-xr-x | rc.multi | 4 | ||||
-rwxr-xr-x | rc.shutdown | 8 | ||||
-rwxr-xr-x | rc.single | 12 | ||||
-rwxr-xr-x | rc.sysinit | 10 |
5 files changed, 37 insertions, 32 deletions
@@ -239,26 +239,31 @@ ck_status() { # ... # } # add_hook hook_name function_name -# It's allowed to register several hook functions for the same hook -# -# The function takes the filename of the script that launched it as an argument +# It is allowed to register several hook functions for the same hook +# Is is also allowed to register the same hook function for several hooks # # Currently, the following hooks exist: -# start: at the beginning of rc.{multi,shutdown,single,sysinit} -# end: at the end of rc.{multi,single,sysinit} -# udevlaunched: after udev has been launched in rc.sysinit and rc.single -# udevsettled: after uevents have settled in rc.sysinit and rc.single -# premount: before local filesystems are mounted, but after root is mounted read-write in rc.sysinit -# prekillall: before all processes are being killed in rc.shutdown and rc.single -# postkillall: after all processes have been killed in rc.shutdown and rc.single -# poweroff: directly before powering off in rc.shutdown +# sysinit_start: at the beginning of rc.sysinit +# multi_start: at the beginning of rc.multi +# single_start: at the beginning of rc.single +# shutdown_start: at the beginning of rc.shutdown +# sysinit_end: at the end of rc.sysinit +# multi_end: at the end of rc.multi +# single_end: at the end of rc.single +# sysinit_udevlaunched: after udev has been launched in rc.sysinit +# single_udevlaunched: after udev has been launched in rc.single +# sysinit_udevsettled: after uevents have settled in rc.sysinit +# single_udevsettled: after uevents have settled in rc.single +# sysinit_premount: before local filesystems are mounted, but after root is mounted read-write in rc.sysinit +# shutdown_prekillall: before all processes are being killed in rc.shutdown +# single_prekillall: before all processes are being killed in rc.single +# shutdown_postkillall: after all processes have been killed in rc.shutdown +# single_postkillall: after all processes have been killed in rc.single +# shutdown_poweroff: directly before powering off in rc.shutdown # # Make sure to never override the add_hook and run_hook functions via functions.d declare -A hook_funcs -for hook in start end udevlaunched udevsettled premount prekillall postkillall poweroff; do - hook_funcs["${hook}"]="" -done add_hook() { [ -z "$1" -o -z "$2" ] && return 1 @@ -270,7 +275,7 @@ run_hook() { [ -z "$1" ] && return 1 for func in ${hook_funcs["$1"]}; do - ${func} "$2" + ${func} done } @@ -6,7 +6,7 @@ . /etc/rc.conf . /etc/rc.d/functions -run_hook start rc.multi +run_hook multi_start # Load sysctl variables if sysctl.conf is present [ -r /etc/sysctl.conf ] && /sbin/sysctl -q -p &>/dev/null @@ -26,6 +26,6 @@ if [ -x /etc/rc.local ]; then /etc/rc.local fi -run_hook end rc.multi +run_hook multi_end # vim: set ts=2 noet: diff --git a/rc.shutdown b/rc.shutdown index 5921e1c..34442ca 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -6,7 +6,7 @@ . /etc/rc.conf . /etc/rc.d/functions -run_hook start rc.shutdown +run_hook shutdown_start # avoid staircase effect /bin/stty onlcr @@ -43,7 +43,7 @@ if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then done fi -run_hook prekillall rc.shutdown +run_hook shutdown_prekillall # Terminate all processes stat_busy "Sending SIGTERM To Processes" @@ -56,7 +56,7 @@ stat_busy "Sending SIGKILL To Processes" /bin/sleep 1 stat_done -run_hook postkillall rc.shutdown +run_hook shutdown_postkillall stat_busy "Saving Random Seed" RANDOM_SEED=/var/lib/misc/random-seed @@ -138,7 +138,7 @@ stat_busy "Remounting Root Filesystem Read-only" /bin/mount -n -o remount,ro / stat_done -run_hook poweroff rc.shutdown +run_hook shutdown_poweroff # Power off or reboot if [ "$RUNLEVEL" = "0" ]; then @@ -6,7 +6,7 @@ . /etc/rc.conf . /etc/rc.d/functions -run_hook start rc.single +run_hook single_start if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then # Find daemons NOT in the DAEMONS array. Shut these down first @@ -28,7 +28,7 @@ if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then fi if [ "$PREVLEVEL" != "N" ]; then - run_hook prekillall rc.single + run_hook single_prekillall # Terminate all processes stat_busy "Sending SIGTERM To Processes" @@ -41,13 +41,13 @@ if [ "$PREVLEVEL" != "N" ]; then /bin/sleep 1 stat_done - run_hook postkillall rc.single + run_hook single_postkillall stat_busy "Starting UDev Daemon" /sbin/udevd --daemon stat_done - run_hook udevlaunched rc.single + run_hook single_udevlaunched # Trigger udev uevents if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then @@ -63,7 +63,7 @@ if [ "$PREVLEVEL" != "N" ]; then stat_done fi - run_hook udevsettled rc.single + run_hook single_udevsettled # try syslog-NG first, then fall back to good ol' syslogd if [ -x /etc/rc.d/syslog-ng ]; then @@ -74,7 +74,7 @@ if [ "$PREVLEVEL" != "N" ]; then fi fi -run_hook end rc.single +run_hook single_end if [ "$RUNLEVEL" = "1" ]; then printsep @@ -14,7 +14,7 @@ printhl "Copyright 2007-2009 Aaron Griffin" printhl "Distributed under the GNU General Public License (GPL)" printsep -run_hook start rc.sysinit +run_hook sysinit_start # mount /proc, /sys and our RAM /dev /bin/mount -n -t tmpfs udev /dev -o mode=0755,size=10M,nosuid @@ -65,7 +65,7 @@ stat_busy "Starting UDev Daemon" /sbin/udevd --daemon stat_done -run_hook udevlaunched rc.sysinit +run_hook sysinit_udevlaunched # Trigger udev uevents if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then @@ -112,7 +112,7 @@ if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then stat_done fi -run_hook udevsettled rc.sysinit +run_hook sysinit_udevsettled # bring up the loopback interface if [ -d /sys/class/net/lo ]; then @@ -288,7 +288,7 @@ stat_busy "Mounting Local Filesystems" if [ -e /proc/mounts ]; then /bin/grep -e "/proc " -e "/sys " -e "/dev " /proc/mounts >> /etc/mtab fi -run_hook premount rc.sysinit +run_hook sysinit_premount # now mount all the local filesystems /bin/mount -a -t $NETFS -O no_netdev stat_done @@ -419,7 +419,7 @@ fi /bin/dmesg >| /var/log/dmesg.log -run_hook end rc.sysinit +run_hook sysinit_end # End of file # vim: set ts=2 noet: |