blob: fe546982246440cdaec92b807494ab6a4091b9ac [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
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -07005# clone_all_portal_repos() - Function that clones Portal source repo.
6function clone_all_portal_repos {
Victor Morales54646642017-12-08 11:57:42 -08007 for repo in ${repos[portal]}; do
Victor Morales21404d72017-10-20 13:18:26 -07008 if [[ "$repo" == "ui/dmaapbc" ]];then
9 prefix="ui"
10 else
11 prefix="portal"
12 fi
Victor Morales54646642017-12-08 11:57:42 -080013 clone_repo $repo ${src_folders[portal]}/${repo#*$prefix}
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070014 done
Victor Morales89ce3212017-06-16 18:32:48 -050015}
16
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070017# compile_all_portal_repos() - Function that compiles Portal source repo.
18function compile_all_portal_repos {
Victor Morales54646642017-12-08 11:57:42 -080019 for repo in ${repos[portal]}; do
Victor Morales21404d72017-10-20 13:18:26 -070020 if [[ "$repo" == "ui/dmaapbc" ]];then
21 prefix="ui"
22 else
23 prefix="portal"
24 fi
Victor Morales54646642017-12-08 11:57:42 -080025 compile_src ${src_folders[portal]}/${repo#*$prefix}
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070026 done
27}
28
29# _build_portal_images() - Function that builds Portal Docker images from source code
30function _build_portal_images {
31 install_maven
32
Victor Morales54646642017-12-08 11:57:42 -080033 pushd ${src_folders[portal]}/deliveries
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070034 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
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070039 popd
40}
41
42# get_portal_images() - Function to get Portal images.
43function get_portal_images {
44 if [[ "$build_image" == "True" ]]; then
45 _build_portal_images
Victor Morales89ce3212017-06-16 18:32:48 -050046 else
47 pull_openecomp_image portaldb ecompdb:portal
48 pull_openecomp_image portalapps ep:1610-1
Victor Morales89ce3212017-06-16 18:32:48 -050049 fi
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070050 pull_docker_image mariadb
51}
Victor Moralesdd074802017-07-26 16:06:35 -050052
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070053# _install_mariadb() - Pull and create a MariaDB container
54function _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
59function install_portal {
60 install_docker
61 docker rm -f ecompdb_portal
62 docker rm -f 1610-1
63
Victor Morales54646642017-12-08 11:57:42 -080064 pushd ${src_folders[portal]}/deliveries
Victor Moralesdd074802017-07-26 16:06:35 -050065 mkdir -p /PROJECT/OpenSource/UbuntuEP/logs
66 install_package unzip
67 unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/
68
Victor Morales6a919972017-09-28 18:29:54 -070069 _install_mariadb
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070070 install_docker_compose
71 bash portal_vm_init.sh
Victor Moralesdd074802017-07-26 16:06:35 -050072
73 sleep 180
74
75 if [ ! -e /opt/config/boot.txt ]; then
Victor Moralesdd074802017-07-26 16:06:35 -050076 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
Victor Morales89ce3212017-06-16 18:32:48 -050081}
82
83# init_portal() - Function that initialize Portal services
84function init_portal {
Shashank Kumar Shankar9911e682017-08-17 15:43:17 -070085 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
Victor Morales6a919972017-09-28 18:29:54 -070091
92 if [[ "$skip_get_images" == "False" ]]; then
93 get_portal_images
94 if [[ "$skip_install" == "False" ]]; then
95 install_portal
96 fi
97 fi
Victor Morales89ce3212017-06-16 18:32:48 -050098}