blob: 2015ef35467596ce413c5ace48d3f2f7f6c7adb5 [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 Williamscfe0b942018-04-12 11:47:57 -070059 libxml2-utils \
Kailash Khalasi1ddc7c62018-04-20 08:47:56 -070060 maven \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080061 nodejs \
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080062 npm \
Zack Williams85249ce2018-04-01 19:54:44 -070063 python \
Zack Williams9754a832018-04-13 11:01:59 -070064 python-certifi \
65 python-cryptography \
Luca Prete31860c52018-03-06 17:54:38 -080066 python-dev \
Zack Williams9754a832018-04-13 11:01:59 -070067 python-idna \
Luca Prete31860c52018-03-06 17:54:38 -080068 python-netaddr \
Zack Williams9754a832018-04-13 11:01:59 -070069 python-openssl \
Luca Prete31860c52018-03-06 17:54:38 -080070 python-pip \
Zack Williams9754a832018-04-13 11:01:59 -070071 python-urllib3 \
Zack Williams40c06f02018-04-15 20:31:34 -070072 ruby \
Zack Williams85249ce2018-04-01 19:54:44 -070073 ssh \
Luca Prete31860c52018-03-06 17:54:38 -080074 sshpass \
Zack Williams85249ce2018-04-01 19:54:44 -070075 zip
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -080076 # end of apt-get install list
Luca Prete31860c52018-03-06 17:54:38 -080077
78 # install python modules
Zack Williams85249ce2018-04-01 19:54:44 -070079 pip install \
80 Jinja2 \
81 ansible-lint \
82 astroid \
83 docker-compose==1.20.1 \
84 docker==3.2.1 \
Luca Prete31860c52018-03-06 17:54:38 -080085 gitpython \
Luca Prete90bfa5e2018-03-06 20:41:56 -080086 graphviz \
Zack Williams85249ce2018-04-01 19:54:44 -070087 isort \
Zack Williams6828f822018-04-12 16:13:33 -070088 linkchecker \
Zack Williams85249ce2018-04-01 19:54:44 -070089 pexpect \
90 pylint \
91 pyyaml \
Luca Prete31860c52018-03-06 17:54:38 -080092 robotframework \
Kailash Khalasicb327c62018-04-03 10:41:38 -070093 robotframework-httplibrary \
Zack Williams85249ce2018-04-01 19:54:44 -070094 robotframework-requests \
Zack Williamsfd8a0042018-04-12 14:34:17 -070095 robotframework-sshlibrary \
96 virtualenv
Zack Williams85249ce2018-04-01 19:54:44 -070097 # end of pip install list
Luca Prete31860c52018-03-06 17:54:38 -080098
Zack Williams40c06f02018-04-15 20:31:34 -070099 # install ruby gems
100 gem install \
101 mdl
102 # end of gem install list
103
Luca Prete31860c52018-03-06 17:54:38 -0800104 # install npm modules
105 npm install -g \
Zack Williams85249ce2018-04-01 19:54:44 -0700106 gitbook-cli \
107 markdownlint \
Luca Prete31860c52018-03-06 17:54:38 -0800108 typings
Zack Williams85249ce2018-04-01 19:54:44 -0700109 # end of npm install list
Luca Prete31860c52018-03-06 17:54:38 -0800110
Zack Williams6828f822018-04-12 16:13:33 -0700111 # ubuntu 16.04 installs the node binary as /usr/bin/nodejs, which breaks
112 # tools that expect it to be named just `node`. Symlink it to fix
113 ln -s /usr/bin/nodejs /usr/local/bin/node
114
Luca Prete31860c52018-03-06 17:54:38 -0800115 # install repo
Zack Williams85249ce2018-04-01 19:54:44 -0700116 REPO_SHA256SUM="394d93ac7261d59db58afa49bb5f88386fea8518792491ee3db8baab49c3ecda"
Luca Prete31860c52018-03-06 17:54:38 -0800117 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 -0700118 echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c -
119 mv /tmp/repo /usr/local/bin/repo
120 chmod a+x /usr/local/bin/repo
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800121
Zack Williams85249ce2018-04-01 19:54:44 -0700122 # install sonarqube scanner
123 SONAR_SCANNER_CLI_VERSION="3.1.0.1141"
124 SONAR_SCANNER_CLI_SHA256SUM="efbe7d1a274bbed220846eccc5b36db853a6bab3ee576aebf93ddc604a89ced4"
Zack Williams4cfdf202018-05-07 09:58:12 -0700125 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 -0700126 echo "$SONAR_SCANNER_CLI_SHA256SUM /tmp/sonarscanner.zip" | sha256sum -c -
127 pushd /opt
128 unzip /tmp/sonarscanner.zip
129 mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux sonar-scanner
Zack Williams4cfdf202018-05-07 09:58:12 -0700130 rm -f /tmp/sonarscanner.zip
Zack Williams85249ce2018-04-01 19:54:44 -0700131 popd
132
Zack Williams4cfdf202018-05-07 09:58:12 -0700133 # install helm
Zack Williams8aa52822018-04-05 09:22:15 -0700134 HELM_VERSION="2.8.2"
135 HELM_SHA256SUM="614b5ac79de4336b37c9b26d528c6f2b94ee6ccacb94b0f4b8d9583a8dd122d3"
136 HELM_PLATFORM="linux-amd64"
Zack Williams4cfdf202018-05-07 09:58:12 -0700137 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 -0700138 echo "$HELM_SHA256SUM /tmp/helm.tgz" | sha256sum -c -
139 pushd /tmp
140 tar -xzvf helm.tgz
141 mv ${HELM_PLATFORM}/helm /usr/local/bin/helm
142 chmod a+x /usr/local/bin/helm
Zack Williams4cfdf202018-05-07 09:58:12 -0700143 rm -rf helm.tgz ${HELM_PLATFORM}
144 popd
145
146 # install minikube
147 MINIKUBE_VERSION="0.26.1"
148 MINIKUBE_DEB_VERSION="$(echo ${MINIKUBE_VERSION} | sed -n 's/\(.*\)\.\(.*\)/\1-\2/p')"
149 MINIKUBE_SHA256SUM="4a97ff448347eb374e1c48b4578cc3cf61af51cca4ff002101a57e77ffaa1575"
150 curl -L -o /tmp/minikube.deb "https://storage.googleapis.com/minikube/releases/v${MINIKUBE_VERSION}/minikube_${MINIKUBE_DEB_VERSION}.deb"
151 echo "$MINIKUBE_SHA256SUM /tmp/minikube.deb" | sha256sum -c -
152 pushd /tmp
153 dpkg -i minikube.deb
154 rm -f minikube.deb
Zack Williams8aa52822018-04-05 09:22:15 -0700155 popd
156
Zack Williams85249ce2018-04-01 19:54:44 -0700157 # clean up
158 apt-get clean
159 apt-get purge -y
160 apt-get autoremove -y
161 rm -rf /var/lib/apt/lists/*
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800162}
Zack Williams85249ce2018-04-01 19:54:44 -0700163
Linux Foundation Administrators1dc9dd52018-01-26 09:09:09 -0800164all_systems() {
165 echo 'No common distribution configuration to perform'
166}
167
168echo "---> Detecting OS"
169ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]')
170
171case "${ORIGIN}" in
172 fedora|centos|redhat)
173 echo "---> RH type system detected"
174 rh_systems
175 ;;
176 ubuntu)
177 echo "---> Ubuntu system detected"
178 ubuntu_systems
179 ;;
180 *)
181 echo "---> Unknown operating system"
182 ;;
183esac
184
185# execute steps for all systems
186all_systems