Skip to content
#!/bin/bash
# vim: set noexpandtab:
#
# Copyright 2014-2017 Holger Levsen <holger@layer-acht.org>
# © 2018 Mattia Rizzolo <mattia@debian.org>
#
# released under the GPLv=2
#
......@@ -29,7 +31,7 @@
START=$(date +'%s')
GIT_REPO="https://salsa.debian.org/qa/jenkins.debian.net.git"
export HOSTS="
HOSTS="
codethink-sled9-arm64.debian.net
codethink-sled10-arm64.debian.net
codethink-sled11-arm64.debian.net
......@@ -85,24 +87,16 @@ root@jenkins.debian.net
ALL_HOSTS=$HOSTS
node_in_the_future () {
case "$1" in
profitbricks-build4-amd64|profitbricks-build5-amd64|profitbricks-build6-i386|profitbricks-build15-amd64|profitbricks-build16-i386) true ;;
codethink-sled9*|codethink-sled11*|codethink-sled13*|codethink-sled15*) true ;;
*) false ;;
esac
}
echo
echo -n "$(date) - "
# real command, for running manually: cd ~jenkins-adm/jenkins.debian.net/ ; sudo -u jenkins-adm git pull ; ./update_jdn.sh
read -r -d '' real_command <<-EOF
set -e
export LANG=C
cd ~jenkins-adm
if [ ! -d jenkins.debian.net ]; then
[ -x /usr/bin/git ] || sudo apt-get install -y git
sudo -u jenkins-adm git clone $GIT_REPO
cd jenkins.debian.net
else
cd jenkins.debian.net
sudo -u jenkins-adm git pull $GIT_REPO
fi
./update_jdn.sh 2>&1 | sudo tee -a /var/log/jenkins/update_jdn.log
EOF
reset_clock=true
if [ "$1" = "all" ] ; then
echo -n "Running j.d.n.git updates on $HOSTS now"
......@@ -129,9 +123,10 @@ elif [ "$1" = "check" ] ; then
reset_clock=false
shift
elif [ "$1" = "" ] ; then
export HOSTS="root@jenkins.debian.net"
HOSTS="root@jenkins.debian.net"
echo -n "Running j.d.n.git updates on $HOSTS now"
elif [ "$1" = "jenkins" ] ; then
export HOSTS="root@jenkins.debian.net"
HOSTS="root@jenkins.debian.net"
shift
for i in $@ ; do
case $i in
......@@ -147,19 +142,19 @@ elif [ "$1" = "jenkins" ] ; then
10|pb10) HOSTS="$HOSTS profitbricks-build10-amd64.debian.net" ;;
11|pb11) HOSTS="$HOSTS profitbricks-build11-amd64.debian.net" ;;
15|pb15) HOSTS="$HOSTS profitbricks-build15-amd64.debian.net" ;;
c9) HOSTS="$HOSTS codethink-sled9-arm64.debian.net" ;;
c10) HOSTS="$HOSTS codethink-sled10-arm64.debian.net" ;;
c11) HOSTS="$HOSTS codethink-sled11-arm64.debian.net" ;;
c12) HOSTS="$HOSTS codethink-sled12-arm64.debian.net" ;;
c13) HOSTS="$HOSTS codethink-sled13-arm64.debian.net" ;;
c14) HOSTS="$HOSTS codethink-sled14-arm64.debian.net" ;;
c15) HOSTS="$HOSTS codethink-sled15-arm64.debian.net" ;;
c16) HOSTS="$HOSTS codethink-sled16-arm64.debian.net" ;;
c9|cs9) HOSTS="$HOSTS codethink-sled9-arm64.debian.net" ;;
c10|cs10) HOSTS="$HOSTS codethink-sled10-arm64.debian.net" ;;
c11|cs11) HOSTS="$HOSTS codethink-sled11-arm64.debian.net" ;;
c12|cs12) HOSTS="$HOSTS codethink-sled12-arm64.debian.net" ;;
c13|cs13) HOSTS="$HOSTS codethink-sled13-arm64.debian.net" ;;
c14|cs14) HOSTS="$HOSTS codethink-sled14-arm64.debian.net" ;;
c15|cs15) HOSTS="$HOSTS codethink-sled15-arm64.debian.net" ;;
c16|cs16) HOSTS="$HOSTS codethink-sled16-arm64.debian.net" ;;
armhf|amd64|i386|arm64) HOSTS="$HOSTS $(echo $ALL_HOSTS | sed 's# #\n#g' | grep $i)" ;;
*) if ping -c 1 $i ; then HOSTS="$HOSTS $i" ; fi ;;
esac
done
echo -n "Running j.d.n.git ('$real_command') updates on $HOSTS now"
echo -n "Running j.d.n.git updates on $HOSTS now"
fi
BG=""
......@@ -181,21 +176,32 @@ for i in $HOSTS ; do
done
HOSTS=$STSOH
for i in $HOSTS ; do
if [ -z "$real_command" ]; then
if node_in_the_future "$i"; then GITOPTS="-c http.sslVerify=false" ; fi
# real command, for running manually: cd ~jenkins-adm/jenkins.debian.net/ ; sudo -u jenkins-adm git pull ; ./update_jdn.sh
read -r -d '' real_command <<-EOF
set -e
export LANG=C
cd ~jenkins-adm
if [ ! -d jenkins.debian.net ]; then
[ -x /usr/bin/git ] || sudo apt-get install -y git
sudo -u jenkins-adm git ${GITOPTS:-} clone $GIT_REPO
cd jenkins.debian.net
else
cd jenkins.debian.net
sudo -u jenkins-adm git ${GITOPTS:-} pull $GIT_REPO
fi
./update_jdn.sh 2>&1 | sudo tee -a /var/log/jenkins/update_jdn.log
EOF
fi
echo -n "."
command="$real_command"
if $reset_clock ; then
case $i in
profitbricks-build4-amd64*|profitbricks-build5-amd64*|profitbricks-build6-i386*|profitbricks-build15-amd64*|profitbricks-build16-i386*)
if node_in_the_future "$i" ; then
# set correct future date
command="sudo ntpdate -b de.pool.ntp.org && $real_command && sudo date --set=\"+398 days +6 hours + 23 minutes\" && echo '__$(echo $i|cut -d '.' -f1)=ok__'"
;;
codethink-sled9*|codethink-sled11*|codethink-sled13*|codethink-sled15*)
# set correct future date
command="sudo ntpdate -b de.pool.ntp.org && $real_command && sudo date --set=\"+398 days +6 hours + 23 minutes\" && echo '__$(echo $i|cut -d '.' -f1)=ok__'"
;;
*)
;;
esac
fi
fi
get_arch_color $i
xterm -class deploy-jenkins -bg $BG -fa 'DejaVuSansMono' -fs 10 -e "ssh -o 'BatchMode = yes' -t $i '$command' | tee $LOG.$i ; sleep 2 ; touch $LOG.$i.done" &
......