Genaral scheme is: run_hook pre_foo if [[$WE_WANT_TO_DO_FOO]]]; then stat_busy "Doing foo" if [[$PRECONDITIONS_FOR_FOO_NOT_SATISFIED]]; then stat_fail else ... stat_done fi fi run hook post_foo Suggested-by: Tom Gundersen <teg@jklm.no> --- functions | 38 ++++++++++++++++++++++++-------------- 1 files changed, 24 insertions(+), 14 deletions(-) diff --git a/functions b/functions index f82110d..ba452d8 100644 --- a/functions +++ b/functions @@ -284,9 +284,10 @@ kill_everything() { ck_daemon ${DAEMONS[i]#@} || stop_daemon ${DAEMONS[i]#@} done + run_hook "$1_prekillall" + # Terminate all processes stat_busy "Sending SIGTERM To Processes" - run_hook "$1_prekillall" /sbin/killall5 -15 ${omit_pids[@]/#/-o } &>/dev/null /bin/sleep 5 stat_done @@ -364,18 +365,25 @@ NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuse # Check local filesystems fsck_all() { - [[ -x $(type -P fsck) ]] || return 0 - stat_busy "Checking Filesystems" - FSCK_OUT=/dev/stdout - FSCK_ERR=/dev/stdout - FSCK_FD= - FORCEFSCK= - [[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f" - run_hook sysinit_prefsck - fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >|$FSCK_OUT 2>|$FSCK_ERR - local -r fsckret=$? - (( fsckret <= 1 )) && stat_done || stat_fail + FSCK_OUT=/dev/stdout + FSCK_ERR=/dev/stdout + FSCK_FD= + FORCEFSCK= + [[ -f /forcefsck ]] || in_array forcefsck $(< /proc/cmdline) && FORCEFSCK="-- -f" + + run_hook sysinit_prefsck + + if [[ -x $(type -P fsck) ]]; then + stat_busy "Checking Filesystems" + fsck -A -T -C$FSCK_FD -a -t "$NETFS,noopts=_netdev" $FORCEFSCK >|$FSCK_OUT 2>|$FSCK_ERR + local -r fsckret=$? + (( fsckret <= 1 )) && stat_done || stat_fail + else + local -r fsckret=0 + fi + run_hook sysinit_postfsck + return $fsckret } @@ -415,11 +423,13 @@ fsck_reboot() { } mount_all() { + run_hook sysinit_premount + stat_busy "Mounting Local Filesystems" - run_hook sysinit_premount mount -a -t $NETFS -O no_netdev - run_hook sysinit_postmount stat_done + + run_hook sysinit_postmount } bootlogd_stop() { -- 1.7.1