| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2016 Telefónica Investigación y Desarrollo S.A.U. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | function usage(){ |
| 17 | echo -e "usage: $0 [OPTIONS]" |
| 18 | echo -e "Install OSM from source code" |
| 19 | echo -e " OPTIONS" |
| 20 | echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules" |
| garciadeblas | a6ff986 | 2017-04-07 02:00:29 +0200 | [diff] [blame] | 21 | echo -e " -b <branch>: install OSM from source code using a specific branch (master, v1.0, ...) or tag" |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 22 | echo -e " -b master" |
| 23 | echo -e " -b v1.0" |
| garciadeblas | a6ff986 | 2017-04-07 02:00:29 +0200 | [diff] [blame] | 24 | echo -e " -b tags/v1.1.0" |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 25 | echo -e " ..." |
| garciadeblas | 2a5a651 | 2016-12-19 10:19:52 +0100 | [diff] [blame] | 26 | echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch" |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 27 | echo -e " --nat: install only NAT rules" |
| garciadeblas | fc43c9d | 2017-03-01 13:25:11 +0100 | [diff] [blame] | 28 | # echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch" |
| 29 | echo -e " --showopts: print chosen options and exit (only for debugging)" |
| tierno | 2cc8e25 | 2017-03-08 17:12:05 +0100 | [diff] [blame] | 30 | echo -e " -y: do not prompt for confirmation, assumes yes" |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 31 | echo -e " -h / --help: print this help" |
| 32 | } |
| 33 | |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 34 | #Uninstall OSM: remove containers |
| 35 | function uninstall(){ |
| 36 | if [ $RC_CLONE ] || [ -n "$TEST_INSTALLER" ]; then |
| 37 | $OSM_DEVOPS/jenkins/host/clean_container RO |
| 38 | $OSM_DEVOPS/jenkins/host/clean_container VCA |
| 39 | $OSM_DEVOPS/jenkins/host/clean_container SO |
| 40 | #$OSM_DEVOPS/jenkins/host/clean_container UI |
| 41 | else |
| 42 | lxc stop RO && lxc delete RO |
| 43 | lxc stop VCA && lxc delete VCA |
| 44 | lxc stop SO-ub && lxc delete SO-ub |
| 45 | fi |
| 46 | } |
| 47 | |
| 48 | #Configure NAT rules, based on the current IP addresses of containers |
| 49 | function nat(){ |
| 50 | echo -e "\nChecking required packages: iptables-persistent" |
| 51 | dpkg -l iptables-persistent &>/dev/null || ! echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" || \ |
| 52 | sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install iptables-persistent |
| 53 | echo -e "\nConfiguring NAT rules" |
| 54 | echo -e " Required root privileges" |
| 55 | sudo $OSM_DEVOPS/installers/nat_osm |
| 56 | } |
| 57 | |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 58 | #Update RO, SO and UI: |
| 59 | function update(){ |
| 60 | echo -e "\nUpdating components" |
| 61 | |
| 62 | echo -e " Updating RO" |
| 63 | CONTAINER="RO" |
| 64 | MDG="RO" |
| 65 | INSTALL_FOLDER="/opt/openmano" |
| 66 | echo -e " Fetching the repo" |
| 67 | lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all |
| 68 | BRANCH="" |
| 69 | BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'` |
| Jokin Garay | c17db01 | 2017-03-08 17:45:39 +0100 | [diff] [blame] | 70 | [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'" |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 71 | CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1` |
| 72 | CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD` |
| 73 | echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)" |
| 74 | # COMMIT_ID either was previously set with -b option, or is an empty string |
| 75 | CHECKOUT_ID=$COMMIT_ID |
| 76 | [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS" |
| 77 | [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH" |
| 78 | if [[ $CHECKOUT_ID == "tags/"* ]]; then |
| 79 | REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID` |
| 80 | else |
| 81 | REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID` |
| 82 | fi |
| 83 | echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)" |
| 84 | if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then |
| 85 | echo " Nothing to be done." |
| 86 | else |
| 87 | echo " Update required." |
| 88 | lxc exec $CONTAINER -- service openmano stop |
| 89 | lxc exec $CONTAINER -- git -C /opt/openmano stash |
| 90 | lxc exec $CONTAINER -- git -C /opt/openmano pull --rebase |
| 91 | lxc exec $CONTAINER -- git -C /opt/openmano checkout $CHECKOUT_ID |
| 92 | lxc exec $CONTAINER -- git -C /opt/openmano stash pop |
| 93 | lxc exec $CONTAINER -- /opt/openmano/database_utils/migrate_mano_db.sh |
| 94 | lxc exec $CONTAINER -- service openmano start |
| 95 | fi |
| 96 | echo |
| 97 | |
| 98 | echo -e " Updating SO and UI" |
| 99 | CONTAINER="SO-ub" |
| 100 | MDG="SO" |
| 101 | INSTALL_FOLDER="" # To be filled in |
| 102 | echo -e " Fetching the repo" |
| 103 | lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all |
| 104 | BRANCH="" |
| 105 | BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'` |
| Jokin Garay | c17db01 | 2017-03-08 17:45:39 +0100 | [diff] [blame] | 106 | [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'" |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 107 | CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1` |
| 108 | CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD` |
| 109 | echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)" |
| 110 | # COMMIT_ID either was previously set with -b option, or is an empty string |
| 111 | CHECKOUT_ID=$COMMIT_ID |
| 112 | [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS" |
| 113 | [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH" |
| 114 | if [[ $CHECKOUT_ID == "tags/"* ]]; then |
| 115 | REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID` |
| 116 | else |
| 117 | REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID` |
| 118 | fi |
| 119 | echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)" |
| 120 | if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then |
| 121 | echo " Nothing to be done." |
| 122 | else |
| 123 | echo " Update required." |
| 124 | # Instructions to be added |
| 125 | # lxc exec SO-ub -- ... |
| 126 | fi |
| 127 | echo |
| 128 | } |
| 129 | |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 130 | #Configure VCA, SO and RO with the initial configuration: |
| 131 | # RO -> tenant:osm, logs to be sent to SO |
| 132 | # VCA -> juju-password |
| 133 | # SO -> route to Juju Controller, add RO account, add VCA account |
| 134 | function configure(){ |
| 135 | #Configure components |
| 136 | echo -e "\nConfiguring components" |
| 137 | . $OSM_DEVOPS/installers/export_ips |
| 138 | |
| 139 | echo -e " Configuring RO" |
| 140 | lxc exec RO -- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /opt/openmano/openmanod.cfg |
| 141 | lxc exec RO -- service openmano restart |
| garciadeblas | d8718f1 | 2016-10-30 19:39:01 +0100 | [diff] [blame] | 142 | time=0; step=2; timelength=20; while [ $time -le $timelength ]; do sleep $step; echo -n "."; time=$((time+step)); done; echo |
| 143 | lxc exec RO -- openmano tenant-delete -f osm >/dev/null |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 144 | RO_TENANT_ID=`lxc exec RO -- openmano tenant-create osm |awk '{print $1}'` |
| 145 | |
| 146 | echo -e " Configuring VCA" |
| 147 | JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32` |
| 148 | echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc exec VCA -- juju change-user-password |
| 149 | JUJU_CONTROLLER_IP=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'` |
| 150 | |
| 151 | echo -e " Configuring SO" |
| 152 | sudo route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP |
| garciadeblas | 2f4c93b | 2017-04-10 18:12:12 +0200 | [diff] [blame^] | 153 | sudo sed -i "$ i route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP" /etc/rc.local |
| garciadeblas | d05ae75 | 2016-12-07 12:13:00 +0100 | [diff] [blame] | 154 | lxc exec SO-ub -- nohup sudo -b -H /usr/rift/rift-shell -r -i /usr/rift -a /usr/rift/.artifacts -- ./demos/launchpad.py --use-xml-mode & |
| garciadeblas | d8718f1 | 2016-10-30 19:39:01 +0100 | [diff] [blame] | 155 | time=0; step=30; timelength=300; while [ $time -le $timelength ]; do sleep $step; echo -n "."; time=$((time+step)); done; echo |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 156 | |
| 157 | curl -k --request POST \ |
| 158 | --url https://$SO_CONTAINER_IP:8008/api/config/config-agent \ |
| 159 | --header 'accept: application/vnd.yang.data+json' \ |
| 160 | --header 'authorization: Basic YWRtaW46YWRtaW4=' \ |
| 161 | --header 'cache-control: no-cache' \ |
| 162 | --header 'content-type: application/vnd.yang.data+json' \ |
| 163 | --data '{"account": [ { "name": "osmjuju", "account-type": "juju", "juju": { "ip-address": "'$JUJU_CONTROLLER_IP'", "port": "17070", "user": "admin", "secret": "'$JUJU_PASSWD'" } } ]}' |
| 164 | |
| 165 | curl -k --request PUT \ |
| 166 | --url https://$SO_CONTAINER_IP:8008/api/config/resource-orchestrator \ |
| 167 | --header 'accept: application/vnd.yang.data+json' \ |
| 168 | --header 'authorization: Basic YWRtaW46YWRtaW4=' \ |
| 169 | --header 'cache-control: no-cache' \ |
| 170 | --header 'content-type: application/vnd.yang.data+json' \ |
| 171 | --data '{ "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'" }, "name": "osmopenmano", "account-type": "openmano" }' |
| 172 | |
| 173 | } |
| 174 | |
| garciadeblas | 2a5a651 | 2016-12-19 10:19:52 +0100 | [diff] [blame] | 175 | function install_lxd() { |
| 176 | lxd init --auto |
| 177 | lxd waitready |
| 178 | systemctl stop lxd-bridge |
| 179 | systemctl --system daemon-reload |
| 180 | systemctl enable lxd-bridge |
| 181 | systemctl start lxd-bridge |
| 182 | } |
| 183 | |
| 184 | |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 185 | UNINSTALL="" |
| 186 | DEVELOP="" |
| 187 | NAT="" |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 188 | UPDATE="" |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 189 | RECONFIGURE="" |
| 190 | TEST_INSTALLER="" |
| garciadeblas | 2a5a651 | 2016-12-19 10:19:52 +0100 | [diff] [blame] | 191 | LXD="" |
| 192 | SHOWOPTS="" |
| 193 | COMMIT_ID="" |
| tierno | 2cc8e25 | 2017-03-08 17:12:05 +0100 | [diff] [blame] | 194 | ASSUME_YES="" |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 195 | |
| tierno | 2cc8e25 | 2017-03-08 17:12:05 +0100 | [diff] [blame] | 196 | while getopts ":hy-:b:" o; do |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 197 | case "${o}" in |
| 198 | h) |
| 199 | usage && exit 0 |
| 200 | ;; |
| garciadeblas | 2a5a651 | 2016-12-19 10:19:52 +0100 | [diff] [blame] | 201 | b) |
| 202 | COMMIT_ID=${OPTARG} |
| 203 | ;; |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 204 | -) |
| 205 | [ "${OPTARG}" == "help" ] && usage && exit 0 |
| 206 | [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue |
| 207 | [ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue |
| 208 | [ "${OPTARG}" == "nat" ] && NAT="y" && continue |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 209 | [ "${OPTARG}" == "update" ] && UPDATE="y" && continue |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 210 | [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue |
| 211 | [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue |
| garciadeblas | 2a5a651 | 2016-12-19 10:19:52 +0100 | [diff] [blame] | 212 | [ "${OPTARG}" == "lxd" ] && LXD="y" && continue |
| 213 | [ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 214 | echo -e "Invalid option: '--$OPTARG'\n" >&2 |
| 215 | usage && exit 1 |
| 216 | ;; |
| 217 | \?) |
| 218 | echo -e "Invalid option: '-$OPTARG'\n" >&2 |
| 219 | usage && exit 1 |
| 220 | ;; |
| tierno | 2cc8e25 | 2017-03-08 17:12:05 +0100 | [diff] [blame] | 221 | y) |
| 222 | ASSUME_YES="y" |
| 223 | ;; |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 224 | *) |
| 225 | usage && exit 1 |
| 226 | ;; |
| 227 | esac |
| 228 | done |
| 229 | |
| garciadeblas | a6ff986 | 2017-04-07 02:00:29 +0200 | [diff] [blame] | 230 | if [ -n "$SHOWOPTS" ]; then |
| 231 | echo "DEVELOP=$DEVELOP" |
| 232 | echo "UNINSTALL=$UNINSTALL" |
| 233 | echo "NAT=$NAT" |
| 234 | echo "UPDATE=$UPDATE" |
| 235 | echo "RECONFIGURE=$RECONFIGURE" |
| 236 | echo "TEST_INSTALLER=$TEST_INSTALLER" |
| 237 | echo "LXD=$LXD" |
| 238 | echo "SHOWOPTS=$SHOWOPTS" |
| 239 | echo "Install from specific refspec (-b): $COMMIT_ID" |
| 240 | exit 0 |
| 241 | fi |
| 242 | |
| garciadeblas | 2a5a651 | 2016-12-19 10:19:52 +0100 | [diff] [blame] | 243 | [ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master" |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 244 | [ -n "$TEST_INSTALLER" ] && [ -z "$COMMIT_ID" ] && echo "Use -b option to specify the branch to use for the test (e.g.: v1.0)" && exit 0 |
| garciadeblas | 2a5a651 | 2016-12-19 10:19:52 +0100 | [diff] [blame] | 245 | |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 246 | if [ -n "$TEST_INSTALLER" ]; then |
| 247 | echo -e "\nUsing local devops repo for OSM installation" |
| 248 | TEMPDIR="$(dirname $(realpath $(dirname $0)))" |
| 249 | else |
| 250 | echo -e "\nCreating temporary dir for OSM installation" |
| 251 | TEMPDIR="$(mktemp -d -q --tmpdir "installosm.XXXXXX")" |
| 252 | trap 'rm -rf "$TEMPDIR"' EXIT |
| 253 | fi |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 254 | |
| garciadeblas | 95f164e | 2016-10-19 13:00:54 +0200 | [diff] [blame] | 255 | echo -e "Checking required packages: git" |
| 256 | dpkg -l git &>/dev/null || ! echo -e " git not installed.\nInstalling git requires root privileges" || sudo apt install -y git |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 257 | if [ -z "$TEST_INSTALLER" ]; then |
| 258 | echo -e "\nCloning devops repo temporarily" |
| 259 | git clone https://osm.etsi.org/gerrit/osm/devops.git $TEMPDIR |
| 260 | RC_CLONE=$? |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 261 | fi |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 262 | |
| 263 | echo -e "\nGuessing the current stable release" |
| 264 | LATEST_STABLE_DEVOPS=`git -C $TEMPDIR tag -l v[0-9].* | tail -n1` |
| 265 | [ -z "$COMMIT_ID" ] && [ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0 |
| garciadeblas | a6ff986 | 2017-04-07 02:00:29 +0200 | [diff] [blame] | 266 | echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS" |
| 267 | [ -z "$COMMIT_ID" ] && [ -n "$LATEST_STABLE_DEVOPS" ] && COMMIT_ID="tags/$LATEST_STABLE_DEVOPS" |
| 268 | [ -z "$TEST_INSTALLER" ] && git -C $TEMPDIR checkout $LATEST_STABLE_DEVOPS |
| 269 | echo -e "\n Installing OSM from refspec: $COMMIT_ID" |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 270 | |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 271 | OSM_DEVOPS=$TEMPDIR |
| garciadeblas | 0fe45dd | 2016-10-04 07:54:17 +0200 | [diff] [blame] | 272 | OSM_JENKINS="$TEMPDIR/jenkins" |
| 273 | . $OSM_JENKINS/common/all_funcs |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 274 | |
| garciadeblas | d8718f1 | 2016-10-30 19:39:01 +0100 | [diff] [blame] | 275 | [ -n "$UNINSTALL" ] && uninstall && echo -e "\nDONE" && exit 0 |
| 276 | [ -n "$NAT" ] && nat && echo -e "\nDONE" && exit 0 |
| garciadeblas | 2a38273 | 2017-01-12 12:11:14 +0100 | [diff] [blame] | 277 | [ -n "$UPDATE" ] && update && echo -e "\nDONE" && exit 0 |
| garciadeblas | d8718f1 | 2016-10-30 19:39:01 +0100 | [diff] [blame] | 278 | [ -n "$RECONFIGURE" ] && configure && echo -e "\nDONE" && exit 0 |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 279 | |
| 280 | #Installation starts here |
| tierno | 2cc8e25 | 2017-03-08 17:12:05 +0100 | [diff] [blame] | 281 | if [ -z "$ASSUME_YES" ]; then |
| 282 | read -e -p "The installation will take about 75-90 minutes. Continue (Y/n)?" USER_CONFIRMATION |
| 283 | [ -n "$USER_CONFIRMATION" ] && [ "$USER_CONFIRMATION" != "yes" ] && \ |
| 284 | [ "$USER_CONFIRMATION" != "y" ] && echo "Cancelled!" && exit 0 |
| 285 | fi |
| 286 | |
| Jokin Garay | c0a6596 | 2017-03-09 14:51:48 +0100 | [diff] [blame] | 287 | echo -e "Checking required packages: lxd" |
| garciadeblas | d880f72 | 2017-04-07 20:14:57 +0200 | [diff] [blame] | 288 | lxd --version &>/dev/null || FATAL "lxd not present, exiting." |
| Jokin Garay | c0a6596 | 2017-03-09 14:51:48 +0100 | [diff] [blame] | 289 | |
| garciadeblas | 0fe45dd | 2016-10-04 07:54:17 +0200 | [diff] [blame] | 290 | wget -q -O- https://osm-download.etsi.org/ftp/osm-1.0-one/README.txt &> /dev/null |
| 291 | |
| garciadeblas | 2a5a651 | 2016-12-19 10:19:52 +0100 | [diff] [blame] | 292 | [ -n "$LXD" ] && echo -e "\nConfiguring lxd" && install_lxd |
| 293 | |
| garciadeblas | 95f164e | 2016-10-19 13:00:54 +0200 | [diff] [blame] | 294 | echo -e "\nChecking required packages: wget, curl, tar" |
| 295 | dpkg -l wget curl tar &>/dev/null || ! echo -e " One or several packages are not installed.\nInstalling required packages\n Root privileges are required" || sudo apt install -y wget curl tar |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 296 | |
| 297 | echo -e "\nCreating the containers and building ..." |
| Jokin Garay | c17db01 | 2017-03-08 17:45:39 +0100 | [diff] [blame] | 298 | $OSM_DEVOPS/jenkins/host/start_build RO --notest checkout $COMMIT_ID || FATAL "RO container build failed (refspec: '$COMMIT_ID')" |
| 299 | $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA container build failed" |
| 300 | $OSM_DEVOPS/jenkins/host/start_build SO checkout $COMMIT_ID || FATAL "SO container build failed (refspec: '$COMMIT_ID')" |
| 301 | $OSM_DEVOPS/jenkins/host/start_build UI checkout $COMMIT_ID || FATAL "UI container build failed (refspec: '$COMMIT_ID')" |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 302 | |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 303 | #Install iptables-persistent and configure NAT rules |
| 304 | nat |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 305 | |
| 306 | #Configure components |
| garciadeblas | 55490d4 | 2016-10-29 14:22:03 +0200 | [diff] [blame] | 307 | configure |
| garciadeblas | 93c6131 | 2016-09-28 15:12:48 +0200 | [diff] [blame] | 308 | |
| Jokin Garay | 237cfd5 | 2017-03-08 16:52:47 +0100 | [diff] [blame] | 309 | wget -q -O- https://osm-download.etsi.org/ftp/osm-1.0-one/README2.txt &> /dev/null |
| Jokin Garay | 3eb9ce7 | 2017-03-09 14:48:11 +0100 | [diff] [blame] | 310 | echo -e "\nDONE" |