init_node 1.71 KB
Newer Older
1 2
#!/bin/bash
#
3
# Copyright 2014-2018 Holger Levsen <holger@layer-acht.org>
4 5 6 7
#
# released under the GPLv=2
#
# initial setup for new build nodes
8
# - this script must be run as root
9 10
# - it's also assumed that this script is once manually scp'ed to the new node
#   and run there manually once :)
11 12

# let's check our assumptions first…
13
if [ $(id -u) -ne 0 ] ; then
14 15 16 17
	echo we need sudo… exiting.
	exit 1
fi

18
START=$(date +'%s')
19
GIT_REPO="https://salsa.debian.org/qa/jenkins.debian.net.git"
20 21

echo
22
echo "$(date -u)"
23 24
set -e
export LANG=C
25
set -x
26 27 28 29 30
addgroup --system jenkins
adduser --system --shell /bin/bash --home /var/lib/jenkins --ingroup jenkins --disabled-login jenkins
addgroup --system jenkins-adm
adduser --system --shell /bin/bash --home /home/jenkins-adm --ingroup jenkins-adm --disabled-login jenkins-adm
usermod -G jenkins jenkins-adm
31
echo '%jenkins-adm ALL= NOPASSWD: ALL' > /etc/sudoers.d/jenkins-adm # will be overwritten later
32
grep -q stretch-backports /etc/apt/sources.list || echo "deb http://deb.debian.org/debian/ stretch-backports main contrib non-free" >> /etc/apt/sources.list
33
chown jenkins-adm.jenkins-adm /home/jenkins-adm
34
cd ~jenkins-adm
35 36
[ -x /usr/bin/git ] || apt-get install -y git
su jenkins-adm -l -c "git clone $GIT_REPO"
37
cd jenkins.debian.net
38 39
mkdir -p /var/log/jenkins/
chown jenkins.jenkins /var/log/jenkins/
40
set +x
41
set +e
42 43 44

END=$(date +'%s')
DURATION=$(( $END - $START ))
45 46 47
HOUR=$(( $DURATION/3600 ))
MIN=$(( ($DURATION-$HOUR*3600)/60 ))
SEC=$(( $DURATION-$HOUR*3600-$MIN*60 ))
48
echo "$(date -u) - total duration: ${HOUR}h ${MIN}m ${SEC}s."
49
echo
Holger Levsen's avatar
Holger Levsen committed
50
echo "Now log out and log in as jenkins-adm and run:"
51 52
echo "        cd ~jenkins-adm/jenkins.debian.net/"
echo "        ./update_jdn.sh 2>&1 | sudo tee -a /var/log/jenkins/update_jdn.log"