summaryrefslogtreecommitdiffstats
path: root/init_node
blob: 30551e8ba260b34d4001b0a6c0faae4001410b8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
#
# Copyright 2014-2017 Holger Levsen <holger@layer-acht.org>
#
# released under the GPLv=2
#
# initial setup for new build nodes
# - this script assumes that the user running it has unlimited sudo powers…
# - it's also assumed that this script is once manually scp'ed to the new node
#   and run there manually once :)

# let's check our assumptions first…
if [ $(sudo id -u) -ne 0 ] ; then
	echo we need sudo… exiting.
	exit 1
elif [ $(id -u) -eq 0 ] ; then
	echo please dont run this as root… exiting.
	exit 1
fi

START=$(date +'%s')
GIT_REPO="git://anonscm.debian.org/qa/jenkins.debian.net.git"

echo
echo "$(date -u)"
set -e
export LANG=C
set -x
sudo addgroup --system jenkins
sudo adduser --system --shell /bin/bash --home /var/lib/jenkins --ingroup jenkins --disabled-login jenkins
sudo addgroup --system jenkins-adm
sudo adduser --system --shell /bin/bash --home /home/jenkins-adm --ingroup jenkins-adm --disabled-login jenkins-adm
sudo usermod -G jenkins jenkins-adm
sudo chown jenkins-adm.jenkins-adm /home/jenkins-adm
cd ~jenkins-adm
[ -x /usr/bin/git ] || sudo apt-get install -y git
sudo su jenkins-adm -l -c "git clone $GIT_REPO"
cd jenkins.debian.net
sudo mkdir -p /var/log/jenkins/
sudo chown jenkins.jenkins /var/log/jenkins/
set +x
set +e
./update_jdn.sh 2>&1 | sudo tee -a /var/log/jenkins/update_jdn.log

END=$(date +'%s')
DURATION=$(( $END - $START ))
HOUR=$(echo "$DURATION/3600"|bc)
MIN=$(echo "($DURATION-$HOUR*3600)/60"|bc)
SEC=$(echo "$DURATION-$HOUR*3600-$MIN*60"|bc)
echo "$(date -u) - total duration: ${HOUR}h ${MIN}m ${SEC}s."
echo
echo "#### NOTE ####   (Those sudo problems are normal, see below!   #### NOTE ####"
echo
echo "Now log out and log in again (to aquire new group memberships, so that above sudo"
echo "problems are gone) and run:"
echo "        cd ~jenkins-adm/jenkins.debian.net/"
echo "        ./update_jdn.sh 2>&1 | sudo tee -a /var/log/jenkins/update_jdn.log"