Merge "Add csit usecase for ems."
[integration.git] / bootstrap / vagrant-onap / lib / portal
1 #!/bin/bash
2
3 set -o xtrace
4
5 source /var/onap/functions
6
7 portal_src_folder=$git_src_folder/portal
8 portal_repos=("sdk")
9
10 # clone_all_portal_repos() - Function that clones Portal source repo.
11 function clone_all_portal_repos {
12     clone_repo portal $portal_src_folder
13     clone_repo ecompsdkos $portal_src_folder/ecompsdkos
14     clone_repo "ui/dmaapbc" $portal_src_folder/dmaapbc
15
16     for dirc in ${portal_repos[@]}; do
17         clone_repo portal/$dirc $portal_src_folder/$dirc
18     done
19 }
20
21 # compile_all_portal_repos() - Function that compiles Portal source repo.
22 function compile_all_portal_repos {
23     compile_src $portal_src_folder
24
25     for dirc in ${portal_repos[@]}; do
26         compile_src $portal_src_folder/$dirc
27     done
28 }
29
30 # _build_portal_images() - Function that builds Portal Docker images from source code
31 function _build_portal_images {
32     install_maven
33
34     pushd $portal_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     popd
41 }
42
43 # get_portal_images() - Function to get Portal images.
44 function get_portal_images {
45     if [[ "$build_image" == "True" ]]; then
46         _build_portal_images
47     else
48         pull_openecomp_image portaldb ecompdb:portal
49         pull_openecomp_image portalapps ep:1610-1
50     fi
51     pull_docker_image mariadb
52 }
53
54 # _install_mariadb() - Pull and create a MariaDB container
55 function _install_mariadb {
56     docker create --name data_vol_portal -v /var/lib/mysql mariadb
57 }
58
59 # install_portal() - Function that installs the source code of Portal
60 function install_portal {
61     install_docker
62     docker rm -f ecompdb_portal
63     docker rm -f 1610-1
64
65     pushd $portal_src_folder/deliveries
66     mkdir -p /PROJECT/OpenSource/UbuntuEP/logs
67     install_package unzip
68     unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/
69
70     _install_mariadb
71     install_docker_compose
72     bash portal_vm_init.sh
73
74     sleep 180
75
76     if [ ! -e /opt/config/boot.txt ]; then
77         install_package mysql-client
78         mysql -u root -p'Aa123456' -h $IP_ADDRESS < Apps_Users_OnBoarding_Script.sql
79         echo "yes" > /opt/config/boot.txt
80     fi
81     popd
82 }
83
84 # init_portal() - Function that initialize Portal services
85 function init_portal {
86     if [[ "$clone_repo" == "True" ]]; then
87         clone_all_portal_repos
88         if [[ "$compile_repo" == "True" ]]; then
89             compile_all_portal_repos
90         fi
91     fi
92
93     if [[ "$skip_get_images" == "False" ]]; then
94         get_portal_images
95         if [[ "$skip_install" == "False" ]]; then
96             install_portal
97         fi
98     fi
99 }