blob: 91a813f18505c03a739c56208e11379c2a01f3e6 [file] [log] [blame]
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -08001#!/bin/bash
2# Ubuntu base build
3
4# vim: ts=4 sw=4 sts=4 et tw=72 :
5
6# force any errors to cause the script and job to end in failure
7set -xeu -o pipefail
8
9rh_systems() {
10 echo 'No changes to apply'
11}
12
Zack Williams85249ce2018-04-01 19:54:44 -070013ubuntu_install_java_setup() {
14
15 echo "debconf shared/accepted-oracle-license-v1-1 select true" | debconf-set-selections
16
17 apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
18
19 DISTRO=$(lsb_release -cs)
20
21 apt-add-repository \
22 "deb http://ppa.launchpad.net/webupd8team/java/ubuntu $DISTRO main"
23}
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080024
25ubuntu_systems() {
26 apt-get clean
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080027
Zack Williams85249ce2018-04-01 19:54:44 -070028 # get prereqs for PPA and apt-over-HTTPS support
29 apt-get update
30 apt-get install -y apt-transport-https software-properties-common
31
32 # install java (not needed as SonarQube includes this)
33 # ubuntu_install_java_setup
34 # apt-get update
35 # apt-get install -y oracle-java8-installer
Zack Williams4cfdf202018-05-07 09:58:12 -070036 # rm -rf /var/cache/oracle-jdk8-installer
Luca Prete31860c52018-03-06 17:54:38 -080037
38 # set up ansible repo
Zack Williams85249ce2018-04-01 19:54:44 -070039 apt-add-repository -y ppa:ansible/ansible
Luca Prete31860c52018-03-06 17:54:38 -080040
41 # set up docker repo
Zack Williams85249ce2018-04-01 19:54:44 -070042 apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88
43 add-apt-repository \
Luca Prete31860c52018-03-06 17:54:38 -080044 "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
45 $(lsb_release -cs) \
46 stable"
47
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080048 apt-get update
Luca Prete31860c52018-03-06 17:54:38 -080049
50 # install basic sofware requirements
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080051 apt-get install -y \
Zack Williams85249ce2018-04-01 19:54:44 -070052 "docker-ce=17.06*" \
Luca Prete31860c52018-03-06 17:54:38 -080053 ansible \
Luca Prete31860c52018-03-06 17:54:38 -080054 build-essential \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080055 bzip2 \
56 curl \
57 git \
58 less \
Zack Williams68f43102018-07-07 12:57:13 -070059 libpcap-dev \
Zack Williamscfe0b942018-04-12 11:47:57 -070060 libxml2-utils \
Kailash Khalasi1ddc7c62018-04-20 08:47:56 -070061 maven \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080062 nodejs \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080063 npm \
Zack Williams85249ce2018-04-01 19:54:44 -070064 python \
Zack Williams9754a832018-04-13 11:01:59 -070065 python-certifi \
66 python-cryptography \
Luca Prete31860c52018-03-06 17:54:38 -080067 python-dev \
Zack Williams9754a832018-04-13 11:01:59 -070068 python-idna \
Luca Prete31860c52018-03-06 17:54:38 -080069 python-netaddr \
Zack Williams9754a832018-04-13 11:01:59 -070070 python-openssl \
Luca Prete31860c52018-03-06 17:54:38 -080071 python-pip \
Zack Williams9754a832018-04-13 11:01:59 -070072 python-urllib3 \
Zack Williams40c06f02018-04-15 20:31:34 -070073 ruby \
Zack Williamseb842ae2018-05-15 17:07:32 -070074 socat \
Zack Williams85249ce2018-04-01 19:54:44 -070075 ssh \
Luca Prete31860c52018-03-06 17:54:38 -080076 sshpass \
Zack Williams85249ce2018-04-01 19:54:44 -070077 zip
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080078 # end of apt-get install list
Luca Prete31860c52018-03-06 17:54:38 -080079
80 # install python modules
Zack Williams85249ce2018-04-01 19:54:44 -070081 pip install \
82 Jinja2 \
83 ansible-lint \
84 astroid \
85 docker-compose==1.20.1 \
86 docker==3.2.1 \
Luca Prete31860c52018-03-06 17:54:38 -080087 gitpython \
Luca Prete90bfa5e2018-03-06 20:41:56 -080088 graphviz \
Kailash Khalasie15b27a2018-06-26 13:28:20 -070089 grpcio-tools \
Zack Williams85249ce2018-04-01 19:54:44 -070090 isort \
Zack Williams6828f822018-04-12 16:13:33 -070091 linkchecker \
Zack Williams85249ce2018-04-01 19:54:44 -070092 pexpect \
93 pylint \
94 pyyaml \
Luca Prete31860c52018-03-06 17:54:38 -080095 robotframework \
Kailash Khalasicb327c62018-04-03 10:41:38 -070096 robotframework-httplibrary \
Zack Williams85249ce2018-04-01 19:54:44 -070097 robotframework-requests \
Zack Williamsfd8a0042018-04-12 14:34:17 -070098 robotframework-sshlibrary \
99 virtualenv
Zack Williams85249ce2018-04-01 19:54:44 -0700100 # end of pip install list
Luca Prete31860c52018-03-06 17:54:38 -0800101
Zack Williams40c06f02018-04-15 20:31:34 -0700102 # install ruby gems
103 gem install \
104 mdl
105 # end of gem install list
106
Luca Prete31860c52018-03-06 17:54:38 -0800107 # install npm modules
108 npm install -g \
Zack Williams85249ce2018-04-01 19:54:44 -0700109 gitbook-cli \
110 markdownlint \
Luca Prete31860c52018-03-06 17:54:38 -0800111 typings
Zack Williams85249ce2018-04-01 19:54:44 -0700112 # end of npm install list
Luca Prete31860c52018-03-06 17:54:38 -0800113
Zack Williams6828f822018-04-12 16:13:33 -0700114 # ubuntu 16.04 installs the node binary as /usr/bin/nodejs, which breaks
115 # tools that expect it to be named just `node`. Symlink it to fix
116 ln -s /usr/bin/nodejs /usr/local/bin/node
117
Luca Prete31860c52018-03-06 17:54:38 -0800118 # install repo
Zack Williams85249ce2018-04-01 19:54:44 -0700119 REPO_SHA256SUM="394d93ac7261d59db58afa49bb5f88386fea8518792491ee3db8baab49c3ecda"
Luca Prete31860c52018-03-06 17:54:38 -0800120 curl -o /tmp/repo 'https://gerrit.opencord.org/gitweb?p=repo.git;a=blob_plain;f=repo;hb=refs/heads/stable'
Zack Williams85249ce2018-04-01 19:54:44 -0700121 echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c -
122 mv /tmp/repo /usr/local/bin/repo
123 chmod a+x /usr/local/bin/repo
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800124
Zack Williams85249ce2018-04-01 19:54:44 -0700125 # install sonarqube scanner
126 SONAR_SCANNER_CLI_VERSION="3.1.0.1141"
127 SONAR_SCANNER_CLI_SHA256SUM="efbe7d1a274bbed220846eccc5b36db853a6bab3ee576aebf93ddc604a89ced4"
Zack Williams4cfdf202018-05-07 09:58:12 -0700128 curl -L -o /tmp/sonarscanner.zip "https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux.zip"
Zack Williams85249ce2018-04-01 19:54:44 -0700129 echo "$SONAR_SCANNER_CLI_SHA256SUM /tmp/sonarscanner.zip" | sha256sum -c -
130 pushd /opt
131 unzip /tmp/sonarscanner.zip
132 mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux sonar-scanner
Zack Williams4cfdf202018-05-07 09:58:12 -0700133 rm -f /tmp/sonarscanner.zip
Zack Williams85249ce2018-04-01 19:54:44 -0700134 popd
135
Zack Williams4cfdf202018-05-07 09:58:12 -0700136 # install helm
Zack Williams286e3de2018-06-27 15:27:07 -0700137 HELM_VERSION="2.9.1"
138 HELM_SHA256SUM="56ae2d5d08c68d6e7400d462d6ed10c929effac929fedce18d2636a9b4e166ba"
Zack Williams8aa52822018-04-05 09:22:15 -0700139 HELM_PLATFORM="linux-amd64"
Zack Williams4cfdf202018-05-07 09:58:12 -0700140 curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz"
Zack Williams8aa52822018-04-05 09:22:15 -0700141 echo "$HELM_SHA256SUM /tmp/helm.tgz" | sha256sum -c -
142 pushd /tmp
143 tar -xzvf helm.tgz
144 mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
145 chmod a+x /usr/local/bin/helm
Zack Williams4cfdf202018-05-07 09:58:12 -0700146 rm -rf helm.tgz ${HELM_PLATFORM}
147 popd
148
Zack Williams4c5bfab2018-05-08 16:13:50 -0700149 # install kubectl
Zack Williams286e3de2018-06-27 15:27:07 -0700150 KUBECTL_VERSION="1.10.5"
151 KUBECTL_SHA256SUM="a9e7f82e516aa8a652bc485620483ea964eb940787cabf890d7eab96eaac294d"
Zack Williams4c5bfab2018-05-08 16:13:50 -0700152 curl -L -o /tmp/kubectl "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
153 echo "$KUBECTL_SHA256SUM /tmp/kubectl" | sha256sum -c -
154 mv /tmp/kubectl /usr/local/bin/kubectl
155 chmod a+x /usr/local/bin/kubectl
156 rm -f /tmp/kubectl
157
Zack Williams4cfdf202018-05-07 09:58:12 -0700158 # install minikube
Zack Williams286e3de2018-06-27 15:27:07 -0700159 MINIKUBE_VERSION="0.28.0"
Zack Williams4cfdf202018-05-07 09:58:12 -0700160 MINIKUBE_DEB_VERSION="$(echo ${MINIKUBE_VERSION} | sed -n 's/\(.*\)\.\(.*\)/\1-\2/p')"
Zack Williams286e3de2018-06-27 15:27:07 -0700161 MINIKUBE_SHA256SUM="5308f955f802a81cdb624fa8f6f5aeead642d203f25efd706cc55f04481bf7a3"
Zack Williams4cfdf202018-05-07 09:58:12 -0700162 curl -L -o /tmp/minikube.deb "https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube_${MINIKUBE_DEB_VERSION}.deb"
163 echo "$MINIKUBE_SHA256SUM /tmp/minikube.deb" | sha256sum -c -
164 pushd /tmp
165 dpkg -i minikube.deb
166 rm -f minikube.deb
Zack Williams8aa52822018-04-05 09:22:15 -0700167 popd
168
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700169 # install protobufs
170 PROTOC_VERSION="3.3.0"
171 PROTOC_SHA256SUM="feb112bbc11ea4e2f7ef89a359b5e1c04428ba6cfa5ee628c410eccbfe0b64c3"
172 curl -L -o /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip
173 echo "$PROTOC_SHA256SUM /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip" | sha256sum -c -
Kailash Khalasic4ff32d2018-06-28 18:24:52 -0700174 unzip /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /tmp/protoc3
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700175 mv /tmp/protoc3/bin/* /usr/local/bin/
176 mv /tmp/protoc3/include/* /usr/local/include/
177 # give sudo permissions on minikube and protoc to jenkins user
178 cat <<EOF >/etc/sudoers.d/88-jenkins-minikube-protoc
179Cmnd_Alias CMDS = /usr/local/bin/protoc, /usr/bin/minikube
Zack Williams81739772018-05-14 16:35:47 -0700180Defaults:jenkins !requiretty
Kailash Khalasi929d21b2018-06-28 12:28:17 -0700181jenkins ALL=(ALL) NOPASSWD:SETENV: CMDS
Zack Williams81739772018-05-14 16:35:47 -0700182EOF
183
Zack Williams85249ce2018-04-01 19:54:44 -0700184 # clean up
185 apt-get clean
186 apt-get purge -y
187 apt-get autoremove -y
188 rm -rf /var/lib/apt/lists/*
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800189}
Zack Williams85249ce2018-04-01 19:54:44 -0700190
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800191all_systems() {
192 echo 'No common distribution configuration to perform'
193}
194
195echo "---> Detecting OS"
196ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
197
198case "${ORIGIN}" in
199 fedora|centos|redhat)
200 echo "---> RH type system detected"
201 rh_systems
202 ;;
203 ubuntu)
204 echo "---> Ubuntu system detected"
205 ubuntu_systems
206 ;;
207 *)
208 echo "---> Unknown operating system"
209 ;;
210esac
211
212# execute steps for all systems
213all_systems