From 464053dfe9f619e7dda8123660d45343799cfcf6 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Thu, 7 Mar 2013 12:50:18 +0100 Subject: [PATCH] split testdeploy script into two, seperate sending mails --- liveboot_approval_mail.sh | 67 +++++++++++++++++++ ...eploy.sh => liveboot_pserver1301_deploy.sh | 41 ++++++------ 2 files changed, 86 insertions(+), 22 deletions(-) create mode 100755 liveboot_approval_mail.sh rename liveboot_testdeploy.sh => liveboot_pserver1301_deploy.sh (71%) diff --git a/liveboot_approval_mail.sh b/liveboot_approval_mail.sh new file mode 100755 index 0000000..e052f14 --- /dev/null +++ b/liveboot_approval_mail.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# copyright 2012-2013 Holger Levsen +# 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)." + diff --git a/liveboot_testdeploy.sh b/liveboot_pserver1301_deploy.sh similarity index 71% rename from liveboot_testdeploy.sh rename to liveboot_pserver1301_deploy.sh index 8e695c0..23dce75 100755 --- a/liveboot_testdeploy.sh +++ b/liveboot_pserver1301_deploy.sh @@ -111,32 +111,29 @@ if ! $(nc -z $TESTSERVER 22 ) ; then 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." +# 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 -echo -echo "Please continue manual testing of $(basename $SOURCE_DIR)." -- 2.39.5