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