chiark / gitweb /
Update buildd-reboot script to also stop buildd2
authorPeter Palfrader <peter@palfrader.org>
Sat, 5 Jul 2014 13:23:03 +0000 (15:23 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sat, 5 Jul 2014 13:23:03 +0000 (15:23 +0200)
buildd-reboot
debian/changelog

index 3ba1f045b6a8b43216574ab237c8a8f094b18c8a..d77667dfa1c627de2dd99ec05907820f9977b077 100755 (executable)
@@ -44,6 +44,30 @@ if [ "$#" != 1 ]; then
 fi
 reason="$1"
 
+touch_stuff() {
+       local user="$1"
+       local home=$(getent passwd "$user" | awk -F: '{print $6}')
+
+       if ! test -e "$home"/NO-DAEMON-PLEASE; then
+               if [ -e "$home"/build/buildd.pid ] ; then
+                       echo "Touching ${home}/NO-DAEMON-PLEASE ${home}/EXIT-DAEMON-PLEASE"
+                       sudo -u "$user" touch "$home"/NO-DAEMON-PLEASE "$home"/EXIT-DAEMON-PLEASE
+                       sudo -u "$user" sh -c "echo waiting-for-clean-shutdown > '${home}/'NO-DAEMON-PLEASE"
+                       sudo chgrp -v adm "$home"/NO-DAEMON-PLEASE
+
+                       echo "Sending HUP to $user:buildd"
+                       sudo -u "$user" kill -HUP "$(sudo cat "${home}"/build/buildd.pid)"
+               else
+                       echo "$user: no-daemon-please does not exist, but there is no buildd.pid file either"
+                       if pgrep -u "$user" -x buildd ; then
+                               echo "But there is a buildd running.  Bad?"
+                               exit 3
+                       fi
+               fi
+       else
+               echo "no-daemon-please already exists"
+       fi
+}
 
 
 wall_counter=0
@@ -62,14 +86,14 @@ maybe_wall() {
 buildd_wait_and_reboot() {
        echo -n "Waiting for buildd to shut down"
 
-       while test -e ~buildd/build/buildd.pid ; do
+       while test -e ~buildd/build/buildd.pid  ||  test -e ~buildd2/build/buildd.pid; do
                echo -n "."
                sleep 5
                maybe_wall
        done
        echo
 
-       if pgrep -u buildd -x buildd ; then
+       if pgrep -u buildd -x buildd || pgrep -u buildd2 - x buildd; then
                echo "pidfile is gone, but buildd process still runs"
                while pgrep -u buildd -x buildd ; do
                        echo -n "."
@@ -82,6 +106,9 @@ buildd_wait_and_reboot() {
        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 grep 'waiting-for-clean-shutdown' ~buildd2/NO-DAEMON-PLEASE > /dev/null; then
+               sudo -u buildd2 sh -c 'echo delete-on-boot > ~buildd2/NO-DAEMON-PLEASE'
+       fi
        if [ "$halt" = 1 ]; then
                /sbin/shutdown -h 1 "$reason"
        else
@@ -102,24 +129,7 @@ if ! [ -d ~buildd ]; then
        exit 3
 fi
 
-if ! test -e ~buildd/NO-DAEMON-PLEASE; then
-       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
+touch_stuff buildd
+[ -d ~buildd2 ] && touch_stuff buildd2
 
 buildd_wait_and_reboot
index ec74f129c0696f3d0b81a6d58a8bd762c85b67f4..7a4fee8928b2cffcfa22041541b07477d7ef9e43 100644 (file)
@@ -3,6 +3,7 @@ debian.org (55) UNRELEASED; urgency=low
   [ Peter Palfrader ]
   * buildd:
     + libyaml-libyaml-perl
+  * Update buildd-reboot script to also stop buildd2.
 
   [ Holger Levsen ]
   * piuparts*.debian.org:
@@ -23,7 +24,7 @@ debian.org (55) UNRELEASED; urgency=low
     + python-ldap
     + bump version on python-django and python-requests
 
- -- Peter Palfrader <weasel@debian.org>  Sat, 24 May 2014 19:26:03 +0200
+ -- Peter Palfrader <weasel@debian.org>  Sat, 05 Jul 2014 15:22:45 +0200
 
 debian.org (54) unstable; urgency=medium