blob: 4dc5ef9b8e902be5569dbb870254acd9a5398303 [file] [log] [blame]
Victor Morales89ce3212017-06-16 18:32:48 -05001#!/bin/bash
2
3set -o xtrace
4
5source /var/onap/functions
6
Victor Moralesd618edd2017-09-18 14:57:12 -07007portal_src_folder=$git_src_folder/portal
8portal_repos=("sdk")
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -07009
10# clone_all_portal_repos() - Function that clones Portal source repo.
11function clone_all_portal_repos {
Victor Moralesd618edd2017-09-18 14:57:12 -070012 clone_repo portal $portal_src_folder
13 clone_repo ecompsdkos $portal_src_folder/ecompsdkos
14 clone_repo "ui/dmaapbc" $portal_src_folder/dmaapbc
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070015
Victor Moralesd618edd2017-09-18 14:57:12 -070016 for dirc in ${portal_repos[@]}; do
17 clone_repo portal/$dirc $portal_src_folder/$dirc
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070018 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 {
Victor Moralesd618edd2017-09-18 14:57:12 -070023 compile_src $portal_src_folder
Victor Morales89ce3212017-06-16 18:32:48 -050024
Victor Moralesd618edd2017-09-18 14:57:12 -070025 for dirc in ${portal_repos[@]}; do
26 compile_src $portal_src_folder/$dirc
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070027 done
28}
29
30# _build_portal_images() - Function that builds Portal Docker images from source code
31function _build_portal_images {
32 install_maven
33
Victor Moralesd618edd2017-09-18 14:57:12 -070034 pushd $portal_src_folder/deliveries
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070035 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
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070040 popd
41}
42
43# get_portal_images() - Function to get Portal images.
44function get_portal_images {
45 if [[ "$build_image" == "True" ]]; then
46 _build_portal_images
Victor Morales89ce3212017-06-16 18:32:48 -050047 else
48 pull_openecomp_image portaldb ecompdb:portal
49 pull_openecomp_image portalapps ep:1610-1
Victor Morales89ce3212017-06-16 18:32:48 -050050 fi
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070051 pull_docker_image mariadb
52}
Victor Moralesdd074802017-07-26 16:06:35 -050053
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070054# _install_mariadb() - Pull and create a MariaDB container
55function _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
60function install_portal {
61 install_docker
62 docker rm -f ecompdb_portal
63 docker rm -f 1610-1
64
Victor Moralesd618edd2017-09-18 14:57:12 -070065 pushd $portal_src_folder/deliveries
Victor Moralesdd074802017-07-26 16:06:35 -050066 mkdir -p /PROJECT/OpenSource/UbuntuEP/logs
67 install_package unzip
68 unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/
69
Victor Morales6a919972017-09-28 18:29:54 -070070 _install_mariadb
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070071 install_docker_compose
72 bash portal_vm_init.sh
Victor Moralesdd074802017-07-26 16:06:35 -050073
74 sleep 180
75
76 if [ ! -e /opt/config/boot.txt ]; then
Victor Moralesdd074802017-07-26 16:06:35 -050077 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
Victor Morales89ce3212017-06-16 18:32:48 -050082}
83
84# init_portal() - Function that initialize Portal services
85function init_portal {
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070086 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
Victor Morales6a919972017-09-28 18:29:54 -070092
93 if [[ "$skip_get_images" == "False" ]]; then
94 get_portal_images
95 if [[ "$skip_install" == "False" ]]; then
96 install_portal
97 fi
98 fi
Victor Morales89ce3212017-06-16 18:32:48 -050099}