forked from rgl/jenkins-vagrant
-
Notifications
You must be signed in to change notification settings - Fork 1
/
provision-ubuntu.sh
87 lines (67 loc) · 1.85 KB
/
provision-ubuntu.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
set -eux
config_fqdn=$(hostname --fqdn)
config_ip=10.10.10.101
config_jenkins_master_fqdn='jenkins.example.com'
config_jenkins_master_ip=10.10.10.100
echo 'Defaults env_keep += "DEBIAN_FRONTEND"' >/etc/sudoers.d/env_keep_apt
chmod 440 /etc/sudoers.d/env_keep_apt
export DEBIAN_FRONTEND=noninteractive
#
# make sure the package index cache is up-to-date before installing anything.
apt-get update
#
# install dependencies.
apt-get install -y openjdk-8-jre-headless
#
# install LLVM for evmjit builds
apt-get install -y llvm-7 llvm-7-dev
#
# add the jenkins user.
groupadd --system jenkins
adduser \
--system \
--disabled-login \
--no-create-home \
--gecos '' \
--ingroup jenkins \
--home /var/jenkins \
--shell /bin/bash \
jenkins
#
# install the slave.
install -d -o jenkins -g jenkins -m 750 /var/jenkins
pushd /var/jenkins
install -d -o jenkins -g jenkins -m 750 {bin,lib,.ssh}
install -o jenkins -g jenkins -m 640 /dev/null .ssh/authorized_keys
cat /vagrant/tmp/$config_jenkins_master_fqdn-ssh-rsa.pub >>.ssh/authorized_keys
cat >bin/jenkins-slave <<EOF
#!/bin/sh
exec java -jar $PWD/lib/slave.jar
EOF
chmod +x bin/jenkins-slave
wget -q http://$config_jenkins_master_ip:8080/jnlpJars/slave.jar -O lib/slave.jar
popd
#
# install and configure git.
apt-get install -y git-core
su jenkins -c bash <<'EOF'
set -eux
git config --global user.email 'jenkins@example.com'
git config --global user.name 'Jenkins'
git config --global push.default simple
git config --global core.autocrlf false
EOF
#
# install pkg-config and libssl-dev
apt-get install -y pkg-config libssl-dev
#
# create artifacts that need to be shared with the other nodes.
mkdir -p /vagrant/tmp
pushd /vagrant/tmp
find \
/etc/ssh \
-name 'ssh_host_*_key.pub' \
-exec sh -c "(echo -n '$config_ip '; cat {})" \; \
>$config_fqdn.ssh_known_hosts
popd