X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dsa-metapackages.git;a=blobdiff_plain;f=buildd-reboot;h=dc45094b71ad242a4bca922882536f60d283e76f;hp=d2e9a5831c58a7712c418a46fa148d0ca8f8f56a;hb=b6cee345c8eedfda7c4001fd71f4de7b4a729bd2;hpb=decc3ecfc1d6525e2d9eb1541155fa4fcd2e41af diff --git a/buildd-reboot b/buildd-reboot index d2e9a58..dc45094 100755 --- a/buildd-reboot +++ b/buildd-reboot @@ -79,10 +79,13 @@ buildd_wait_and_reboot() { echo fi + if grep 'waiting-for-clean-shutdown' ~buildd/NO-DAEMON-PLEASE > /dev/null; then + sudo -u buildd sh -c 'echo delete-on-boot > ~buildd/NO-DAEMON-PLEASE' + 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 +103,21 @@ 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 waiting-for-clean-shutdown > ~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" + if pgrep -u buildd -x buildd ; then + echo "But there is a buildd running. Bad?" + exit 3 + fi + fi else echo "no-daemon-please already exists" fi