From 65e86bc4f0c331da160e349a083352b722506e50 Mon Sep 17 00:00:00 2001 From: Kurt J. Bosch Date: Thu, 18 Feb 2010 11:08:34 +0100 Subject: [PATCH 3/3] Add some hooks to stat/daemon-functions to elim. any need to override --- functions | 40 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 39 insertions(+), 1 deletions(-) diff --git a/functions b/functions index b7b9511..1a798a9 100644 --- a/functions +++ b/functions @@ -101,6 +101,8 @@ stat_bkgd() { printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} " deltext printf " ${C_OTHER}[${C_BKGD}BKGD${C_OTHER}]${C_CLEAR} " + local statmsg="${1}" + run_hook stat_bkgd } stat_busy() { @@ -108,22 +110,28 @@ stat_busy() { printf "${SAVE_POSITION}" deltext printf " ${C_OTHER}[${C_BUSY}BUSY${C_OTHER}]${C_CLEAR} " + local statmsg="${1}" + run_hook stat_busy } stat_append() { printf "${RESTORE_POSITION}" printf -- "${C_MAIN}${1}${C_CLEAR}" printf "${SAVE_POSITION}" + local statmsg="${1}" + run_hook stat_append } stat_done() { deltext printf " ${C_OTHER}[${C_DONE}DONE${C_OTHER}]${C_CLEAR} \n" + run_hook stat_done } stat_fail() { deltext printf " ${C_OTHER}[${C_FAIL}FAIL${C_OTHER}]${C_CLEAR} \n" + run_hook stat_fail } stat_die() { @@ -189,16 +197,28 @@ ck_depends() { } start_daemon() { + local daemon=$1 + run_hook pre_daemon_start /etc/rc.d/$1 start + run_hook post_daemon_start } start_daemon_bkgd() { stat_bkgd "Starting $1" - (/etc/rc.d/$1 start) &>/dev/null & + local daemon=$1 + run_hook fork_daemon_bkgd + ( + run_hook pre_daemon_bkgd + /etc/rc.d/$1 start + run_hook post_daemon_bkgd + ) &>/dev/null & } stop_daemon() { + local daemon=$1 + run_hook pre_daemon_stop /etc/rc.d/$1 stop + run_hook post_daemon_stop } # Status functions @@ -246,14 +266,32 @@ ck_status() { # 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_prefsck: directly before fsck is run in rc.sysinit +# sysinit_postfsck: after fsck was run in rc.sysinit # 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 +# Busy stat function hooks - local var statmsg is set to message-text +# stat_bkgd: when stat_bkgd is called +# stat_busy: when stat_busy is called +# stat_append: when stat_append is called +# End stat function hooks +# stat_done: when stat_done is called +# stat_fail: when stat_fail is called +# Daemon function hooks - local var daemon is set when these are run +# pre_daemon_start: before a daemon is started +# post_daemon_start: after a daemon was started +# fork_daemon_bkgd: before forking to start a daemon in background +# pre_daemon_bkgd: before a daemon is started in background +# post_daemon_bkgd: after a daemon was started in background +# pre_daemon_stop: before a daemon is stopped +# post_daemon_stop: after a daemon was stopped # # Make sure to never override the add_hook and run_hook functions via functions.d +# Also make sure to not override the stat and daemon funktions declare -A hook_funcs -- 1.6.6.1