--- /dev/null
+#!/bin/bash
+
+# copyright 2012-2013 Holger Levsen <holger@layer-acht.org>
+# 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
+
+#
+# output announcement mail headers
+#
+while read line ; do
+ if [ "$line" != "" ] ; then
+ echo $line
+ else
+ break
+ fi
+done < $MAIL
+echo
+mailtextbody < $MAIL ; echo
+echo "Attachments not shown here."
+echo
+#
+# send announcement mail
+#
+cat $MAIL | /usr/sbin/sendmail -t
+echo
+echo "Ok, announcement mail sent."
+
+#
+# finish
+#
+figlet Ok
+echo
+echo "Please continue testing of $(basename $SOURCE_DIR)."
+
--- /dev/null
+#!/bin/bash
+
+# copyright 2012-2013 Holger Levsen <holger@layer-acht.org>
+# GPL2 licenced
+
+set -e
+#set -x
+export
+echo
+
+TESTSERVER=pserver1301.ri.pb.local
+TESTSERVER_MGMT_IP=192.168.178.49
+TESTSERVER_MGMT_PASSWD_FILE=/etc/jenkins/pserver1301.ipmi
+
+#
+# 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
+
+#
+# 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 3
+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 -t $TMPFILE root@$TESTSERVER:/tmp/
+ssh -t root@$TESTSERVER $TMPFILE
+rm $TMPFILE
+ssh -t jenkins@$TESTSERVER sudo id
+
+#
+# finish
+#
+figlet Ok
+
+++ /dev/null
-#!/bin/bash
-
-# copyright 2012-2013 Holger Levsen <holger@layer-acht.org>
-# GPL2 licenced
-
-set -e
-#set -x
-export
-echo
-
-TESTSERVER=pserver1301.ri.pb.local
-TESTSERVER_MGMT_IP=192.168.178.49
-TESTSERVER_MGMT_PASSWD_FILE=/etc/jenkins/pserver1301.ipmi
-
-#
-# 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
-
-#
-# 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 3
-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
-
-
-#
-# output announcement mail headers
-#
-while read line ; do
- if [ "$line" != "" ] ; then
- echo $line
- else
- break
- fi
-done < $MAIL
-echo
-mailtextbody < $MAIL ; echo
-echo "Attachments not shown here."
-echo
-#
-# send announcement mail
-#
-cat $MAIL | /usr/sbin/sendmail -t
-echo
-echo "Ok, announcement mail sent."
-
-#
-# finish
-#
-figlet Ok
-echo
-echo "Please continue manual testing of $(basename $SOURCE_DIR)."
-