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