Gary Wu | 39a2f2f | 2017-11-10 13:38:28 -0800 | [diff] [blame^] | 1 | #!/bin/bash -x |
Gary Wu | 5cccfa9 | 2017-08-02 12:03:10 -0700 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2017 Huawei Technologies Co., Ltd. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
Gary Wu | b2076ff | 2017-06-22 13:29:06 -0700 | [diff] [blame] | 11 | |
| 12 | function restart_jenkins() { |
| 13 | sudo systemctl restart jenkins |
| 14 | sleep 1 |
| 15 | echo -n "Restarting jenkins" |
| 16 | until $(curl --output /dev/null --silent --head --fail http://localhost:8080/login); do |
| 17 | printf '.' |
| 18 | sleep 3 |
| 19 | done |
| 20 | echo |
| 21 | sleep 1 |
| 22 | } |
Gary Wu | 213a835 | 2017-06-16 13:44:28 -0700 | [diff] [blame] | 23 | |
| 24 | sed -i 's|archive\.ubuntu\.com|mirrors.ocf.berkeley.edu|g' /etc/apt/sources.list |
| 25 | |
Gary Wu | b2076ff | 2017-06-22 13:29:06 -0700 | [diff] [blame] | 26 | # Assume that the vagrant host is running a local Nexus proxy |
Gary Wu | 213a835 | 2017-06-16 13:44:28 -0700 | [diff] [blame] | 27 | echo "192.168.33.1 nexus-proxy" >> /etc/hosts |
| 28 | |
| 29 | |
| 30 | cat >> /etc/inputrc <<EOF |
| 31 | set show-all-if-ambiguous on |
| 32 | set show-all-if-unmodified on |
| 33 | set match-hidden-files off |
| 34 | set mark-symlinked-directories on |
| 35 | EOF |
| 36 | |
| 37 | |
| 38 | apt-get update |
| 39 | apt-get -y install git |
Gary Wu | b2076ff | 2017-06-22 13:29:06 -0700 | [diff] [blame] | 40 | git config --global user.email "jenkins@localhost" |
| 41 | git config --global user.name "jenkins" |
Gary Wu | 39a2f2f | 2017-11-10 13:38:28 -0800 | [diff] [blame^] | 42 | apt-get -y install curl openjdk-8-jdk-headless maven unzip python-pip |
Gary Wu | 213a835 | 2017-06-16 13:44:28 -0700 | [diff] [blame] | 43 | |
| 44 | # install Jenkins |
| 45 | wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add - |
| 46 | sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list' |
| 47 | apt-get update |
Gary Wu | 39a2f2f | 2017-11-10 13:38:28 -0800 | [diff] [blame^] | 48 | apt-get -y install jenkins |
Gary Wu | 213a835 | 2017-06-16 13:44:28 -0700 | [diff] [blame] | 49 | |
Gary Wu | 39a2f2f | 2017-11-10 13:38:28 -0800 | [diff] [blame^] | 50 | # install docker |
Gary Wu | 213a835 | 2017-06-16 13:44:28 -0700 | [diff] [blame] | 51 | apt-get -y install docker.io |
Gary Wu | 213a835 | 2017-06-16 13:44:28 -0700 | [diff] [blame] | 52 | sudo usermod -aG docker jenkins |
| 53 | |
| 54 | su -l jenkins -c "/vagrant/jenkins-init-1.sh" |
| 55 | |
Gary Wu | b2076ff | 2017-06-22 13:29:06 -0700 | [diff] [blame] | 56 | restart_jenkins |
Gary Wu | 213a835 | 2017-06-16 13:44:28 -0700 | [diff] [blame] | 57 | |
| 58 | su -l jenkins -c "/vagrant/jenkins-init-2.sh" |
| 59 | |
Gary Wu | b2076ff | 2017-06-22 13:29:06 -0700 | [diff] [blame] | 60 | restart_jenkins |
Gary Wu | 213a835 | 2017-06-16 13:44:28 -0700 | [diff] [blame] | 61 | |
| 62 | su -l jenkins -c "/vagrant/jjb-init.sh" |
| 63 | |