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