summaryrefslogtreecommitdiffstats
path: root/bin/reproducible_cleanup_nodes.sh
diff options
context:
space:
mode:
authorHolger Levsen <holger@layer-acht.org>2015-12-09 12:35:48 +0100
committerHolger Levsen <holger@layer-acht.org>2015-12-09 12:35:48 +0100
commit9f20c74c7cc4434b298c40f2786dbd9d54981bd8 (patch)
treebff7f1a319257143ada444aea9b5cd77f3f532b4 /bin/reproducible_cleanup_nodes.sh
parent3c2f65d77d08ab47ecc6ff75eecc729e64575a0b (diff)
downloadjenkins.debian.net-9f20c74c7cc4434b298c40f2786dbd9d54981bd8.tar.xz
reproducible: add new script, reproducible_cleanup_nodes.sh, to kill lonely build processes on all nodes
Diffstat (limited to 'bin/reproducible_cleanup_nodes.sh')
-rwxr-xr-xbin/reproducible_cleanup_nodes.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/bin/reproducible_cleanup_nodes.sh b/bin/reproducible_cleanup_nodes.sh
new file mode 100755
index 00000000..c6e0473a
--- /dev/null
+++ b/bin/reproducible_cleanup_nodes.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# Copyright © 2015 Holger Levsen <holger@layer-acht.org>
+# released under the GPLv=2
+
+DEBUG=false
+. /srv/jenkins/bin/common-functions.sh
+common_init "$@"
+
+# common code defining db access
+. /srv/jenkins/bin/reproducible_common.sh
+
+# only run this on the main node
+if [ "$HOSTNAME" != "jenkins" ] ; then
+ echo "this script must only be run on the main node, aborting."
+ exit 1
+fi
+
+# deny running this if jenkins is still running
+RESULT=$(ps fax|grep '/usr/share/jenkins/jenkins.war'|grep -v grep||true)
+if [ -n "$RESULT" ] ; then
+ echo "jenkins is still running, aborting."
+ exit 1
+else
+ echo "jenkins is not running, ok, let's go."
+
+# simple confirmation needed
+echo
+echo "Warning: running this will kill all processes by the 1111, 2222 and jenkins"
+echo " users. Press return if you want this, else better press CTRL-C now."
+echo
+read
+
+export JOB_NAME="cleanup_nodes"
+for NODE in $BUILD_NODES ; do
+ # call jenkins_master_wrapper.sh so we only need to track different ssh ports in one place
+ # jenkins_master_wrapper.sh needs NODE_NAME and JOB_NAME
+ export NODE_NAME=$NODE
+ echo "$(date -u) - Killing build processes on $NODE now:"
+ /srv/jenkins/bin/jenkins_master_wrapper.sh /srv/jenkins/bin/reproducible_slay.sh
+ echo "$(date -u) - done killing processes on $NODE."
+done
+