forked from neerajprad/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installjenkins.sh
executable file
·65 lines (56 loc) · 2.41 KB
/
installjenkins.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
#!/bin/bash
set -e
cd ~
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get install -y git openjdk-7-jre-headless htop iotop tmux
sudo apt-get install -y python3.4-dev python-virtualenv python-wheel
sudo apt-get install -y authbind
# setup authbind
sudo touch /etc/authbind/byport/443
sudo chown $USER /etc/authbind/byport/443
sudo chmod 755 /etc/authbind/byport/443
rm -rf ~/env
virtualenv -p python3 ~/env
source ~/env/bin/activate
pip install -U pip
pip install -U wheel
pip install -U setuptools
pip install pyyaml
pip install requests
if ls ~/.jenkins >/dev/null 2>&1;
then
echo "WARNING WARNING: removing existing jenkins and it's configuration files"
read -p "Press enter for ok, Ctrl+C to exit " -n 1 -r
rm jenkins.war
rm -rf ~/.jenkins
fi
wget -c http://mirrors.jenkins-ci.org/war-stable/2.7.3/jenkins.war
if ! ls /etc/letsencrypt/live/build.pytorch.org >/dev/null 2>&1;
then
wget -c https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto
./certbot-auto certonly
sudo chmod 711 "/etc/letsencrypt"
sudo chmod 711 "/etc/letsencrypt/live"
sudo chmod 711 "/etc/letsencrypt/archive"
rm -f keys.pkcs12
rm -f jenkins.jks
openssl pkcs12 -inkey /etc/letsencrypt/live/build.pytorch.org/privkey.pem -in /etc/letsencrypt/live/build.pytorch.org/cert.pem -export -out keys.pkcs12 -passout "pass:jenkinspassword"
keytool -importkeystore -srckeystore keys.pkcs12 -srcstoretype pkcs12 -destkeystore jenkins.jks -srcstorepass jenkinspassword -deststorepass jenkinspassword
rm -f keys.pkcs12
fi
# start jenkins
builder/runjenkins.sh
sleep 15
eval $(python builder/readconfig.py)
echo "Go to https://build.pytorch.org and setup the initial admin user to \n Username: jenkins \nPassword: $jenkinspassword \nThe initial temporary credentials are: \nUsername: admin \nPassword:"
cat $HOME/.jenkins/secrets/initialAdminPassword
echo 'Remember to do this step: Go to Manage Jenkins -> Configure Global Security -> "TCP port for JNLP agents": choose random'
echo 'Remeber to do this step: "Manage Jenkins" > "Configure Global Security" -> "Prevent Cross Site Request Forgery exploits" -> Uncheck / Disable'
read -p "Press enter when finished setting up " -n 1 -r
# terminate jenkins
echo Finished setup. Shutting jenkins down
JENKINSCLI=~/.jenkins/war/WEB-INF/jenkins-cli.jar
java -jar ${JENKINSCLI} -s http://127.0.0.1:8080/ safe-shutdown --username jenkins --password $jenkinspassword