X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dsa-metapackages.git;a=blobdiff_plain;f=buildd-reboot;h=237fb8b8b0e38304872e629501a532f121ae295a;hp=d082ef28366957043f9eb91ed8c7f2ddcc3915bb;hb=f0d5b2ab28621ea2f853cbd97942e326fcb1670a;hpb=205d6d70eb332f0e2070abff5750b7ea34ad4795 diff --git a/buildd-reboot b/buildd-reboot index d082ef2..237fb8b 100755 --- a/buildd-reboot +++ b/buildd-reboot @@ -50,7 +50,7 @@ wall_counter=0 maybe_wall() { wall_counter=$((wall_counter-1)) if [ "$wall_counter" -le 0 ]; then - if [ "$host" = 1 ]; then + if [ "$halt" = 1 ]; then echo "System will halt for $reason when buildd has stopped" | wall else echo "System will reboot for $reason when buildd has stopped" | wall @@ -79,10 +79,10 @@ buildd_wait_and_reboot() { echo fi - if [ "$host" = 1 ]; then - /sbin/shutdown -p 15 "$reason" + if [ "$halt" = 1 ]; then + /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