Blame 0001-shutdown-shutdown.sh-loop-over-shutdown-hooks-until-.patch

Harald Hoyer eeb1c2
From b09faad8779f5579b2f1c559edf7c0570e8d50ac Mon Sep 17 00:00:00 2001
Harald Hoyer eeb1c2
From: Lukas Wunner <lukas@wunner.de>
Harald Hoyer eeb1c2
Date: Mon, 6 Oct 2014 13:43:58 +0200
Harald Hoyer eeb1c2
Subject: [PATCH] shutdown/shutdown.sh: loop over shutdown hooks until all
Harald Hoyer eeb1c2
 succeed
Harald Hoyer eeb1c2
Harald Hoyer eeb1c2
Up until now, _check_shutdown() returns true if at least one of
Harald Hoyer eeb1c2
the shutdown hooks succeeded. Change this to only return true if
Harald Hoyer eeb1c2
*all* succeeded. To prevent an infinite loop, introduce an upper
Harald Hoyer eeb1c2
bound of 40 iterations.
Harald Hoyer eeb1c2
---
Harald Hoyer eeb1c2
 modules.d/99shutdown/shutdown.sh | 9 ++++++---
Harald Hoyer eeb1c2
 1 file changed, 6 insertions(+), 3 deletions(-)
Harald Hoyer eeb1c2
Harald Hoyer eeb1c2
diff --git a/modules.d/99shutdown/shutdown.sh b/modules.d/99shutdown/shutdown.sh
Harald Hoyer eeb1c2
index 6e5e559..98eab1d 100755
Harald Hoyer eeb1c2
--- a/modules.d/99shutdown/shutdown.sh
Harald Hoyer eeb1c2
+++ b/modules.d/99shutdown/shutdown.sh
Harald Hoyer eeb1c2
@@ -90,16 +90,19 @@ _check_shutdown() {
Harald Hoyer eeb1c2
         ( . "$__f" $1 )
Harald Hoyer eeb1c2
         if [ $? -eq 0 ]; then
Harald Hoyer eeb1c2
             rm -f -- $__f
Harald Hoyer eeb1c2
+        else
Harald Hoyer eeb1c2
             __s=0
Harald Hoyer eeb1c2
         fi
Harald Hoyer eeb1c2
     done
Harald Hoyer eeb1c2
     return $__s
Harald Hoyer eeb1c2
 }
Harald Hoyer eeb1c2
 
Harald Hoyer eeb1c2
-while _check_shutdown; do
Harald Hoyer eeb1c2
-:
Harald Hoyer eeb1c2
+_cnt=0
Harald Hoyer eeb1c2
+while [ $_cnt -le 40 ]; do
Harald Hoyer eeb1c2
+    _check_shutdown || break
Harald Hoyer eeb1c2
+    _cnt=$(($_cnt+1))
Harald Hoyer eeb1c2
 done
Harald Hoyer eeb1c2
-_check_shutdown final
Harald Hoyer eeb1c2
+[ $_cnt -ge 40 ] && _check_shutdown final
Harald Hoyer eeb1c2
 
Harald Hoyer eeb1c2
 getarg 'rd.break=shutdown' && emergency_shell --shutdown shutdown "Break before shutdown"
Harald Hoyer eeb1c2