blob: 2286aa4b7cf6eee781eba46601f832a3497ceff4 [file] [log] [blame]
garciadeblasd8bc5c32018-05-09 17:37:56 +02001#!/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
16function usage(){
17 echo -e "usage: $0 [OPTIONS]"
18 echo -e "Install OSM from binaries or source code (by default, from binaries)"
19 echo -e " OPTIONS"
garciadeblasd8bc5c32018-05-09 17:37:56 +020020 echo -e " -r <repo>: use specified repository name for osm packages"
21 echo -e " -R <release>: use specified release for osm binaries (deb packages, lxd images, ...)"
22 echo -e " -u <repo base>: use specified repository url for osm packages"
23 echo -e " -k <repo key>: use specified repository public key url"
24 echo -e " -b <refspec>: install OSM from source code using a specific branch (master, v2.0, ...) or tag"
25 echo -e " -b master (main dev branch)"
26 echo -e " -b v2.0 (v2.0 branch)"
27 echo -e " -b tags/v1.1.0 (a specific tag)"
28 echo -e " ..."
garciadeblas6c66abf2018-05-16 14:46:19 +020029 echo -e " --vimemu: additionally deploy the VIM emulator as a docker container"
30 echo -e " --elk_stack: additionally deploy an ELK docker stack for event logging"
31 echo -e " --pm_stack: additionally deploy a Prometheus+Grafana stack for performance monitoring (PM)"
garciadeblas0e596bc2018-05-28 16:04:42 +020032 echo -e " -m <MODULE>: install OSM but only rebuild the specified docker images (RO, LCM, NBI, LW-UI, MON, KAFKA, MONGO, NONE)"
garciadeblas6c66abf2018-05-16 14:46:19 +020033 echo -e " -o <ADDON>: do not install OSM, but ONLY one of the addons (vimemu, elk_stack, pm_stack) (assumes OSM is already installed)"
garciadeblase990f662018-05-18 11:43:39 +020034 echo -e " -D <devops path> use local devops installation path"
garciadeblasd41f5482018-05-25 10:25:06 +020035 echo -e " --nolxd: do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)"
garciadeblasa3e26612018-05-30 17:58:55 +020036 echo -e " --nodocker: do not install docker, do not initialize a swarm (assumes docker is already installed and a swarm has been initialized)"
garciadeblase990f662018-05-18 11:43:39 +020037 echo -e " --uninstall: uninstall OSM: remove the containers and delete NAT rules"
38 echo -e " --source: install OSM from source code using the latest stable tag"
garciadeblasd8bc5c32018-05-09 17:37:56 +020039 echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
garciadeblasd41f5482018-05-25 10:25:06 +020040 echo -e " --soui: install classic build of OSM (Rel THREE v3.1, based on LXD containers, with SO and UI)"
41 echo -e " --lxdimages: (only for Rel THREE with --soui) download lxd images from OSM repository instead of creating them from scratch"
42 echo -e " -l <lxd_repo>: (only for Rel THREE with --soui) use specified repository url for lxd images"
43 echo -e " -p <path>: (only for Rel THREE with --soui) use specified repository path for lxd images"
garciadeblasd8bc5c32018-05-09 17:37:56 +020044# echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)"
garciadeblasd41f5482018-05-25 10:25:06 +020045 echo -e " --nat: (only for Rel THREE with --soui) install only NAT rules"
46 echo -e " --noconfigure: (only for Rel THREE with --soui) DO NOT install osmclient, DO NOT install NAT rules, DO NOT configure modules"
garciadeblasd8bc5c32018-05-09 17:37:56 +020047# echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
48 echo -e " --showopts: print chosen options and exit (only for debugging)"
49 echo -e " -y: do not prompt for confirmation, assumes yes"
garciadeblasd8bc5c32018-05-09 17:37:56 +020050 echo -e " -h / --help: print this help"
51}
52
53#Uninstall OSM: remove containers
54function uninstall(){
55 echo -e "\nUninstalling OSM"
56 if [ $RC_CLONE ] || [ -n "$TEST_INSTALLER" ]; then
57 $OSM_DEVOPS/jenkins/host/clean_container RO
58 $OSM_DEVOPS/jenkins/host/clean_container VCA
59 $OSM_DEVOPS/jenkins/host/clean_container MON
60 $OSM_DEVOPS/jenkins/host/clean_container SO
61 #$OSM_DEVOPS/jenkins/host/clean_container UI
62 else
63 lxc stop RO && lxc delete RO
64 lxc stop VCA && lxc delete VCA
65 lxc stop MON && lxc delete MON
66 lxc stop SO-ub && lxc delete SO-ub
67 fi
68 echo -e "\nDeleting imported lxd images if they exist"
69 lxc image show osm-ro &>/dev/null && lxc image delete osm-ro
70 lxc image show osm-vca &>/dev/null && lxc image delete osm-vca
71 lxc image show osm-soui &>/dev/null && lxc image delete osm-soui
72 return 0
73}
74
garciadeblas5b857d32018-05-24 18:37:58 +020075function remove_stack() {
76 stack=$1
garciadeblas5ef98212018-05-28 09:25:36 +020077 if sg docker -c "docker stack ps ${stack}" ; then
garciadeblas5b857d32018-05-24 18:37:58 +020078 echo -e "\nRemoving stack ${stack}" && sg docker -c "docker stack rm ${stack}"
79 COUNTER=0
80 result=1
81 while [ ${COUNTER} -lt 30 ]; do
82 result=$(sg docker -c "docker stack ps ${stack}" | wc -l)
83 #echo "Dockers running: $result"
84 if [ "${result}" == "0" ]; then
85 break
86 fi
87 let COUNTER=COUNTER+1
88 sleep 1
89 done
garciadeblasd8bc5c32018-05-09 17:37:56 +020090 if [ "${result}" == "0" ]; then
garciadeblas5b857d32018-05-24 18:37:58 +020091 echo "All dockers of the stack ${stack} were removed"
92 else
93 FATAL "Some dockers of the stack ${stack} could not be removed. Could not clean it."
garciadeblasd8bc5c32018-05-09 17:37:56 +020094 fi
garciadeblas5b857d32018-05-24 18:37:58 +020095 sleep 5
garciadeblasd8bc5c32018-05-09 17:37:56 +020096 fi
garciadeblas5b857d32018-05-24 18:37:58 +020097}
98
99#Uninstall lightweight OSM: remove dockers
100function uninstall_lightweight() {
101 echo -e "\nUninstalling lightweight OSM"
102 remove_stack osm
garciadeblas83ca1322018-05-22 18:31:14 +0200103 echo "Now osm docker images and volumes will be deleted"
104 newgrp docker << EONG
garciadeblasd8bc5c32018-05-09 17:37:56 +0200105 docker image rm osm/ro
106 docker image rm osm/lcm
107 docker image rm osm/light-ui
108 docker image rm osm/nbi
109 docker image rm osm/mon
110 docker image rm osm/pm
garciadeblas83ca1322018-05-22 18:31:14 +0200111 docker volume rm osm_mon_db
112 docker volume rm osm_mongo_db
113 docker volume rm osm_osm_packages
114 docker volume rm osm_ro_db
115EONG
garciadeblas70502ad2018-05-25 12:15:12 +0200116 echo "Removing /etc/osm and /var/log/osm files"
117 rm -rf /etc/osm
118 rm -rf /var/log/osm
garciadeblasd8bc5c32018-05-09 17:37:56 +0200119 return 0
120}
121
122#Configure NAT rules, based on the current IP addresses of containers
123function nat(){
124 echo -e "\nChecking required packages: iptables-persistent"
125 dpkg -l iptables-persistent &>/dev/null || ! echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" || \
126 sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install iptables-persistent
127 echo -e "\nConfiguring NAT rules"
128 echo -e " Required root privileges"
129 sudo $OSM_DEVOPS/installers/nat_osm
130}
131
132function FATAL(){
133 echo "FATAL error: Cannot install OSM due to \"$1\""
134 exit 1
135}
136
137#Update RO, SO and UI:
138function update(){
139 echo -e "\nUpdating components"
140
141 echo -e " Updating RO"
142 CONTAINER="RO"
143 MDG="RO"
144 INSTALL_FOLDER="/opt/openmano"
145 echo -e " Fetching the repo"
146 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
147 BRANCH=""
148 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
149 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
150 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
151 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
152 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
153 # COMMIT_ID either was previously set with -b option, or is an empty string
154 CHECKOUT_ID=$COMMIT_ID
155 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
156 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
157 if [[ $CHECKOUT_ID == "tags/"* ]]; then
158 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
159 else
160 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
161 fi
162 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
163 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
164 echo " Nothing to be done."
165 else
166 echo " Update required."
167 lxc exec $CONTAINER -- service osm-ro stop
168 lxc exec $CONTAINER -- git -C /opt/openmano stash
169 lxc exec $CONTAINER -- git -C /opt/openmano pull --rebase
170 lxc exec $CONTAINER -- git -C /opt/openmano checkout $CHECKOUT_ID
171 lxc exec $CONTAINER -- git -C /opt/openmano stash pop
172 lxc exec $CONTAINER -- /opt/openmano/database_utils/migrate_mano_db.sh
173 lxc exec $CONTAINER -- service osm-ro start
174 fi
175 echo
176
177 echo -e " Updating SO and UI"
178 CONTAINER="SO-ub"
179 MDG="SO"
180 INSTALL_FOLDER="" # To be filled in
181 echo -e " Fetching the repo"
182 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
183 BRANCH=""
184 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
185 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
186 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
187 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
188 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
189 # COMMIT_ID either was previously set with -b option, or is an empty string
190 CHECKOUT_ID=$COMMIT_ID
191 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
192 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
193 if [[ $CHECKOUT_ID == "tags/"* ]]; then
194 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
195 else
196 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
197 fi
198 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
199 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
200 echo " Nothing to be done."
201 else
202 echo " Update required."
203 # Instructions to be added
204 # lxc exec SO-ub -- ...
205 fi
206 echo
207 echo -e "Updating MON Container"
208 CONTAINER="MON"
209 MDG="MON"
210 INSTALL_FOLDER="/root/MON"
211 echo -e " Fetching the repo"
212 lxc exec $CONTAINER -- git -C $INSTALL_FOLDER fetch --all
213 BRANCH=""
214 BRANCH=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status -sb | head -n1 | sed -n 's/^## \(.*\).*/\1/p'|awk '{print $1}' |sed 's/\(.*\)\.\.\..*/\1/'`
215 [ -z "$BRANCH" ] && FATAL "Could not find the current branch in use in the '$MDG'"
216 CURRENT=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER status |head -n1`
217 CURRENT_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse HEAD`
218 echo " FROM: $CURRENT ($CURRENT_COMMIT_ID)"
219 # COMMIT_ID either was previously set with -b option, or is an empty string
220 CHECKOUT_ID=$COMMIT_ID
221 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" == "HEAD" ] && CHECKOUT_ID="tags/$LATEST_STABLE_DEVOPS"
222 [ -z "$CHECKOUT_ID" ] && [ "$BRANCH" != "HEAD" ] && CHECKOUT_ID="$BRANCH"
223 if [[ $CHECKOUT_ID == "tags/"* ]]; then
224 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-list -n 1 $CHECKOUT_ID`
225 else
226 REMOTE_COMMIT_ID=`lxc exec $CONTAINER -- git -C $INSTALL_FOLDER rev-parse origin/$CHECKOUT_ID`
227 fi
228 echo " TO: $CHECKOUT_ID ($REMOTE_COMMIT_ID)"
229 if [ "$CURRENT_COMMIT_ID" == "$REMOTE_COMMIT_ID" ]; then
230 echo " Nothing to be done."
231 else
232 echo " Update required."
233 fi
234 echo
235}
236
237function so_is_up() {
238 if [ -n "$1" ]; then
239 SO_IP=$1
240 else
241 SO_IP=`lxc list SO-ub -c 4|grep eth0 |awk '{print $2}'`
242 fi
243 time=0
244 step=5
245 timelength=300
246 while [ $time -le $timelength ]
247 do
248 if [[ `curl -k -X GET https://$SO_IP:8008/api/operational/vcs/info \
249 -H 'accept: application/vnd.yang.data+json' \
250 -H 'authorization: Basic YWRtaW46YWRtaW4=' \
251 -H 'cache-control: no-cache' 2> /dev/null | jq '.[].components.component_info[] | select(.component_name=="RW.Restconf")' 2>/dev/null | grep "RUNNING" | wc -l` -eq 1 ]]
252 then
253 echo "RW.Restconf running....SO is up"
254 return 0
255 fi
256
257 sleep $step
258 echo -n "."
259 time=$((time+step))
260 done
261
262 FATAL "OSM Failed to startup. SO failed to startup"
263}
264
265function vca_is_up() {
266 if [[ `lxc exec VCA -- juju status | grep "osm" | wc -l` -eq 1 ]]; then
267 echo "VCA is up and running"
268 return 0
269 fi
270
271 FATAL "OSM Failed to startup. VCA failed to startup"
272}
273
274function mon_is_up() {
275 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
276 echo "MON is up and running"
277 return 0
278 fi
279
280 FATAL "OSM Failed to startup. MON failed to startup"
281}
282
283function ro_is_up() {
284 if [ -n "$1" ]; then
285 RO_IP=$1
286 else
287 RO_IP=`lxc list RO -c 4|grep eth0 |awk '{print $2}'`
288 fi
289 time=0
290 step=2
291 timelength=20
292 while [ $time -le $timelength ]; do
293 if [[ `curl http://$RO_IP:9090/openmano/ | grep "works" | wc -l` -eq 1 ]]; then
294 echo "RO is up and running"
295 return 0
296 fi
297 sleep $step
298 echo -n "."
299 time=$((time+step))
300 done
301
302 FATAL "OSM Failed to startup. RO failed to startup"
303}
304
305
306function configure_RO(){
307 . $OSM_DEVOPS/installers/export_ips
308 echo -e " Configuring RO"
309 lxc exec RO -- sed -i -e "s/^\#\?log_socket_host:.*/log_socket_host: $SO_CONTAINER_IP/g" /etc/osm/openmanod.cfg
310 lxc exec RO -- service osm-ro restart
311
312 ro_is_up
313
314 lxc exec RO -- openmano tenant-delete -f osm >/dev/null
315 lxc exec RO -- openmano tenant-create osm > /dev/null
316 lxc exec RO -- sed -i '/export OPENMANO_TENANT=osm/d' .bashrc
317 lxc exec RO -- sed -i '$ i export OPENMANO_TENANT=osm' .bashrc
318 lxc exec RO -- sh -c 'echo "export OPENMANO_TENANT=osm" >> .bashrc'
319}
320
321function configure_VCA(){
322 echo -e " Configuring VCA"
323 JUJU_PASSWD=`date +%s | sha256sum | base64 | head -c 32`
324 echo -e "$JUJU_PASSWD\n$JUJU_PASSWD" | lxc exec VCA -- juju change-user-password
325}
326
327function configure_SOUI(){
328 . $OSM_DEVOPS/installers/export_ips
329 JUJU_CONTROLLER_IP=`lxc exec VCA -- lxc list -c 4 |grep eth0 |awk '{print $2}'`
330 RO_TENANT_ID=`lxc exec RO -- openmano tenant-list osm |awk '{print $1}'`
331
332 echo -e " Configuring MON"
333 #Information to be added about SO socket for logging
334
335 echo -e " Configuring SO"
336 sudo route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP
garciadeblas818fa5a2018-05-10 13:39:10 +0200337 sudo ip route add 10.44.127.0/24 via $VCA_CONTAINER_IP
garciadeblasd8bc5c32018-05-09 17:37:56 +0200338 sudo sed -i "$ i route add -host $JUJU_CONTROLLER_IP gw $VCA_CONTAINER_IP" /etc/rc.local
garciadeblas818fa5a2018-05-10 13:39:10 +0200339 sudo sed -i "$ i ip route add 10.44.127.0/24 via $VCA_CONTAINER_IP" /etc/rc.local
garciadeblasd8bc5c32018-05-09 17:37:56 +0200340 # make journaling persistent
341 lxc exec SO-ub -- mkdir -p /var/log/journal
342 lxc exec SO-ub -- systemd-tmpfiles --create --prefix /var/log/journal
343 lxc exec SO-ub -- systemctl restart systemd-journald
344
345 echo RIFT_EXTERNAL_ADDRESS=$DEFAULT_IP | lxc exec SO-ub -- tee -a /usr/rift/etc/default/launchpad
346
347 lxc exec SO-ub -- systemctl restart launchpad
348
349 so_is_up $SO_CONTAINER_IP
350
351 #delete existing config agent (could be there on reconfigure)
352 curl -k --request DELETE \
353 --url https://$SO_CONTAINER_IP:8008/api/config/config-agent/account/osmjuju \
354 --header 'accept: application/vnd.yang.data+json' \
355 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
356 --header 'cache-control: no-cache' \
357 --header 'content-type: application/vnd.yang.data+json' &> /dev/null
358
359 result=$(curl -k --request POST \
360 --url https://$SO_CONTAINER_IP:8008/api/config/config-agent \
361 --header 'accept: application/vnd.yang.data+json' \
362 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
363 --header 'cache-control: no-cache' \
364 --header 'content-type: application/vnd.yang.data+json' \
365 --data '{"account": [ { "name": "osmjuju", "account-type": "juju", "juju": { "ip-address": "'$JUJU_CONTROLLER_IP'", "port": "17070", "user": "admin", "secret": "'$JUJU_PASSWD'" } } ]}')
366 [[ $result =~ .*success.* ]] || FATAL "Failed config-agent configuration: $result"
367
368 #R1/R2 config line
369 #result=$(curl -k --request PUT \
370 # --url https://$SO_CONTAINER_IP:8008/api/config/resource-orchestrator \
371 # --header 'accept: application/vnd.yang.data+json' \
372 # --header 'authorization: Basic YWRtaW46YWRtaW4=' \
373 # --header 'cache-control: no-cache' \
374 # --header 'content-type: application/vnd.yang.data+json' \
375 # --data '{ "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'" }, "name": "osmopenmano", "account-type": "openmano" }')
376
377 result=$(curl -k --request PUT \
378 --url https://$SO_CONTAINER_IP:8008/api/config/project/default/ro-account/account \
379 --header 'accept: application/vnd.yang.data+json' \
380 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
381 --header 'cache-control: no-cache' \
382 --header 'content-type: application/vnd.yang.data+json' \
383 --data '{"rw-ro-account:account": [ { "openmano": { "host": "'$RO_CONTAINER_IP'", "port": "9090", "tenant-id": "'$RO_TENANT_ID'"}, "name": "osmopenmano", "ro-account-type": "openmano" }]}')
384 [[ $result =~ .*success.* ]] || FATAL "Failed resource-orchestrator configuration: $result"
385
386 result=$(curl -k --request PATCH \
387 --url https://$SO_CONTAINER_IP:8008/v2/api/config/openidc-provider-config/rw-ui-client/redirect-uri \
388 --header 'accept: application/vnd.yang.data+json' \
389 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
390 --header 'cache-control: no-cache' \
391 --header 'content-type: application/vnd.yang.data+json' \
392 --data '{"redirect-uri": "https://'$DEFAULT_IP':8443/callback" }')
393 [[ $result =~ .*success.* ]] || FATAL "Failed redirect-uri configuration: $result"
394
395 result=$(curl -k --request PATCH \
396 --url https://$SO_CONTAINER_IP:8008/v2/api/config/openidc-provider-config/rw-ui-client/post-logout-redirect-uri \
397 --header 'accept: application/vnd.yang.data+json' \
398 --header 'authorization: Basic YWRtaW46YWRtaW4=' \
399 --header 'cache-control: no-cache' \
400 --header 'content-type: application/vnd.yang.data+json' \
401 --data '{"post-logout-redirect-uri": "https://'$DEFAULT_IP':8443/?api_server=https://'$DEFAULT_IP'" }')
402 [[ $result =~ .*success.* ]] || FATAL "Failed post-logout-redirect-uri configuration: $result"
403
404 lxc exec SO-ub -- tee /etc/network/interfaces.d/60-rift.cfg <<EOF
405auto lo:1
406iface lo:1 inet static
407 address $DEFAULT_IP
408 netmask 255.255.255.255
409EOF
410 lxc exec SO-ub ifup lo:1
411}
412
413#Configure RO, VCA, and SO with the initial configuration:
414# RO -> tenant:osm, logs to be sent to SO
415# VCA -> juju-password
416# SO -> route to Juju Controller, add RO account, add VCA account
417function configure(){
418 #Configure components
419 echo -e "\nConfiguring components"
420 configure_RO
421 configure_VCA
422 configure_SOUI
423}
424
425function install_lxd() {
426 sudo apt-get update
427 sudo apt-get install -y lxd
428 newgrp lxd
429 lxd init --auto
430 lxd waitready
431 lxc network create lxdbr0 ipv4.address=auto ipv4.nat=true ipv6.address=none ipv6.nat=false
432 DEFAULT_INTERFACE=$(route -n | awk '$1~/^0.0.0.0/ {print $8}')
433 DEFAULT_MTU=$(ip addr show $DEFAULT_INTERFACE | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
434 lxc profile device set default eth0 mtu $DEFAULT_MTU
435 #sudo systemctl stop lxd-bridge
436 #sudo systemctl --system daemon-reload
437 #sudo systemctl enable lxd-bridge
438 #sudo systemctl start lxd-bridge
439}
440
441function ask_user(){
442 # ask to the user and parse a response among 'y', 'yes', 'n' or 'no'. Case insensitive
443 # Params: $1 text to ask; $2 Action by default, can be 'y' for yes, 'n' for no, other or empty for not allowed
444 # Return: true(0) if user type 'yes'; false (1) if user type 'no'
445 read -e -p "$1" USER_CONFIRMATION
446 while true ; do
447 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'y' ] && return 0
448 [ -z "$USER_CONFIRMATION" ] && [ "$2" == 'n' ] && return 1
449 [ "${USER_CONFIRMATION,,}" == "yes" ] || [ "${USER_CONFIRMATION,,}" == "y" ] && return 0
450 [ "${USER_CONFIRMATION,,}" == "no" ] || [ "${USER_CONFIRMATION,,}" == "n" ] && return 1
451 read -e -p "Please type 'yes' or 'no': " USER_CONFIRMATION
452 done
453}
454
455function launch_container_from_lxd(){
456 export OSM_MDG=$1
457 OSM_load_config
458 export OSM_BASE_IMAGE=$2
459 if ! container_exists $OSM_BUILD_CONTAINER; then
460 CONTAINER_OPTS=""
461 [[ "$OSM_BUILD_CONTAINER_PRIVILEGED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.privileged=true"
462 [[ "$OSM_BUILD_CONTAINER_ALLOW_NESTED" == yes ]] && CONTAINER_OPTS="$CONTAINER_OPTS -c security.nesting=true"
463 create_container $OSM_BASE_IMAGE $OSM_BUILD_CONTAINER $CONTAINER_OPTS
464 wait_container_up $OSM_BUILD_CONTAINER
465 fi
466}
467
468function install_osmclient(){
469 CLIENT_RELEASE=${RELEASE#"-R "}
470 CLIENT_REPOSITORY_KEY="OSM%20ETSI%20Release%20Key.gpg"
471 CLIENT_REPOSITORY=${REPOSITORY#"-r "}
472 [ -z "$REPOSITORY_BASE" ] && REPOSITORY_BASE="-u https://osm-download.etsi.org/repository/osm/debian"
473 CLIENT_REPOSITORY_BASE=${REPOSITORY_BASE#"-u "}
474 key_location=$CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE/$CLIENT_REPOSITORY_KEY
475 curl $key_location | sudo apt-key add -
476 sudo add-apt-repository -y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient"
477 sudo apt-get update
478 sudo apt-get install -y python-pip
479 sudo -H pip install pip==9.0.3
480 sudo -H pip install python-magic
481 sudo apt-get install -y python-osmclient
482 #sed 's,OSM_SOL005=[^$]*,OSM_SOL005=True,' -i ${HOME}/.bashrc
483 #echo 'export OSM_HOSTNAME=localhost' >> ${HOME}/.bashrc
484 #echo 'export OSM_SOL005=True' >> ${HOME}/.bashrc
485 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'`
486 [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_RO_HOSTNAME=`lxc list | awk '($2=="RO"){print $6}'`
garciadeblas8e6bc152018-05-14 11:36:11 +0200487 [ -n "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=127.0.0.1
garciadeblasd8bc5c32018-05-09 17:37:56 +0200488 echo -e "\nOSM client installed"
489 echo -e "You might be interested in adding the following OSM client env variables to your .bashrc file:"
490 echo " export OSM_HOSTNAME=${OSM_HOSTNAME}"
491 [ -n "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_SOL005=True"
492 [ -z "$INSTALL_LIGHTWEIGHT" ] && echo " export OSM_RO_HOSTNAME=${OSM_RO_HOSTNAME}"
493 return 0
494}
495
496function install_from_lxdimages(){
497 LXD_RELEASE=${RELEASE#"-R "}
498 if [ -n "$LXD_REPOSITORY_PATH" ]; then
499 LXD_IMAGE_DIR="$LXD_REPOSITORY_PATH"
500 else
501 LXD_IMAGE_DIR="$(mktemp -d -q --tmpdir "osmimages.XXXXXX")"
502 trap 'rm -rf "$LXD_IMAGE_DIR"' EXIT
503 fi
504 echo -e "\nDeleting previous lxd images if they exist"
505 lxc image show osm-ro &>/dev/null && lxc image delete osm-ro
506 lxc image show osm-vca &>/dev/null && lxc image delete osm-vca
507 lxc image show osm-soui &>/dev/null && lxc image delete osm-soui
508 echo -e "\nImporting osm-ro"
509 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-ro.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-ro.tar.gz
510 lxc image import $LXD_IMAGE_DIR/osm-ro.tar.gz --alias osm-ro
511 rm -f $LXD_IMAGE_DIR/osm-ro.tar.gz
512 echo -e "\nImporting osm-vca"
513 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-vca.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-vca.tar.gz
514 lxc image import $LXD_IMAGE_DIR/osm-vca.tar.gz --alias osm-vca
515 rm -f $LXD_IMAGE_DIR/osm-vca.tar.gz
516 echo -e "\nImporting osm-soui"
517 [ -z "$LXD_REPOSITORY_PATH" ] && wget -O $LXD_IMAGE_DIR/osm-soui.tar.gz $LXD_REPOSITORY_BASE/$LXD_RELEASE/osm-soui.tar.gz
518 lxc image import $LXD_IMAGE_DIR/osm-soui.tar.gz --alias osm-soui
519 rm -f $LXD_IMAGE_DIR/osm-soui.tar.gz
520 launch_container_from_lxd RO osm-ro
521 ro_is_up && track RO
522 launch_container_from_lxd VCA osm-vca
523 vca_is_up && track VCA
524 launch_container_from_lxd MON osm-mon
525 mon_is_up && track MON
526 launch_container_from_lxd SO osm-soui
527 #so_is_up && track SOUI
528 track SOUI
529}
530
531function install_docker_ce() {
532 # installs and configures Docker CE
533 echo "Installing Docker CE ..."
534 sudo apt-get -qq update
535 sudo apt-get install -y apt-transport-https ca-certificates software-properties-common
536 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
537 sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
538 sudo apt-get -qq update
539 sudo apt-get install -y docker-ce
540 echo "Adding user to group 'docker'"
541 sudo groupadd -f docker
542 sudo usermod -aG docker $USER
garciadeblasd8bc5c32018-05-09 17:37:56 +0200543 sleep 2
544 sudo service docker restart
545 echo "... restarted Docker service"
garciadeblas67ce97c2018-05-18 10:22:09 +0200546 sg docker -c "docker version" || FATAL "Docker installation failed"
547 echo "... Docker CE installation done"
548 return 0
garciadeblasd8bc5c32018-05-09 17:37:56 +0200549}
550
551function install_docker_compose() {
552 # installs and configures docker-compose
553 echo "Installing Docker Compose ..."
554 sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
555 sudo chmod +x /usr/local/bin/docker-compose
556 echo "... Docker Compose installation done"
557}
558
559function install_juju() {
560 echo "Installing juju"
561 sudo snap install juju --classic
garciadeblasd41f5482018-05-25 10:25:06 +0200562 [ -z "$INSTALL_NOLXD" ] && sudo dpkg-reconfigure -p medium lxd
garciadeblasa235be82018-05-18 15:37:28 +0200563 sg lxd -c "juju bootstrap --bootstrap-series=xenial localhost osm"
garciadeblasf79d1632018-05-24 10:48:59 +0200564 [ $(sg lxd -c "juju status" |grep "osm" |wc -l) -eq 1 ] || FATAL "Juju installation failed"
garciadeblasd8bc5c32018-05-09 17:37:56 +0200565 echo "Finished installation of juju"
566}
567
568function generate_docker_images() {
569 echo "Pulling and generating docker images"
garciadeblas0e596bc2018-05-28 16:04:42 +0200570 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q KAFKA ; then
571 sg docker -c "docker pull wurstmeister/zookeeper" || FATAL "cannot get zookeeper docker image"
572 sg docker -c "docker pull wurstmeister/kafka" || FATAL "cannot get kafka docker image"
573 fi
574 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MONGO ; then
575 sg docker -c "docker pull mongo" || FATAL "cannot get mongo docker image"
576 fi
577 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MON ; then
578 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/MON
579 git -C ${LWTEMPDIR}/MON checkout ${COMMIT_ID}
580 sg docker -c "docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t osm/mon --no-cache" || FATAL "cannot build MON docker image"
581 sg docker -c "docker build ${LWTEMPDIR}/MON/policy_module -f ${LWTEMPDIR}/MON/policy_module/Dockerfile -t osm/pm --no-cache" || FATAL "cannot build PM docker image"
582 fi
583 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q NBI ; then
584 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/NBI
585 git -C ${LWTEMPDIR}/NBI checkout ${COMMIT_ID}
586 sg docker -c "docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t osm/nbi --no-cache" || FATAL "cannot build NBI docker image"
587 fi
588 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q RO ; then
589 sg docker -c "docker pull mysql:5" || FATAL "cannot get mysql docker image"
590 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/RO
591 git -C ${LWTEMPDIR}/RO checkout ${COMMIT_ID}
592 sg docker -c "docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/docker/Dockerfile-local -t osm/ro --no-cache" || FATAL "cannot build RO docker image"
593 fi
594 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LCM ; then
595 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LCM
596 git -C ${LWTEMPDIR}/LCM checkout ${COMMIT_ID}
597 sg docker -c "docker build ${LWTEMPDIR}/LCM -f ${LWTEMPDIR}/LCM/Dockerfile.local -t osm/lcm --no-cache" || FATAL "cannot build LCM docker image"
598 fi
599 if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LW-UI ; then
600 git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LW-UI
601 git -C ${LWTEMPDIR}/LW-UI checkout ${COMMIT_ID}
602 sg docker -c "docker build ${LWTEMPDIR}/LW-UI -t osm/light-ui -f ${LWTEMPDIR}/LW-UI/Dockerfile --no-cache" || FATAL "cannot build LW-UI docker image"
603 fi
garciadeblasd8bc5c32018-05-09 17:37:56 +0200604 echo "Finished generation of docker images"
605}
606
garciadeblas5b857d32018-05-24 18:37:58 +0200607function cmp_overwrite() {
608 file1="$1"
609 file2="$2"
610 if ! $(cmp "${file1}" "${file2}" >/dev/null 2>&1); then
611 if [ -f "${file2}" ]; then
garciadeblas70502ad2018-05-25 12:15:12 +0200612 ask_user "The file ${file2} already exists. Overwrite (y/N)? " n && sudo cp -b ${file1} ${file2}
garciadeblas5b857d32018-05-24 18:37:58 +0200613 else
garciadeblas70502ad2018-05-25 12:15:12 +0200614 sudo cp -b ${file1} ${file2}
garciadeblas5b857d32018-05-24 18:37:58 +0200615 fi
616 fi
617}
618
garciadeblascf0e34a2018-05-24 10:45:53 +0200619function generate_config_log_folders() {
620 echo "Generating config and log folders"
garciadeblas5b857d32018-05-24 18:37:58 +0200621 sudo mkdir -p /etc/osm/docker
garciadeblas5ef98212018-05-28 09:25:36 +0200622 sudo cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml /etc/osm/docker/docker-compose.yaml
garciadeblascf0e34a2018-05-24 10:45:53 +0200623 sudo mkdir -p /var/log/osm
624 echo "Finished generation of config and log folders"
625}
626
garciadeblasd8bc5c32018-05-09 17:37:56 +0200627function generate_docker_env_files() {
628 echo "Generating docker env files"
garciadeblas5b857d32018-05-24 18:37:58 +0200629 echo "OSMLCM_VCA_HOST=${OSMLCM_VCA_HOST}" |sudo tee /etc/osm/docker/lcm.env
630 echo "OSMLCM_VCA_SECRET=${OSMLCM_VCA_SECRET}" |sudo tee -a /etc/osm/docker/lcm.env
garciadeblasd8bc5c32018-05-09 17:37:56 +0200631 MYSQL_ROOT_PASSWORD=`date +%s | sha256sum | base64 | head -c 32`
garciadeblas5b857d32018-05-24 18:37:58 +0200632 if [ ! -f /etc/osm/docker/ro-db.env ]; then
633 echo "MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |sudo tee /etc/osm/docker/ro-db.env
634 fi
635 if [ ! -f /etc/osm/docker/ro.env ]; then
636 echo "RO_DB_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}" |sudo tee /etc/osm/docker/ro.env
637 fi
garciadeblasd8bc5c32018-05-09 17:37:56 +0200638 echo "OS_NOTIFIER_URI=http://${DEFAULT_IP}:8662" |sudo tee ${OSM_DEVOPS}/installers/docker/mon.env
garciadeblas5ef98212018-05-28 09:25:36 +0200639 cmp_overwrite ${OSM_DEVOPS}/installers/docker/mon.env /etc/osm/docker/mon.env
garciadeblasd8bc5c32018-05-09 17:37:56 +0200640 echo "Finished generation of docker env files"
641}
642
garciadeblasa3e26612018-05-30 17:58:55 +0200643function init_docker_swarm() {
garciadeblasd8bc5c32018-05-09 17:37:56 +0200644 if [ "${DEFAULT_MTU}" != "1500" ]; then
645 DOCKER_NETS=`sg docker -c "docker network list" | awk '{print $2}' | egrep -v "^ID$" | paste -d " " -s`
646 DOCKER_GW_NET=`sg docker -c "docker network inspect ${DOCKER_NETS}" | grep Subnet | awk -F\" '{print $4}' | egrep "^172" | sort -u | tail -1 | awk -F\. '{if ($2 != 255) print $1"."$2+1"."$3"."$4; else print "-1";}'`
647 sg docker -c "docker network create --subnet ${DOCKER_GW_NET} --opt com.docker.network.bridge.name=docker_gwbridge --opt com.docker.network.bridge.enable_icc=false --opt com.docker.network.bridge.enable_ip_masquerade=true --opt com.docker.network.driver.mtu=${DEFAULT_MTU} docker_gwbridge"
648 fi
garciadeblas5b857d32018-05-24 18:37:58 +0200649 sg docker -c "docker swarm init --advertise-addr ${DEFAULT_IP}"
650 sg docker -c "docker network create --driver=overlay --attachable --opt com.docker.network.driver.mtu=${DEFAULT_MTU} netOSM"
garciadeblasa3e26612018-05-30 17:58:55 +0200651 return 0
652}
653
654function deploy_lightweight() {
655 echo "Deploying lightweight build"
656 [ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
garciadeblas5b857d32018-05-24 18:37:58 +0200657 remove_stack osm
658 sg docker -c "docker stack deploy -c /etc/osm/docker/docker-compose.yaml osm"
659 #docker-compose -f /etc/osm/docker/docker-compose.yaml up -d
garciadeblasd8bc5c32018-05-09 17:37:56 +0200660 echo "Finished deployment of lightweight build"
661}
662
garciadeblas6c66abf2018-05-16 14:46:19 +0200663function deploy_elk() {
garciadeblas5b857d32018-05-24 18:37:58 +0200664 sudo mkdir -p /etc/osm/docker/osm_elk
garciadeblas5ef98212018-05-28 09:25:36 +0200665 sudo cp -b ${OSM_DEVOPS}/installers/docker/osm_elk/* /etc/osm/docker/osm_elk
garciadeblas5b857d32018-05-24 18:37:58 +0200666 remove_stack osm_elk
garciadeblas6c66abf2018-05-16 14:46:19 +0200667 echo "Deploying ELK stack"
garciadeblas5b857d32018-05-24 18:37:58 +0200668 sg docker -c "docker stack deploy -c /etc/osm/docker/osm_elk/docker-compose.yml osm_elk"
garciadeblas6c66abf2018-05-16 14:46:19 +0200669 echo "Waiting for ELK stack to be up and running"
670 time=0
671 step=2
672 timelength=20
673 elk_is_up=1
674 while [ $time -le $timelength ]; do
garciadeblas5b857d32018-05-24 18:37:58 +0200675 if [[ $(curl -XGET http://127.0.0.1:5601/status -I | grep "HTTP/1.1 200 OK" | wc -l ) -eq 1 ]]; then
garciadeblas6c66abf2018-05-16 14:46:19 +0200676 elk_is_up=0
677 break
678 fi
679 sleep $step
680 time=$((time+step))
681 done
682 if [ $elk_is_up -eq 0 ]; then
683 echo "ELK is up and running. Trying to create index pattern..."
684 #Create index pattern
685 curl -f -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
garciadeblas5b857d32018-05-24 18:37:58 +0200686 "http://127.0.0.1:5601/api/saved_objects/index-pattern/logstash-*" \
garciadeblas6c66abf2018-05-16 14:46:19 +0200687 -d"{\"attributes\":{\"title\":\"logstash-*\",\"timeFieldName\":\"@timestamp\"}}"
688 #Make it the default index
689 curl -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
garciadeblas5b857d32018-05-24 18:37:58 +0200690 "http://127.0.0.1:5601/api/kibana/settings/defaultIndex" \
garciadeblas6c66abf2018-05-16 14:46:19 +0200691 -d"{\"value\":\"logstash-*\"}"
692 else
693 echo "Cannot connect to Kibana to create index pattern."
694 echo "Once Kibana is running, you can use the following instructions to create index pattern:"
695 echo 'curl -f -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
garciadeblas5b857d32018-05-24 18:37:58 +0200696 "http://127.0.0.1:5601/api/saved_objects/index-pattern/logstash-*" \
garciadeblas6c66abf2018-05-16 14:46:19 +0200697 -d"{\"attributes\":{\"title\":\"logstash-*\",\"timeFieldName\":\"@timestamp\"}}"'
698 echo 'curl -XPOST -H "Content-Type: application/json" -H "kbn-xsrf: anything" \
garciadeblas5b857d32018-05-24 18:37:58 +0200699 "http://127.0.0.1:5601/api/kibana/settings/defaultIndex" \
garciadeblas6c66abf2018-05-16 14:46:19 +0200700 -d"{\"value\":\"logstash-*\"}"'
701 fi
702 echo "Finished deployment of ELK stack"
703 return 0
704}
705
706function deploy_perfmon() {
707 echo "Generating osm/kafka-exporter docker image"
garciadeblasc119fb32018-05-25 09:13:30 +0200708 sg docker -c "docker build ${OSM_DEVOPS}/installers/docker/osm_metrics/kafka-exporter -f ${OSM_DEVOPS}/installers/docker/osm_metrics/kafka-exporter/Dockerfile -t osm/kafka-exporter --no-cache" || FATAL "cannot build kafka-exporter docker image"
garciadeblas6c66abf2018-05-16 14:46:19 +0200709 echo "Finished generation of osm/kafka-exporter docker image"
garciadeblas5b857d32018-05-24 18:37:58 +0200710 sudo mkdir -p /etc/osm/docker/osm_metrics
garciadeblas5ef98212018-05-28 09:25:36 +0200711 sudo cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.yml /etc/osm/docker/osm_metrics
712 sudo cp -b ${OSM_DEVOPS}/installers/docker/osm_metrics/*.json /etc/osm/docker/osm_metrics
garciadeblas5b857d32018-05-24 18:37:58 +0200713 remove_stack osm_metrics
garciadeblas6c66abf2018-05-16 14:46:19 +0200714 echo "Deploying PM stack (Kafka exporter + Prometheus + Grafana)"
garciadeblas5b857d32018-05-24 18:37:58 +0200715 sg docker -c "docker stack deploy -c /etc/osm/docker/osm_metrics/docker-compose.yml osm_metrics"
garciadeblas6c66abf2018-05-16 14:46:19 +0200716 echo "Finished deployment of PM stack"
717 return 0
718}
719
garciadeblasd8bc5c32018-05-09 17:37:56 +0200720function install_lightweight() {
garciadeblasd13a8aa2018-05-18 15:24:51 +0200721 [ "$USER" == "root" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges."
garciadeblas0ebde162018-05-30 18:36:29 +0200722 [ -z "$ASSUME_YES" ] && ! ask_user "The installation will configure LXD, install juju, install docker CE and init a docker swarm, as pre-requirements. Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
garciadeblasd8bc5c32018-05-09 17:37:56 +0200723 echo "Installing lightweight build of OSM"
724 LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")"
725 trap 'rm -rf "${LWTEMPDIR}"' EXIT
726 DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'`
727 DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
728 DEFAULT_MTU=$(ip addr show ${DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
garciadeblasd41f5482018-05-25 10:25:06 +0200729 if [ -z "$INSTALL_NOLXD" ]; then
730 need_packages_lw="lxd"
731 echo -e "Checking required packages: $need_packages_lw"
732 dpkg -l $need_packages_lw &>/dev/null \
733 || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
734 || sudo apt-get update \
735 || FATAL "failed to run apt-get update"
736 dpkg -l $need_packages_lw &>/dev/null \
737 || ! echo -e "Installing $need_packages_lw requires root privileges." \
738 || sudo apt-get install -y $need_packages_lw \
739 || FATAL "failed to install $need_packages_lw"
740 fi
garciadeblasd8bc5c32018-05-09 17:37:56 +0200741 install_juju
garciadeblas70502ad2018-05-25 12:15:12 +0200742 OSMLCM_VCA_HOST=`sg lxd -c "juju show-controller"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
743 OSMLCM_VCA_SECRET=`grep password ${HOME}/.local/share/juju/accounts.yaml |awk '{print $2}'`
744 [ -z "$OSMLCM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
745 [ -z "$OSMLCM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret"
garciadeblas6c66abf2018-05-16 14:46:19 +0200746 track juju
garciadeblasa3e26612018-05-30 17:58:55 +0200747 [ -n "$INSTALL_NODOCKER" ] || install_docker_ce
garciadeblas6c66abf2018-05-16 14:46:19 +0200748 track docker_ce
garciadeblasd8bc5c32018-05-09 17:37:56 +0200749 #install_docker_compose
750 generate_docker_images
garciadeblas6c66abf2018-05-16 14:46:19 +0200751 track docker_build
garciadeblas5ef98212018-05-28 09:25:36 +0200752 generate_config_log_folders
garciadeblasd8bc5c32018-05-09 17:37:56 +0200753 generate_docker_env_files
754 deploy_lightweight
garciadeblas6c66abf2018-05-16 14:46:19 +0200755 track docker_deploy
756 [ -n "$INSTALL_VIMEMU" ] && install_vimemu && track vimemu
757 [ -n "$INSTALL_ELK" ] && deploy_elk && track elk
758 [ -n "$INSTALL_PERFMON" ] && deploy_perfmon && track perfmon
garciadeblasd8bc5c32018-05-09 17:37:56 +0200759 install_osmclient
garciadeblas6c66abf2018-05-16 14:46:19 +0200760 track osmclient
761 wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
762 track end
garciadeblasd8bc5c32018-05-09 17:37:56 +0200763 return 0
764}
765
766function install_vimemu() {
peusterm76353e42018-05-08 13:56:05 +0200767 echo "\nInstalling vim-emu"
768 EMUTEMPDIR="$(mktemp -d -q --tmpdir "installosmvimemu.XXXXXX")"
769 trap 'rm -rf "${EMUTEMPDIR}"' EXIT
garciadeblasd8bc5c32018-05-09 17:37:56 +0200770 # clone vim-emu repository (attention: branch is currently master only)
771 echo "Cloning vim-emu repository ..."
peusterm76353e42018-05-08 13:56:05 +0200772 git clone https://osm.etsi.org/gerrit/osm/vim-emu.git $EMUTEMPDIR
garciadeblasd8bc5c32018-05-09 17:37:56 +0200773 # build vim-emu docker
774 echo "Building vim-emu Docker container..."
garciadeblasc119fb32018-05-25 09:13:30 +0200775 sudo docker build -t vim-emu-img -f $EMUTEMPDIR/Dockerfile --no-cache $EMUTEMPDIR/ || FATAL "cannot build vim-emu-img docker image"
garciadeblasd8bc5c32018-05-09 17:37:56 +0200776 # start vim-emu container as daemon
777 echo "Starting vim-emu Docker container 'vim-emu' ..."
peusterm76353e42018-05-08 13:56:05 +0200778 if [ -n "$INSTALL_LIGHTWEIGHT" ]; then
779 # in lightweight mode, the emulator needs to be attached to netOSM
780 sudo docker run --name vim-emu -t -d --rm --privileged --pid='host' --network=netOSM -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py
781 else
782 # classic build mode
783 sudo docker run --name vim-emu -t -d --rm --privileged --pid='host' -v /var/run/docker.sock:/var/run/docker.sock vim-emu-img python examples/osm_default_daemon_topology_2_pop.py
784 fi
garciadeblasd8bc5c32018-05-09 17:37:56 +0200785 echo "Waiting for 'vim-emu' container to start ..."
786 sleep 5
787 export VIMEMU_HOSTNAME=$(sudo docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' vim-emu)
788 echo "vim-emu running at ${VIMEMU_HOSTNAME} ..."
peusterm76353e42018-05-08 13:56:05 +0200789 # print vim-emu connection info
790 echo -e "\nYou might be interested in adding the following vim-emu env variables to your .bashrc file:"
garciadeblasd8bc5c32018-05-09 17:37:56 +0200791 echo " export VIMEMU_HOSTNAME=${VIMEMU_HOSTNAME}"
peusterm76353e42018-05-08 13:56:05 +0200792 echo -e "To add the emulated VIM to OSM you should do:"
garciadeblasd8bc5c32018-05-09 17:37:56 +0200793 echo " osm vim-create --name emu-vim1 --user username --password password --auth_url http://${VIMEMU_HOSTNAME}:6001/v2.0 --tenant tenantName --account_type openstack"
794}
795
796function dump_vars(){
797 echo "DEVELOP=$DEVELOP"
798 echo "INSTALL_FROM_SOURCE=$INSTALL_FROM_SOURCE"
799 echo "UNINSTALL=$UNINSTALL"
800 echo "NAT=$NAT"
801 echo "UPDATE=$UPDATE"
802 echo "RECONFIGURE=$RECONFIGURE"
803 echo "TEST_INSTALLER=$TEST_INSTALLER"
804 echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
805 echo "INSTALL_LXD=$INSTALL_LXD"
806 echo "INSTALL_FROM_LXDIMAGES=$INSTALL_FROM_LXDIMAGES"
807 echo "LXD_REPOSITORY_BASE=$LXD_REPOSITORY_BASE"
808 echo "LXD_REPOSITORY_PATH=$LXD_REPOSITORY_PATH"
809 echo "INSTALL_LIGHTWEIGHT=$INSTALL_LIGHTWEIGHT"
garciadeblas6c66abf2018-05-16 14:46:19 +0200810 echo "INSTALL_ONLY=$INSTALL_ONLY"
811 echo "INSTALL_ELK=$INSTALL_ELK"
812 echo "INSTALL_PERFMON=$INSTALL_PERFMON"
garciadeblas0e596bc2018-05-28 16:04:42 +0200813 echo "TO_REBUILD=$TO_REBUILD"
garciadeblasd41f5482018-05-25 10:25:06 +0200814 echo "INSTALL_NOLXD=$INSTALL_NOLXD"
garciadeblasa3e26612018-05-30 17:58:55 +0200815 echo "INSTALL_NODOCKER=$INSTALL_NODOCKER"
garciadeblasd8bc5c32018-05-09 17:37:56 +0200816 echo "RELEASE=$RELEASE"
817 echo "REPOSITORY=$REPOSITORY"
818 echo "REPOSITORY_BASE=$REPOSITORY_BASE"
819 echo "REPOSITORY_KEY=$REPOSITORY_KEY"
820 echo "NOCONFIGURE=$NOCONFIGURE"
821 echo "SHOWOPTS=$SHOWOPTS"
822 echo "Install from specific refspec (-b): $COMMIT_ID"
823}
824
825function track(){
826 ctime=`date +%s`
827 duration=$((ctime - SESSION_ID))
828 url="http://www.woopra.com/track/ce?project=osm.etsi.org&cookie=${SESSION_ID}"
829 #url="${url}&ce_campaign_name=${CAMPAIGN_NAME}"
830 event_name="bin"
garciadeblas6c66abf2018-05-16 14:46:19 +0200831 [ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_SOURCE" ] && event_name="binsrc"
832 [ -z "$INSTALL_LIGHTWEIGHT" ] && [ -n "$INSTALL_FROM_LXDIMAGES" ] && event_name="lxd"
833 [ -n "$INSTALL_LIGHTWEIGHT" ] && event_name="lw"
garciadeblasd8bc5c32018-05-09 17:37:56 +0200834 event_name="${event_name}_$1"
835 url="${url}&event=${event_name}&ce_duration=${duration}"
836 wget -q -O /dev/null $url
837}
838
839UNINSTALL=""
840DEVELOP=""
841NAT=""
842UPDATE=""
843RECONFIGURE=""
844TEST_INSTALLER=""
845INSTALL_LXD=""
846SHOWOPTS=""
847COMMIT_ID=""
848ASSUME_YES=""
849INSTALL_FROM_SOURCE=""
garciadeblasfb566272018-05-25 10:33:36 +0200850RELEASE="-R ReleaseFOUR"
garciadeblasd8bc5c32018-05-09 17:37:56 +0200851REPOSITORY="-r stable"
852INSTALL_VIMEMU=""
853INSTALL_FROM_LXDIMAGES=""
854LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
855LXD_REPOSITORY_PATH=""
856INSTALL_LIGHTWEIGHT="y"
garciadeblas6c66abf2018-05-16 14:46:19 +0200857INSTALL_ONLY=""
858INSTALL_ELK=""
859INSTALL_PERFMON=""
garciadeblas0e596bc2018-05-28 16:04:42 +0200860TO_REBUILD=""
garciadeblasd41f5482018-05-25 10:25:06 +0200861INSTALL_NOLXD=""
garciadeblasa3e26612018-05-30 17:58:55 +0200862INSTALL_NODOCKER=""
garciadeblasd8bc5c32018-05-09 17:37:56 +0200863NOCONFIGURE=""
864RELEASE_DAILY=""
865SESSION_ID=`date +%s`
866OSM_DEVOPS=
867
garciadeblas0e596bc2018-05-28 16:04:42 +0200868while getopts ":hy-:b:r:k:u:R:l:p:D:o:m:" o; do
garciadeblasd8bc5c32018-05-09 17:37:56 +0200869 case "${o}" in
870 h)
871 usage && exit 0
872 ;;
873 b)
874 COMMIT_ID=${OPTARG}
875 ;;
876 r)
877 REPOSITORY="-r ${OPTARG}"
878 ;;
879 R)
880 RELEASE="-R ${OPTARG}"
881 ;;
882 k)
883 REPOSITORY_KEY="-k ${OPTARG}"
884 ;;
885 u)
886 REPOSITORY_BASE="-u ${OPTARG}"
887 ;;
888 l)
889 LXD_REPOSITORY_BASE="${OPTARG}"
890 ;;
891 p)
892 LXD_REPOSITORY_PATH="${OPTARG}"
893 ;;
894 D)
895 OSM_DEVOPS="${OPTARG}"
896 ;;
garciadeblas6c66abf2018-05-16 14:46:19 +0200897 o)
898 INSTALL_ONLY="y"
899 [ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
900 [ "${OPTARG}" == "elk_stack" ] && INSTALL_ELK="y" && continue
901 [ "${OPTARG}" == "pm_stack" ] && INSTALL_PERFMON="y" && continue
902 ;;
garciadeblas0e596bc2018-05-28 16:04:42 +0200903 m)
904 [ "${OPTARG}" == "RO" ] && TO_REBUILD="$TO_REBUILD RO" && continue
905 [ "${OPTARG}" == "LCM" ] && TO_REBUILD="$TO_REBUILD LCM" && continue
906 [ "${OPTARG}" == "NBI" ] && TO_REBUILD="$TO_REBUILD NBI" && continue
907 [ "${OPTARG}" == "LW-UI" ] && TO_REBUILD="$TO_REBUILD LW-UI" && continue
908 [ "${OPTARG}" == "MON" ] && TO_REBUILD="$TO_REBUILD MON" && continue
909 [ "${OPTARG}" == "KAFKA" ] && TO_REBUILD="$TO_REBUILD KAFKA" && continue
910 [ "${OPTARG}" == "MONGO" ] && TO_REBUILD="$TO_REBUILD MONGO" && continue
911 [ "${OPTARG}" == "NONE" ] && TO_REBUILD="$TO_REBUILD NONE" && continue
912 ;;
garciadeblasd8bc5c32018-05-09 17:37:56 +0200913 -)
914 [ "${OPTARG}" == "help" ] && usage && exit 0
915 [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && continue
916 [ "${OPTARG}" == "develop" ] && DEVELOP="y" && continue
917 [ "${OPTARG}" == "uninstall" ] && UNINSTALL="y" && continue
918 [ "${OPTARG}" == "nat" ] && NAT="y" && continue
919 [ "${OPTARG}" == "update" ] && UPDATE="y" && continue
920 [ "${OPTARG}" == "reconfigure" ] && RECONFIGURE="y" && continue
921 [ "${OPTARG}" == "test" ] && TEST_INSTALLER="y" && continue
922 [ "${OPTARG}" == "lxdinstall" ] && INSTALL_LXD="y" && continue
garciadeblasd41f5482018-05-25 10:25:06 +0200923 [ "${OPTARG}" == "nolxd" ] && INSTALL_NOLXD="y" && continue
garciadeblasa3e26612018-05-30 17:58:55 +0200924 [ "${OPTARG}" == "nodocker" ] && INSTALL_NODOCKER="y" && continue
garciadeblasd8bc5c32018-05-09 17:37:56 +0200925 [ "${OPTARG}" == "lxdimages" ] && INSTALL_FROM_LXDIMAGES="y" && continue
926 [ "${OPTARG}" == "lightweight" ] && INSTALL_LIGHTWEIGHT="y" && continue
garciadeblase990f662018-05-18 11:43:39 +0200927 [ "${OPTARG}" == "soui" ] && INSTALL_LIGHTWEIGHT="" && RELEASE="-R ReleaseTHREE" && REPOSITORY="-r stable" && continue
garciadeblasd8bc5c32018-05-09 17:37:56 +0200928 [ "${OPTARG}" == "vimemu" ] && INSTALL_VIMEMU="y" && continue
garciadeblas6c66abf2018-05-16 14:46:19 +0200929 [ "${OPTARG}" == "elk_stack" ] && INSTALL_ELK="y" && continue
930 [ "${OPTARG}" == "pm_stack" ] && INSTALL_PERFMON="y" && continue
garciadeblasd8bc5c32018-05-09 17:37:56 +0200931 [ "${OPTARG}" == "noconfigure" ] && NOCONFIGURE="y" && continue
932 [ "${OPTARG}" == "showopts" ] && SHOWOPTS="y" && continue
933 [ "${OPTARG}" == "daily" ] && RELEASE_DAILY="y" && continue
934 echo -e "Invalid option: '--$OPTARG'\n" >&2
935 usage && exit 1
936 ;;
937 \?)
938 echo -e "Invalid option: '-$OPTARG'\n" >&2
939 usage && exit 1
940 ;;
941 y)
942 ASSUME_YES="y"
943 ;;
944 *)
945 usage && exit 1
946 ;;
947 esac
948done
949
garciadeblas6c66abf2018-05-16 14:46:19 +0200950[ -n "$INSTALL_FROM_LXDIMAGES" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --lxd can only be used with --soui"
garciadeblase990f662018-05-18 11:43:39 +0200951[ -n "$NAT" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --nat can only be used with --soui"
952[ -n "$NOCONFIGURE" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --noconfigure can only be used with --soui"
garciadeblasfb566272018-05-25 10:33:36 +0200953[ -n "$RELEASE_DAILY" ] && [ -n "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible options: --daily can only be used with --soui"
garciadeblasd41f5482018-05-25 10:25:06 +0200954[ -n "$INSTALL_NOLXD" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: --nolxd cannot be used with --soui"
garciadeblasa3e26612018-05-30 17:58:55 +0200955[ -n "$INSTALL_NODOCKER" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: --nodocker cannot be used with --soui"
garciadeblas0e596bc2018-05-28 16:04:42 +0200956[ -n "$TO_REBUILD" ] && [ -z "$INSTALL_LIGHTWEIGHT" ] && FATAL "Incompatible option: -m cannot be used with --soui"
957[ -n "$TO_REBUILD" ] && [ "$TO_REBUILD" != " NONE" ] && echo $TO_REBUILD | grep -q NONE && FATAL "Incompatible option: -m NONE cannot be used with other -m options"
garciadeblas6c66abf2018-05-16 14:46:19 +0200958
garciadeblasd8bc5c32018-05-09 17:37:56 +0200959if [ -n "$SHOWOPTS" ]; then
960 dump_vars
961 exit 0
962fi
963
964[ -n "$RELEASE_DAILY" ] && echo -e "\nInstalling from daily build repo" && RELEASE="-R ReleaseTHREE-daily" && REPOSITORY="-r testing" && COMMIT_ID="master"
965
966# if develop, we force master
967[ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
968
969# forcing source from master removed. Now only install from source when explicit
970# [ -n "$COMMIT_ID" ] && [ "$COMMIT_ID" == "master" ] && INSTALL_FROM_SOURCE="y"
971
972if [ -z "$OSM_DEVOPS" ]; then
973 if [ -n "$TEST_INSTALLER" ]; then
974 echo -e "\nUsing local devops repo for OSM installation"
975 TEMPDIR="$(dirname $(realpath $(dirname $0)))"
976 else
977 echo -e "\nCreating temporary dir for OSM installation"
978 TEMPDIR="$(mktemp -d -q --tmpdir "installosm.XXXXXX")"
979 trap 'rm -rf "$TEMPDIR"' EXIT
980 fi
981fi
982
983need_packages="git jq wget curl tar"
984echo -e "Checking required packages: $need_packages"
985dpkg -l $need_packages &>/dev/null \
986 || ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
987 || sudo apt-get update \
988 || FATAL "failed to run apt-get update"
989dpkg -l $need_packages &>/dev/null \
990 || ! echo -e "Installing $need_packages requires root privileges." \
991 || sudo apt-get install -y $need_packages \
992 || FATAL "failed to install $need_packages"
993
994if [ -z "$OSM_DEVOPS" ]; then
995 if [ -z "$TEST_INSTALLER" ]; then
996 echo -e "\nCloning devops repo temporarily"
997 git clone https://osm.etsi.org/gerrit/osm/devops.git $TEMPDIR
998 RC_CLONE=$?
999 fi
1000
1001 echo -e "\nGuessing the current stable release"
1002 LATEST_STABLE_DEVOPS=`git -C $TEMPDIR tag -l v[0-9].* | sort -V | tail -n1`
1003 [ -z "$COMMIT_ID" ] && [ -z "$LATEST_STABLE_DEVOPS" ] && echo "Could not find the current latest stable release" && exit 0
1004 echo "Latest tag in devops repo: $LATEST_STABLE_DEVOPS"
1005 [ -z "$COMMIT_ID" ] && [ -n "$LATEST_STABLE_DEVOPS" ] && COMMIT_ID="tags/$LATEST_STABLE_DEVOPS"
1006
1007 if [ -n "$RELEASE_DAILY" ]; then
1008 echo "Using master/HEAD devops"
1009 git -C $TEMPDIR checkout master
1010 elif [ -z "$TEST_INSTALLER" ]; then
1011 git -C $TEMPDIR checkout tags/$LATEST_STABLE_DEVOPS
1012 fi
1013 OSM_DEVOPS=$TEMPDIR
1014fi
1015
1016OSM_JENKINS="$OSM_DEVOPS/jenkins"
1017. $OSM_JENKINS/common/all_funcs
1018
1019[ -n "$INSTALL_LIGHTWEIGHT" ] && [ -n "$UNINSTALL" ] && uninstall_lightweight && echo -e "\nDONE" && exit 0
1020[ -n "$UNINSTALL" ] && uninstall && echo -e "\nDONE" && exit 0
1021[ -n "$NAT" ] && nat && echo -e "\nDONE" && exit 0
1022[ -n "$UPDATE" ] && update && echo -e "\nDONE" && exit 0
1023[ -n "$RECONFIGURE" ] && configure && echo -e "\nDONE" && exit 0
garciadeblas6c66abf2018-05-16 14:46:19 +02001024[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_ELK" ] && deploy_elk
1025[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_PERFMON" ] && deploy_perfmon
1026[ -n "$INSTALL_ONLY" ] && [ -n "$INSTALL_VIMEMU" ] && install_vimemu
1027[ -n "$INSTALL_ONLY" ] && echo -e "\nDONE" && exit 0
garciadeblasd8bc5c32018-05-09 17:37:56 +02001028
1029#Installation starts here
garciadeblas6c66abf2018-05-16 14:46:19 +02001030wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README.txt &> /dev/null
1031track start
1032
garciadeblasd8bc5c32018-05-09 17:37:56 +02001033[ -n "$INSTALL_LIGHTWEIGHT" ] && install_lightweight && echo -e "\nDONE" && exit 0
1034echo -e "\nInstalling OSM from refspec: $COMMIT_ID"
1035if [ -n "$INSTALL_FROM_SOURCE" ] && [ -z "$ASSUME_YES" ]; then
1036 ! ask_user "The installation will take about 75-90 minutes. Continue (Y/n)? " y && echo "Cancelled!" && exit 1
1037fi
1038
1039echo -e "Checking required packages: lxd"
1040lxd --version &>/dev/null || FATAL "lxd not present, exiting."
1041[ -n "$INSTALL_LXD" ] && echo -e "\nInstalling and configuring lxd" && install_lxd
1042
garciadeblasd8bc5c32018-05-09 17:37:56 +02001043# use local devops for containers
1044export OSM_USE_LOCAL_DEVOPS=true
1045if [ -n "$INSTALL_FROM_SOURCE" ]; then #install from source
1046 echo -e "\nCreating the containers and building from source ..."
1047 $OSM_DEVOPS/jenkins/host/start_build RO --notest checkout $COMMIT_ID || FATAL "RO container build failed (refspec: '$COMMIT_ID')"
1048 ro_is_up && track RO
1049 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA container build failed"
1050 vca_is_up && track VCA
1051 $OSM_DEVOPS/jenkins/host/start_build MON || FATAL "MON install failed"
1052 mon_is_up && track MON
1053 $OSM_DEVOPS/jenkins/host/start_build SO checkout $COMMIT_ID || FATAL "SO container build failed (refspec: '$COMMIT_ID')"
1054 $OSM_DEVOPS/jenkins/host/start_build UI checkout $COMMIT_ID || FATAL "UI container build failed (refspec: '$COMMIT_ID')"
1055 #so_is_up && track SOUI
1056 track SOUI
1057elif [ -n "$INSTALL_FROM_LXDIMAGES" ]; then #install from LXD images stored in OSM repo
1058 echo -e "\nInstalling from lxd images ..."
1059 install_from_lxdimages
1060else #install from binaries
1061 echo -e "\nCreating the containers and installing from binaries ..."
1062 $OSM_DEVOPS/jenkins/host/install RO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "RO install failed"
1063 ro_is_up && track RO
1064 $OSM_DEVOPS/jenkins/host/start_build VCA || FATAL "VCA install failed"
1065 vca_is_up && track VCA
1066 $OSM_DEVOPS/jenkins/host/install MON || FATAL "MON build failed"
1067 mon_is_up && track MON
1068 $OSM_DEVOPS/jenkins/host/install SO $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "SO install failed"
1069 $OSM_DEVOPS/jenkins/host/install UI $REPOSITORY $RELEASE $REPOSITORY_KEY $REPOSITORY_BASE || FATAL "UI install failed"
1070 #so_is_up && track SOUI
1071 track SOUI
1072fi
1073
1074#Install iptables-persistent and configure NAT rules
1075[ -z "$NOCONFIGURE" ] && nat
1076
1077#Configure components
1078[ -z "$NOCONFIGURE" ] && configure
1079
1080#Install osmclient
1081[ -z "$NOCONFIGURE" ] && install_osmclient
1082
1083#Install vim-emu (optional)
peusterm76353e42018-05-08 13:56:05 +02001084[ -n "$INSTALL_VIMEMU" ] && install_docker_ce && install_vimemu
garciadeblasd8bc5c32018-05-09 17:37:56 +02001085
1086wget -q -O- https://osm-download.etsi.org/ftp/osm-4.0-four/README2.txt &> /dev/null
1087track end
1088echo -e "\nDONE"
1089