From f47e0234987e7e6cfb2439e90658cb5c3b8bdef8 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Wed, 20 Jul 2011 21:11:36 +0200 Subject: [PATCH] shutdown: fixed check_shutdown loop --- modules.d/90dm/dm-shutdown.sh | 11 ++++++----- modules.d/90mdraid/md-shutdown.sh | 9 ++++++--- modules.d/99shutdown/shutdown | 24 ++++++++++++++---------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/modules.d/90dm/dm-shutdown.sh b/modules.d/90dm/dm-shutdown.sh index 3e668f8..80d80d0 100644 --- a/modules.d/90dm/dm-shutdown.sh +++ b/modules.d/90dm/dm-shutdown.sh @@ -3,13 +3,14 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh _do_dm_shutdown() { local ret + local final=$1 info "Disassembling device-mapper devices" dmsetup -v remove_all ret=$? -#info "dmsetup ls --tree" -#dmsetup ls --tree 2>&1 | vinfo + if [ "x$final" != "x" ]; then + info "dmsetup ls --tree" + dmsetup ls --tree 2>&1 | vinfo + fi return $ret } - -_do_dm_shutdown - +_do_dm_shutdown $1 diff --git a/modules.d/90mdraid/md-shutdown.sh b/modules.d/90mdraid/md-shutdown.sh index aa89bf6..bc36166 100644 --- a/modules.d/90mdraid/md-shutdown.sh +++ b/modules.d/90mdraid/md-shutdown.sh @@ -3,12 +3,15 @@ # ex: ts=8 sw=4 sts=4 et filetype=sh _do_md_shutdown() { local ret + local final=$1 info "Disassembling mdraid devices." mdadm -v --stop --scan ret=$? -#info "cat /proc/mdstat" -# cat /proc/mdstat | vinfo + if [ "x$final" != "x" ]; then + info "cat /proc/mdstat" + cat /proc/mdstat | vinfo + fi return $ret } -_do_md_shutdown +_do_md_shutdown $1 diff --git a/modules.d/99shutdown/shutdown b/modules.d/99shutdown/shutdown index bff29b9..a31a95d 100755 --- a/modules.d/99shutdown/shutdown +++ b/modules.d/99shutdown/shutdown @@ -64,21 +64,25 @@ while [ $_cnt -le 40 ]; do done [ $_cnt -ge 40 ] && umount_a -check_finished() { - local f - for f in $hookdir/shutdown/*.sh; do - [ -e "$f" ] || continue - ( . "$f" ) || return 1 +_check_shutdown() { + local __f + local __s=1 + for __f in $hookdir/shutdown/*.sh; do + [ -e "$__f" ] || continue + ( . "$__f" $1 ) + if [ $? -eq 0 ]; then + rm -f $__f + __s=0 + fi done - return 0 + return $__s } _cnt=0 -while [ $_cnt -le 40 ]; do - check_finished 2>/dev/null && break - _cnt=$(($_cnt+1)) +while _check_shutdown; do +: done -[ $_cnt -ge 40 ] && check_finished +_check_shutdown final getarg 'rd.break=shutdown' && emergency_shell -n cmdline "Break before shutdown" [ "$1" = "reboot" ] && reboot -f -d -n --no-wall