Control: tags -1 + patch

I suspect a good fix for this is to make sure we always remove
policy-rc.d if we created it, independent of how the setup script was
terminated.  This will make sure both ^c and other ways to exit are
properly handled.

James, can you test this and verify that it work before it is commited?
I lack the space required for a test bench at the moment.

diff --git a/setup b/setup
index 5e31cf9..904ef34 100755
--- a/setup
+++ b/setup
@@ -1,6 +1,14 @@
 #!/bin/sh
 
-# Make sure configuring packages do not start any services
+at_exit() {
+    if $policyd ; then
+       rm /usr/sbin/policy-rc.d
+    fi
+}
+
+# Make sure configuring packages do not start any services.  Also make
+# sure we remove policy-rc.d only if we created it.
+trap at_exit SIGHUP SIGINT SIGTERM SIGEXIT
 if [ ! -e /usr/sbin/policy-rc.d ] ; then
     cat > /usr/sbin/policy-rc.d <<EOF
 #!/bin/sh
@@ -11,12 +19,8 @@ EOF
 else
     policyd=false
 fi
+
 for f in /usr/lib/freedombox/setup.d/* ; do
     echo "running $f"
     $f
 done
-
-# Allow services to start after upgrading
-if $policyd ; then
-    rm /usr/sbin/policy-rc.d
-fi
-- 
Happy hacking
Petter Reinholdtsen

Reply via email to