blob: b5e768b2c5584874519be72f5f99714b5f2e1e3d [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
Victor Morales21404d72017-10-20 13:18:26 -07008portal_repos=("portal" "portal/sdk" "ecompsdkos" "ui/dmaapbc")
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 Morales21404d72017-10-20 13:18:26 -070012 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}
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070019 done
Victor Morales89ce3212017-06-16 18:32:48 -050020}
21
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070022# compile_all_portal_repos() - Function that compiles Portal source repo.
23function compile_all_portal_repos {
Victor Morales21404d72017-10-20 13:18:26 -070024 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}
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070031 done
32}
33
34# _build_portal_images() - Function that builds Portal Docker images from source code
35function _build_portal_images {
36 install_maven
37
Victor Moralesd618edd2017-09-18 14:57:12 -070038 pushd $portal_src_folder/deliveries
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070039 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
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070044 popd
45}
46
47# get_portal_images() - Function to get Portal images.
48function get_portal_images {
49 if [[ "$build_image" == "True" ]]; then
50 _build_portal_images
Victor Morales89ce3212017-06-16 18:32:48 -050051 else
52 pull_openecomp_image portaldb ecompdb:portal
53 pull_openecomp_image portalapps ep:1610-1
Victor Morales89ce3212017-06-16 18:32:48 -050054 fi
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070055 pull_docker_image mariadb
56}
Victor Moralesdd074802017-07-26 16:06:35 -050057
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070058# _install_mariadb() - Pull and create a MariaDB container
59function _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
64function install_portal {
65 install_docker
66 docker rm -f ecompdb_portal
67 docker rm -f 1610-1
68
Victor Moralesd618edd2017-09-18 14:57:12 -070069 pushd $portal_src_folder/deliveries
Victor Moralesdd074802017-07-26 16:06:35 -050070 mkdir -p /PROJECT/OpenSource/UbuntuEP/logs
71 install_package unzip
72 unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/
73
Victor Morales6a919972017-09-28 18:29:54 -070074 _install_mariadb
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070075 install_docker_compose
76 bash portal_vm_init.sh
Victor Moralesdd074802017-07-26 16:06:35 -050077
78 sleep 180
79
80 if [ ! -e /opt/config/boot.txt ]; then
Victor Moralesdd074802017-07-26 16:06:35 -050081 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
Victor Morales89ce3212017-06-16 18:32:48 -050086}
87
88# init_portal() - Function that initialize Portal services
89function init_portal {
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070090 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
Victor Morales6a919972017-09-28 18:29:54 -070096
97 if [[ "$skip_get_images" == "False" ]]; then
98 get_portal_images
99 if [[ "$skip_install" == "False" ]]; then
100 install_portal
101 fi
102 fi
Victor Morales89ce3212017-06-16 18:32:48 -0500103}