]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
adding files as of request by mschiller
authorMathias Klette <mathias.klette@profitbricks.com>
Mon, 29 Apr 2013 15:51:32 +0000 (17:51 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Mon, 29 Apr 2013 15:51:32 +0000 (17:51 +0200)
liveboot_image_deploy.sh [new file with mode: 0755]
liveboot_pserver_reset.sh [new file with mode: 0755]

diff --git a/liveboot_image_deploy.sh b/liveboot_image_deploy.sh
new file mode 100755 (executable)
index 0000000..5e87903
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# copyright 2012-2013 Marjan Schiller <marjan.schiller@profitbricks.com>
+# GPL2 licenced
+
+set -e
+#set -x
+export
+echo
+
+#
+# check if we have a LIVEBOOT_BUILD_NUMBER
+#
+if [ "$LIVEBOOT_BUILD_NUMBER" != "" ] ; then
+       echo "Ok, got LIVEBOOT_BUILD_NUMBER=$LIVEBOOT_BUILD_NUMBER, which is valid."
+else 
+       echo "Fail, no LIVEBOOT_BUILD_NUMBER set."
+       exit 1
+fi
+
+#
+# check if there is an image for it
+#
+if [ -d /srv/mirror/liveboot/liveboot-????????-${LIVEBOOT_BUILD_NUMBER}/ ] ; then
+       SOURCE_DIR=$(ls -d /srv/mirror/liveboot/liveboot-????????-${LIVEBOOT_BUILD_NUMBER}/)
+       echo "Ok, found directory $SOURCE_DIR"
+else
+       figlet "Failure:"
+       echo "/srv/mirror/liveboot/liveboot-????????-${LIVEBOOT_BUILD_NUMBER}/ does not exist."
+       exit 1
+fi
+
+MAIL=$SOURCE_DIR/mail.txt
+if [ ! -e $MAIL ] ; then
+       figlet "Warning:"
+       echo "$MAIL does not exist, something wrong with the liveboot web UI or was it simply not used at all?"
+       exit 1
+fi
+
+#
+# create pending-approval link and rsync again
+#
+cd /srv/mirror/liveboot
+rm -f pending-approval
+ln -sfv $(basename $SOURCE_DIR) pending-approval
+echo "pending-approval link created, pointing to $SOURCE_DIR"
+$(dirname $0)/liveboot_rsync.sh
+
+#
+# finish
+#
+figlet Ok
+
diff --git a/liveboot_pserver_reset.sh b/liveboot_pserver_reset.sh
new file mode 100755 (executable)
index 0000000..3011770
--- /dev/null
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+# copyright 2012-2013 Holger Levsen <holger@layer-acht.org>
+# GPL2 licenced
+
+set -e
+#set -x
+export
+echo
+
+#
+# reboot TESTSERVER
+#
+echo "Scheduling hard-reset of $TESTSERVER via IPMI on $TESTSERVER_MGMT_IP"
+cat $TESTSERVER_MGMT_PASSWD_FILE | ipmitool -H $TESTSERVER_MGMT_IP  -U ADMIN -a chassis power reset
+
+#
+# Test if it's gone
+#
+sleep 10
+if $(ping -c 1 $TESTSERVER >/dev/null)  ; then
+       figlet "Warning:"
+       echo "$TESTSERVER responds to pings, even though it was reset 3secs ago, this should not happen, please investigate manually."
+       exit 1
+fi
+echo
+
+#
+# check for 10min whether it's booting up again
+#
+echo "Pinging $TESTSERVER..."
+for i in $(seq 1 60) ; do
+       sleep 10
+       echo -n "$(date +%H:%M:%S): "
+       if $(ping -c 1 $TESTSERVER >/dev/null)  ; then
+               echo "ICMP echo reply from $TESTSERVER, so let's assume it's booting now."
+               break
+       fi
+       echo "no ICMP echo reply received."
+done
+if ! $(ping -c 1 $TESTSERVER >/dev/null) ; then
+       figlet "Failure:"
+       echo "$TESTSERVER still down, please investigate."
+       exit 1
+fi
+echo
+
+#
+# check for 15min whether ssh comes back
+#
+echo "Checking for sshd running on $TESTSERVER..."
+for i in $(seq 1 90) ; do
+       sleep 10
+       if $(ping -c 1 $TESTSERVER >/dev/null)  ; then
+               echo -n "ping $TESTSERVER ok..."
+               # check ssh FIXME
+               if $(nc -z $TESTSERVER 22 ) ; then
+                       echo "ok, sshd is running at $(date +%H:%M:%S)"
+                       break
+               else
+                       echo "but sshd is not running at $(date +%H:%M:%S)"
+               fi
+       fi
+done
+if ! $(nc -z $TESTSERVER 22 ) ; then
+       figlet "Failure:"
+       echo "$TESTSERVER still not running sshd, please investigate."
+       exit 1
+fi
+echo
+
+#
+# add jenkins user and sudoers.d/jenkins for it
+#
+TMPFILE=$(mktemp)
+cat > $TMPFILE <<-EOF
+addgroup --system jenkins
+adduser --system --home /home/jenkins --shell /bin/bash --ingroup jenkins --disabled-password --gecos "Profitbricks jenkins user" jenkins
+mkdir -p /home/jenkins/.ssh
+echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDiQRvDBjX4+oSAhoKIWQ/QKLDp3Zg5eKif89wjWbE0uvxAeaAzcEcN/Kkxcf6D37KmpQnWS3OyIyy7+K6BKy51HEaemnMLLzcNIKWkhkZZnbbZDWZxURBl+cE7EZ0vlN6dXFCIWftU5UVSo11U3UKUPL3o4omZvAtgakOWBam8OLM2RArzqjLEC0KouCqRBXmbQPllIYKIC1r/nYPdMfDklLna+Y1fEiRYvrP7SwNZBBxZHvqTMXeCv+xGq4QLBbCFHR5RtU4f0IS5Lqx/mrGfYykDP1KDTcqA3fBWURUC1VMmjzd0ez3gvSnLZTLuF1f1VQcydveNZ5beCoDt8j3J jenkins@sagunt" > /home/jenkins/.ssh/authorized_keys
+chmod 700 /home/jenkins/.ssh
+chmod 700 /home/jenkins/.ssh/authorized_keys
+chown jenkins.jenkins -R /home/jenkins
+echo "jenkins  ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/jenkins
+chmod 440 /etc/sudoers.d/jenkins
+chown root:root /etc/sudoers.d/jenkins
+EOF
+scp -o StrictHostKeychecking=no -i ~/.ssh/id_ritest $TMPFILE root@$TESTSERVER:/tmp/
+ssh -o StrictHostKeychecking=no -i ~/.ssh/id_ritest -t root@$TESTSERVER bash $TMPFILE
+rm $TMPFILE
+ssh -o StrictHostKeychecking=no -i ~/.ssh/id_ritest -t jenkins@$TESTSERVER sudo id
+
+#
+# finish
+#
+figlet Ok
+