]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
shutdown/shutdown.sh: loop over shutdown hooks until all succeed 28/head
authorLukas Wunner <lukas@wunner.de>
Mon, 6 Oct 2014 11:43:58 +0000 (13:43 +0200)
committerLukas Wunner <lukas@wunner.de>
Mon, 6 Oct 2014 11:43:58 +0000 (13:43 +0200)
Up until now, _check_shutdown() returns true if at least one of
the shutdown hooks succeeded. Change this to only return true if
*all* succeeded. To prevent an infinite loop, introduce an upper
bound of 40 iterations.

modules.d/99shutdown/shutdown.sh

index 6e5e559f98fc063a2caeeb732c06d749c8649132..98eab1d88cf156837509e83c6140f7768d99ad28 100755 (executable)
@@ -90,16 +90,19 @@ _check_shutdown() {
         ( . "$__f" $1 )
         if [ $? -eq 0 ]; then
             rm -f -- $__f
+        else
             __s=0
         fi
     done
     return $__s
 }
 
-while _check_shutdown; do
-:
+_cnt=0
+while [ $_cnt -le 40 ]; do
+    _check_shutdown || break
+    _cnt=$(($_cnt+1))
 done
-_check_shutdown final
+[ $_cnt -ge 40 ] && _check_shutdown final
 
 getarg 'rd.break=shutdown' && emergency_shell --shutdown shutdown "Break before shutdown"