Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 1 | #!/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 |
| 7 | set -xeu -o pipefail |
| 8 | |
| 9 | rh_systems() { |
| 10 | echo 'No changes to apply' |
| 11 | } |
| 12 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 13 | ubuntu_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 Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 24 | |
| 25 | ubuntu_systems() { |
| 26 | apt-get clean |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 27 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 28 | # 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 Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 36 | # rm -rf /var/cache/oracle-jdk8-installer |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 37 | |
| 38 | # set up ansible repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 39 | apt-add-repository -y ppa:ansible/ansible |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 40 | |
| 41 | # set up docker repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 42 | apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88 |
| 43 | add-apt-repository \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 44 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ |
| 45 | $(lsb_release -cs) \ |
| 46 | stable" |
| 47 | |
Zack Williams | 6ecb83c | 2018-08-29 13:22:21 -0700 | [diff] [blame] | 48 | # set up golang repo |
| 49 | add-apt-repository ppa:gophers/archive |
| 50 | |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 51 | apt-get update |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 52 | |
| 53 | # install basic sofware requirements |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 54 | apt-get install -y \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 55 | "docker-ce=17.06*" \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 56 | ansible \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 57 | build-essential \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 58 | bzip2 \ |
| 59 | curl \ |
| 60 | git \ |
Zack Williams | 6ecb83c | 2018-08-29 13:22:21 -0700 | [diff] [blame] | 61 | golang-1.10-go \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 62 | less \ |
Zack Williams | 9d661a4 | 2018-10-01 15:43:21 -0700 | [diff] [blame] | 63 | libmysqlclient-dev \ |
Zack Williams | 68f4310 | 2018-07-07 12:57:13 -0700 | [diff] [blame] | 64 | libpcap-dev \ |
Zack Williams | cfe0b94 | 2018-04-12 11:47:57 -0700 | [diff] [blame] | 65 | libxml2-utils \ |
Kailash Khalasi | 1ddc7c6 | 2018-04-20 08:47:56 -0700 | [diff] [blame] | 66 | maven \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 67 | nodejs \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 68 | npm \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 69 | python \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 70 | python-certifi \ |
| 71 | python-cryptography \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 72 | python-dev \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 73 | python-idna \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 74 | python-netaddr \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 75 | python-openssl \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 76 | python-pip \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 77 | python-urllib3 \ |
Zack Williams | 40c06f0 | 2018-04-15 20:31:34 -0700 | [diff] [blame] | 78 | ruby \ |
Zack Williams | eb842ae | 2018-05-15 17:07:32 -0700 | [diff] [blame] | 79 | socat \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 80 | ssh \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 81 | sshpass \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 82 | zip |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 83 | # end of apt-get install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 84 | |
| 85 | # install python modules |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 86 | pip install \ |
| 87 | Jinja2 \ |
| 88 | ansible-lint \ |
Zack Williams | ac92296 | 2018-07-24 13:02:26 -0700 | [diff] [blame] | 89 | astroid==1.* \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 90 | docker-compose==1.20.1 \ |
| 91 | docker==3.2.1 \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 92 | gitpython \ |
Luca Prete | 90bfa5e | 2018-03-06 20:41:56 -0800 | [diff] [blame] | 93 | graphviz \ |
Kailash Khalasi | e15b27a | 2018-06-26 13:28:20 -0700 | [diff] [blame] | 94 | grpcio-tools \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 95 | isort \ |
Zack Williams | 6828f82 | 2018-04-12 16:13:33 -0700 | [diff] [blame] | 96 | linkchecker \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 97 | pexpect \ |
Zack Williams | e9af4c4 | 2018-07-24 14:29:02 -0700 | [diff] [blame] | 98 | pylint==1.* \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 99 | pyyaml \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 100 | robotframework \ |
Kailash Khalasi | cb327c6 | 2018-04-03 10:41:38 -0700 | [diff] [blame] | 101 | robotframework-httplibrary \ |
Kailash Khalasi | a191768 | 2018-08-20 10:34:39 -0700 | [diff] [blame] | 102 | robotframework-kafkalibrary \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 103 | robotframework-requests \ |
Zack Williams | fd8a004 | 2018-04-12 14:34:17 -0700 | [diff] [blame] | 104 | robotframework-sshlibrary \ |
| 105 | virtualenv |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 106 | # end of pip install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 107 | |
Zack Williams | 40c06f0 | 2018-04-15 20:31:34 -0700 | [diff] [blame] | 108 | # install ruby gems |
| 109 | gem install \ |
| 110 | mdl |
| 111 | # end of gem install list |
| 112 | |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 113 | # install npm modules |
| 114 | npm install -g \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 115 | gitbook-cli \ |
| 116 | markdownlint \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 117 | typings |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 118 | # end of npm install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 119 | |
Zack Williams | 6ecb83c | 2018-08-29 13:22:21 -0700 | [diff] [blame] | 120 | # install golang packages in /usr/local/go |
| 121 | # Set PATH=$PATH:/usr/local/go/bin` to use these |
| 122 | export GOPATH=/usr/local/go |
| 123 | mkdir -p $GOPATH |
| 124 | export PATH=$PATH:/usr/lib/go-1.10/bin:$GOPATH/bin |
| 125 | # converters for unit/coverage test |
| 126 | go get -v github.com/t-yuki/gocover-cobertura |
| 127 | go get -v github.com/jstemmer/go-junit-report |
| 128 | |
Zack Williams | 6828f82 | 2018-04-12 16:13:33 -0700 | [diff] [blame] | 129 | # ubuntu 16.04 installs the node binary as /usr/bin/nodejs, which breaks |
| 130 | # tools that expect it to be named just `node`. Symlink it to fix |
| 131 | ln -s /usr/bin/nodejs /usr/local/bin/node |
| 132 | |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 133 | # install repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 134 | REPO_SHA256SUM="394d93ac7261d59db58afa49bb5f88386fea8518792491ee3db8baab49c3ecda" |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 135 | curl -o /tmp/repo 'https://gerrit.opencord.org/gitweb?p=repo.git;a=blob_plain;f=repo;hb=refs/heads/stable' |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 136 | echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c - |
| 137 | mv /tmp/repo /usr/local/bin/repo |
| 138 | chmod a+x /usr/local/bin/repo |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 139 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 140 | # install sonarqube scanner |
Zack Williams | 891922a | 2018-07-07 10:33:24 -0700 | [diff] [blame] | 141 | # dl link: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner |
| 142 | SONAR_SCANNER_CLI_VERSION="3.2.0.1227" |
| 143 | SONAR_SCANNER_CLI_SHA256SUM="07a50ec270a36cb83f26fe93233819c53c145248c638f4591880f1bd36e331d6" |
Zack Williams | 02e301e | 2018-10-08 12:09:58 -0700 | [diff] [blame] | 144 | curl -L -o /tmp/sonarscanner.zip "https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux.zip" |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 145 | echo "$SONAR_SCANNER_CLI_SHA256SUM /tmp/sonarscanner.zip" | sha256sum -c - |
| 146 | pushd /opt |
| 147 | unzip /tmp/sonarscanner.zip |
| 148 | mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux sonar-scanner |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 149 | rm -f /tmp/sonarscanner.zip |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 150 | popd |
| 151 | |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 152 | # install helm |
Zack Williams | 469fb0d | 2018-09-10 15:16:51 -0700 | [diff] [blame] | 153 | HELM_VERSION="2.10.0" |
| 154 | HELM_SHA256SUM="0fa2ed4983b1e4a3f90f776d08b88b0c73fd83f305b5b634175cb15e61342ffe" |
Zack Williams | 8aa5282 | 2018-04-05 09:22:15 -0700 | [diff] [blame] | 155 | HELM_PLATFORM="linux-amd64" |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 156 | curl -L -o /tmp/helm.tgz "https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz" |
Zack Williams | 8aa5282 | 2018-04-05 09:22:15 -0700 | [diff] [blame] | 157 | echo "$HELM_SHA256SUM /tmp/helm.tgz" | sha256sum -c - |
| 158 | pushd /tmp |
| 159 | tar -xzvf helm.tgz |
| 160 | mv ${HELM_PLATFORM}/helm /usr/local/bin/helm |
| 161 | chmod a+x /usr/local/bin/helm |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 162 | rm -rf helm.tgz ${HELM_PLATFORM} |
| 163 | popd |
| 164 | |
Zack Williams | 4c5bfab | 2018-05-08 16:13:50 -0700 | [diff] [blame] | 165 | # install kubectl |
Zack Williams | 469fb0d | 2018-09-10 15:16:51 -0700 | [diff] [blame] | 166 | KUBECTL_VERSION="1.11.3" |
| 167 | KUBECTL_SHA256SUM="0d4c70484e90d4310f03f997b4432e0a97a7f5b5be5c31d281f3d05919f8b46c" |
Zack Williams | 4c5bfab | 2018-05-08 16:13:50 -0700 | [diff] [blame] | 168 | curl -L -o /tmp/kubectl "https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl" |
| 169 | echo "$KUBECTL_SHA256SUM /tmp/kubectl" | sha256sum -c - |
| 170 | mv /tmp/kubectl /usr/local/bin/kubectl |
| 171 | chmod a+x /usr/local/bin/kubectl |
| 172 | rm -f /tmp/kubectl |
| 173 | |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 174 | # install minikube |
Zack Williams | 469fb0d | 2018-09-10 15:16:51 -0700 | [diff] [blame] | 175 | MINIKUBE_VERSION="0.28.2" |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 176 | MINIKUBE_DEB_VERSION="$(echo ${MINIKUBE_VERSION} | sed -n 's/\(.*\)\.\(.*\)/\1-\2/p')" |
Zack Williams | 469fb0d | 2018-09-10 15:16:51 -0700 | [diff] [blame] | 177 | MINIKUBE_SHA256SUM="47cd2db6a65b092a3e1ac47ddd4331914290f04069260ee273530ab7e29123d2" |
Zack Williams | 4cfdf20 | 2018-05-07 09:58:12 -0700 | [diff] [blame] | 178 | curl -L -o /tmp/minikube.deb "https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube_${MINIKUBE_DEB_VERSION}.deb" |
| 179 | echo "$MINIKUBE_SHA256SUM /tmp/minikube.deb" | sha256sum -c - |
| 180 | pushd /tmp |
| 181 | dpkg -i minikube.deb |
| 182 | rm -f minikube.deb |
Zack Williams | 8aa5282 | 2018-04-05 09:22:15 -0700 | [diff] [blame] | 183 | popd |
| 184 | |
Kailash Khalasi | 929d21b | 2018-06-28 12:28:17 -0700 | [diff] [blame] | 185 | # install protobufs |
Zack Williams | cab43ba | 2018-09-19 09:58:25 -0700 | [diff] [blame] | 186 | PROTOC_VERSION="3.6.1" |
| 187 | PROTOC_SHA256SUM="6003de742ea3fcf703cfec1cd4a3380fd143081a2eb0e559065563496af27807" |
Kailash Khalasi | 929d21b | 2018-06-28 12:28:17 -0700 | [diff] [blame] | 188 | 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 |
| 189 | echo "$PROTOC_SHA256SUM /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip" | sha256sum -c - |
Kailash Khalasi | c4ff32d | 2018-06-28 18:24:52 -0700 | [diff] [blame] | 190 | unzip /tmp/protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /tmp/protoc3 |
Kailash Khalasi | 929d21b | 2018-06-28 12:28:17 -0700 | [diff] [blame] | 191 | mv /tmp/protoc3/bin/* /usr/local/bin/ |
| 192 | mv /tmp/protoc3/include/* /usr/local/include/ |
Zack Williams | 3fc47ab | 2018-10-08 11:22:29 -0700 | [diff] [blame] | 193 | # fix permissions on include files |
| 194 | chmod -R a+r /usr/local/include/ |
Zack Williams | cab43ba | 2018-09-19 09:58:25 -0700 | [diff] [blame] | 195 | |
Kailash Khalasi | 929d21b | 2018-06-28 12:28:17 -0700 | [diff] [blame] | 196 | # give sudo permissions on minikube and protoc to jenkins user |
| 197 | cat <<EOF >/etc/sudoers.d/88-jenkins-minikube-protoc |
| 198 | Cmnd_Alias CMDS = /usr/local/bin/protoc, /usr/bin/minikube |
Zack Williams | 8173977 | 2018-05-14 16:35:47 -0700 | [diff] [blame] | 199 | Defaults:jenkins !requiretty |
Kailash Khalasi | 929d21b | 2018-06-28 12:28:17 -0700 | [diff] [blame] | 200 | jenkins ALL=(ALL) NOPASSWD:SETENV: CMDS |
Zack Williams | 8173977 | 2018-05-14 16:35:47 -0700 | [diff] [blame] | 201 | EOF |
| 202 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 203 | # clean up |
| 204 | apt-get clean |
| 205 | apt-get purge -y |
| 206 | apt-get autoremove -y |
| 207 | rm -rf /var/lib/apt/lists/* |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 208 | } |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 209 | |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 210 | all_systems() { |
| 211 | echo 'No common distribution configuration to perform' |
| 212 | } |
| 213 | |
| 214 | echo "---> Detecting OS" |
| 215 | ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') |
| 216 | |
| 217 | case "${ORIGIN}" in |
| 218 | fedora|centos|redhat) |
| 219 | echo "---> RH type system detected" |
| 220 | rh_systems |
| 221 | ;; |
| 222 | ubuntu) |
| 223 | echo "---> Ubuntu system detected" |
| 224 | ubuntu_systems |
| 225 | ;; |
| 226 | *) |
| 227 | echo "---> Unknown operating system" |
| 228 | ;; |
| 229 | esac |
| 230 | |
| 231 | # execute steps for all systems |
| 232 | all_systems |