Skip to contentSkip to conversation

shutdown: move scripts instead of deleting them

PATCH New Will Woods 1 participant 1 message Feb 28, 2013

lore
Share & tools
lore

Will Woods

author
#0 lore raw

PATCH 1/1 shutdown: move scripts instead of deleting them

Unlike every other rd.break=XXX breakpoint, shutdown happens *after* the shutdown scripts are run. Furthermore, shutdown deletes the scripts after they run.

This makes debugging tricky if you have something that's supposed to dynamically generate shutdown scripts - they've all been deleted by the time the 'shutdown' shell starts.

So just for the sake of clarity, move finished scripts out of the way to $hookdir/shutdown/done rather than deleting them outright.

---
 modules.d/99shutdown/shutdown.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
modules.d/99shutdown/shutdown.sh +2 -1
index 202ecb1..6f843f6 100755
@@ -84,13 +84,14 @@ _check_shutdown() {
         [ -e "$__f" ] || continue
         ( . "$__f" $1 )
         if [ $? -eq 0 ]; then
-            rm -f $__f
+            mv -f $__f $hookdir/shutdown/done
             __s=0
         fi
     done
     return $__s
 }
 
+mkdir -p $hookdir/shutdown/done
 while _check_shutdown; do
 :
 done
Signature · 1 line
1.8.1.2