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 |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 36 | |
| 37 | # set up ansible repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 38 | apt-add-repository -y ppa:ansible/ansible |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 39 | |
| 40 | # set up docker repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 41 | apt-key adv --keyserver keyserver.ubuntu.com --recv 0EBFCD88 |
| 42 | add-apt-repository \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 43 | "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ |
| 44 | $(lsb_release -cs) \ |
| 45 | stable" |
| 46 | |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 47 | apt-get update |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 48 | |
| 49 | # install basic sofware requirements |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 50 | apt-get install -y \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 51 | "docker-ce=17.06*" \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 52 | ansible \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 53 | build-essential \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 54 | bzip2 \ |
| 55 | curl \ |
| 56 | git \ |
| 57 | less \ |
Zack Williams | cfe0b94 | 2018-04-12 11:47:57 -0700 | [diff] [blame] | 58 | libxml2-utils \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 59 | nodejs \ |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 60 | npm \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 61 | python \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 62 | python-certifi \ |
| 63 | python-cryptography \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 64 | python-dev \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 65 | python-idna \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 66 | python-netaddr \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 67 | python-openssl \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 68 | python-pip \ |
Zack Williams | 9754a83 | 2018-04-13 11:01:59 -0700 | [diff] [blame] | 69 | python-urllib3 \ |
Zack Williams | 40c06f0 | 2018-04-15 20:31:34 -0700 | [diff] [blame] | 70 | ruby \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 71 | ssh \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 72 | sshpass \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 73 | zip |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 74 | # end of apt-get install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 75 | |
| 76 | # install python modules |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 77 | pip install \ |
| 78 | Jinja2 \ |
| 79 | ansible-lint \ |
| 80 | astroid \ |
| 81 | docker-compose==1.20.1 \ |
| 82 | docker==3.2.1 \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 83 | gitpython \ |
Luca Prete | 90bfa5e | 2018-03-06 20:41:56 -0800 | [diff] [blame] | 84 | graphviz \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 85 | isort \ |
Zack Williams | 6828f82 | 2018-04-12 16:13:33 -0700 | [diff] [blame] | 86 | linkchecker \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 87 | pexpect \ |
| 88 | pylint \ |
| 89 | pyyaml \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 90 | robotframework \ |
Kailash Khalasi | cb327c6 | 2018-04-03 10:41:38 -0700 | [diff] [blame] | 91 | robotframework-httplibrary \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 92 | robotframework-requests \ |
Zack Williams | fd8a004 | 2018-04-12 14:34:17 -0700 | [diff] [blame] | 93 | robotframework-sshlibrary \ |
| 94 | virtualenv |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 95 | # end of pip install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 96 | |
Zack Williams | 40c06f0 | 2018-04-15 20:31:34 -0700 | [diff] [blame] | 97 | # install ruby gems |
| 98 | gem install \ |
| 99 | mdl |
| 100 | # end of gem install list |
| 101 | |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 102 | # install npm modules |
| 103 | npm install -g \ |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 104 | gitbook-cli \ |
| 105 | markdownlint \ |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 106 | typings |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 107 | # end of npm install list |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 108 | |
Zack Williams | 6828f82 | 2018-04-12 16:13:33 -0700 | [diff] [blame] | 109 | # ubuntu 16.04 installs the node binary as /usr/bin/nodejs, which breaks |
| 110 | # tools that expect it to be named just `node`. Symlink it to fix |
| 111 | ln -s /usr/bin/nodejs /usr/local/bin/node |
| 112 | |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 113 | # install repo |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 114 | REPO_SHA256SUM="394d93ac7261d59db58afa49bb5f88386fea8518792491ee3db8baab49c3ecda" |
Luca Prete | 31860c5 | 2018-03-06 17:54:38 -0800 | [diff] [blame] | 115 | 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] | 116 | echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c - |
| 117 | mv /tmp/repo /usr/local/bin/repo |
| 118 | chmod a+x /usr/local/bin/repo |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 119 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 120 | # install sonarqube scanner |
| 121 | SONAR_SCANNER_CLI_VERSION="3.1.0.1141" |
| 122 | SONAR_SCANNER_CLI_SHA256SUM="efbe7d1a274bbed220846eccc5b36db853a6bab3ee576aebf93ddc604a89ced4" |
| 123 | curl -L -o /tmp/sonarscanner.zip https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${SONAR_SCANNER_CLI_VERSION}-linux.zip |
| 124 | echo "$SONAR_SCANNER_CLI_SHA256SUM /tmp/sonarscanner.zip" | sha256sum -c - |
| 125 | pushd /opt |
| 126 | unzip /tmp/sonarscanner.zip |
| 127 | mv sonar-scanner-${SONAR_SCANNER_CLI_VERSION}-linux sonar-scanner |
| 128 | popd |
| 129 | |
Zack Williams | 8aa5282 | 2018-04-05 09:22:15 -0700 | [diff] [blame] | 130 | # install helm (for lint) |
| 131 | HELM_VERSION="2.8.2" |
| 132 | HELM_SHA256SUM="614b5ac79de4336b37c9b26d528c6f2b94ee6ccacb94b0f4b8d9583a8dd122d3" |
| 133 | HELM_PLATFORM="linux-amd64" |
| 134 | curl -L -o /tmp/helm.tgz https://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-${HELM_PLATFORM}.tar.gz |
| 135 | echo "$HELM_SHA256SUM /tmp/helm.tgz" | sha256sum -c - |
| 136 | pushd /tmp |
| 137 | tar -xzvf helm.tgz |
| 138 | mv ${HELM_PLATFORM}/helm /usr/local/bin/helm |
| 139 | chmod a+x /usr/local/bin/helm |
| 140 | popd |
| 141 | |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 142 | # clean up |
| 143 | apt-get clean |
| 144 | apt-get purge -y |
| 145 | apt-get autoremove -y |
| 146 | rm -rf /var/lib/apt/lists/* |
| 147 | rm -rf /var/cache/oracle-jdk8-installer |
| 148 | rm -rf /tmp/sonarscanner.zip |
Zack Williams | 8aa5282 | 2018-04-05 09:22:15 -0700 | [diff] [blame] | 149 | rm -rf /tmp/helm.tgz |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 150 | } |
Zack Williams | 85249ce | 2018-04-01 19:54:44 -0700 | [diff] [blame] | 151 | |
Linux Foundation Administrators | 1dc9dd5 | 2018-01-26 09:09:09 -0800 | [diff] [blame] | 152 | all_systems() { |
| 153 | echo 'No common distribution configuration to perform' |
| 154 | } |
| 155 | |
| 156 | echo "---> Detecting OS" |
| 157 | ORIGIN=$(facter operatingsystem | tr '[:upper:]' '[:lower:]') |
| 158 | |
| 159 | case "${ORIGIN}" in |
| 160 | fedora|centos|redhat) |
| 161 | echo "---> RH type system detected" |
| 162 | rh_systems |
| 163 | ;; |
| 164 | ubuntu) |
| 165 | echo "---> Ubuntu system detected" |
| 166 | ubuntu_systems |
| 167 | ;; |
| 168 | *) |
| 169 | echo "---> Unknown operating system" |
| 170 | ;; |
| 171 | esac |
| 172 | |
| 173 | # execute steps for all systems |
| 174 | all_systems |