blob: 915ccd59ad905bf3e7effeefcac0829a31ca76a3 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
Victor Morales89ce3212017-06-16 18:32:48 -05003source /var/onap/functions
4
Victor Moralesd618edd2017-09-18 14:57:12 -07005portal_src_folder=$git_src_folder/portal
Victor Morales21404d72017-10-20 13:18:26 -07006portal_repos=("portal" "portal/sdk" "ecompsdkos" "ui/dmaapbc")
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -07007
8# clone_all_portal_repos() - Function that clones Portal source repo.
9function clone_all_portal_repos {
Victor Morales21404d72017-10-20 13:18:26 -070010 for repo in ${portal_repos[@]}; do
11 if [[ "$repo" == "ui/dmaapbc" ]];then
12 prefix="ui"
13 else
14 prefix="portal"
15 fi
16 clone_repo $repo $portal_src_folder/${repo#*$prefix}
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070017 done
Victor Morales89ce3212017-06-16 18:32:48 -050018}
19
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070020# compile_all_portal_repos() - Function that compiles Portal source repo.
21function compile_all_portal_repos {
Victor Morales21404d72017-10-20 13:18:26 -070022 for repo in ${portal_repos[@]}; do
23 if [[ "$repo" == "ui/dmaapbc" ]];then
24 prefix="ui"
25 else
26 prefix="portal"
27 fi
28 compile_src $portal_src_folder/${repo#*$prefix}
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070029 done
30}
31
32# _build_portal_images() - Function that builds Portal Docker images from source code
33function _build_portal_images {
34 install_maven
35
Victor Moralesd618edd2017-09-18 14:57:12 -070036 pushd $portal_src_folder/deliveries
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070037 chmod +x *.sh
38 export MVN=$(which mvn)
39 export GLOBAL_SETTINGS_FILE=/usr/share/maven3/conf/settings.xml
40 export SETTINGS_FILE=$HOME/.m2/settings.xml
41 bash build_portalapps_dockers.sh
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070042 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
Victor Moralesd618edd2017-09-18 14:57:12 -070067 pushd $portal_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
Victor Morales6a919972017-09-28 18:29:54 -070072 _install_mariadb
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070073 install_docker_compose
74 bash portal_vm_init.sh
Victor Moralesdd074802017-07-26 16:06:35 -050075
76 sleep 180
77
78 if [ ! -e /opt/config/boot.txt ]; then
Victor Moralesdd074802017-07-26 16:06:35 -050079 install_package mysql-client
80 mysql -u root -p'Aa123456' -h $IP_ADDRESS < Apps_Users_OnBoarding_Script.sql
81 echo "yes" > /opt/config/boot.txt
82 fi
83 popd
Victor Morales89ce3212017-06-16 18:32:48 -050084}
85
86# init_portal() - Function that initialize Portal services
87function init_portal {
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070088 if [[ "$clone_repo" == "True" ]]; then
89 clone_all_portal_repos
90 if [[ "$compile_repo" == "True" ]]; then
91 compile_all_portal_repos
92 fi
93 fi
Victor Morales6a919972017-09-28 18:29:54 -070094
95 if [[ "$skip_get_images" == "False" ]]; then
96 get_portal_images
97 if [[ "$skip_install" == "False" ]]; then
98 install_portal
99 fi
100 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500101}