blob: 505bdde0cee243a35e1f4602f40c2e1b7ed55126 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
5source /var/onap/functions
6
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -07007policy_src_folder=$git_src_folder/portal
8policy_repos=("sdk")
9
10# clone_all_portal_repos() - Function that clones Portal source repo.
11function clone_all_portal_repos {
12 clone_repo portal $policy_src_folder
13 clone_repo ecompsdkos $policy_src_folder/ecompsdkos
14 clone_repo "ui/dmaapbc" $policy_src_folder/dmaapbc
15
16 for dirc in ${policy_repos[@]}; do
17 clone_repo portal/$dirc $policy_src_folder/$dirc
18 done
Victor Morales89ce3212017-06-16 18:32:48 -050019}
20
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070021# compile_all_portal_repos() - Function that compiles Portal source repo.
22function compile_all_portal_repos {
23 compile_src $policy_src_folder
Victor Morales89ce3212017-06-16 18:32:48 -050024
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070025 for dirc in ${policy_repos[@]}; do
26 compile_src $policy_src_folder/$dirc
27 done
28}
29
30# _build_portal_images() - Function that builds Portal Docker images from source code
31function _build_portal_images {
32 install_maven
33
34 pushd $policy_src_folder/deliveries
35 chmod +x *.sh
36 export MVN=$(which mvn)
37 export GLOBAL_SETTINGS_FILE=/usr/share/maven3/conf/settings.xml
38 export SETTINGS_FILE=$HOME/.m2/settings.xml
39 bash build_portalapps_dockers.sh
40 compile_src $policy_src_folder/ecomp-portal-widget-ms
41 build_docker_image $policy_src_folder/ecomp-portal-widget-ms
42 popd
43}
44
45# get_portal_images() - Function to get Portal images.
46function get_portal_images {
47 if [[ "$build_image" == "True" ]]; then
48 _build_portal_images
Victor Morales89ce3212017-06-16 18:32:48 -050049 else
50 pull_openecomp_image portaldb ecompdb:portal
51 pull_openecomp_image portalapps ep:1610-1
Victor Morales89ce3212017-06-16 18:32:48 -050052 fi
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070053 pull_docker_image mariadb
54}
Victor Moralesdd074802017-07-26 16:06:35 -050055
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070056# _install_mariadb() - Pull and create a MariaDB container
57function _install_mariadb {
58 docker create --name data_vol_portal -v /var/lib/mysql mariadb
59}
60
61# install_portal() - Function that installs the source code of Portal
62function install_portal {
63 install_docker
64 docker rm -f ecompdb_portal
65 docker rm -f 1610-1
66
67 pushd $policy_src_folder/deliveries
Victor Moralesdd074802017-07-26 16:06:35 -050068 mkdir -p /PROJECT/OpenSource/UbuntuEP/logs
69 install_package unzip
70 unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/
71
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070072 install_docker_compose
73 bash portal_vm_init.sh
Victor Moralesdd074802017-07-26 16:06:35 -050074
75 sleep 180
76
77 if [ ! -e /opt/config/boot.txt ]; then
Victor Moralesdd074802017-07-26 16:06:35 -050078 install_package mysql-client
79 mysql -u root -p'Aa123456' -h $IP_ADDRESS < Apps_Users_OnBoarding_Script.sql
80 echo "yes" > /opt/config/boot.txt
81 fi
82 popd
Victor Morales89ce3212017-06-16 18:32:48 -050083}
84
85# init_portal() - Function that initialize Portal services
86function init_portal {
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070087 if [[ "$clone_repo" == "True" ]]; then
88 clone_all_portal_repos
89 if [[ "$compile_repo" == "True" ]]; then
90 compile_all_portal_repos
91 fi
92 fi
93 get_portal_images
94 _install_mariadb
Victor Morales89ce3212017-06-16 18:32:48 -050095 install_portal
96}