chiark / gitweb /
buildd-reboot: Only touch no-daemon-please if there is currently a buildd.pid.
[dsa-metapackages.git] / buildd-reboot
index d2e9a5831c58a7712c418a46fa148d0ca8f8f56a..237fb8b8b0e38304872e629501a532f121ae295a 100755 (executable)
@@ -80,9 +80,9 @@ buildd_wait_and_reboot() {
        fi
 
        if [ "$halt" = 1 ]; then
-               /sbin/shutdown -p 15 "$reason"
+               /sbin/shutdown -h 15 "$reason"
        else
-               /sbin/shutdown -p 15 "$reason"
+               /sbin/shutdown -r 15 "$reason"
        fi
 }
 
@@ -100,13 +100,17 @@ if ! [ -d ~buildd ]; then
 fi
 
 if ! test -e ~buildd/NO-DAEMON-PLEASE; then
-       echo "Touching ~buildd/NO-DAEMON-PLEASE ~buildd/EXIT-DAEMON-PLEASE"
-       sudo -u buildd touch ~buildd/NO-DAEMON-PLEASE ~buildd/EXIT-DAEMON-PLEASE
-       sudo -u buildd sh -c 'echo delete-on-boot > ~buildd/NO-DAEMON-PLEASE'
-       sudo chgrp -v adm ~buildd/NO-DAEMON-PLEASE
-
-       echo "Sending HUP to buildd"
-       sudo -u buildd kill -HUP `sudo cat ~buildd/build/buildd.pid`
+       if [ -e ~buildd/build/buildd.pid ] ; then
+               echo "Touching ~buildd/NO-DAEMON-PLEASE ~buildd/EXIT-DAEMON-PLEASE"
+               sudo -u buildd touch ~buildd/NO-DAEMON-PLEASE ~buildd/EXIT-DAEMON-PLEASE
+               sudo -u buildd sh -c 'echo delete-on-boot > ~buildd/NO-DAEMON-PLEASE'
+               sudo chgrp -v adm ~buildd/NO-DAEMON-PLEASE
+
+               echo "Sending HUP to buildd"
+               sudo -u buildd kill -HUP `sudo cat ~buildd/build/buildd.pid`
+       else
+               echo "no-daemon-please does not exist, but there is no buildd.pid file either"
+       fi
 else
        echo "no-daemon-please already exists"
 fi