Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -o xtrace |
| 4 | |
| 5 | source /var/onap/functions |
| 6 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 7 | policy_src_folder=$git_src_folder/portal |
| 8 | policy_repos=("sdk") |
| 9 | |
| 10 | # clone_all_portal_repos() - Function that clones Portal source repo. |
| 11 | function clone_all_portal_repos { |
| 12 | clone_repo portal $policy_src_folder |
| 13 | clone_repo ecompsdkos $policy_src_folder/ecompsdkos |
| 14 | clone_repo "ui/dmaapbc" $policy_src_folder/dmaapbc |
| 15 | |
| 16 | for dirc in ${policy_repos[@]}; do |
| 17 | clone_repo portal/$dirc $policy_src_folder/$dirc |
| 18 | done |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 19 | } |
| 20 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 21 | # compile_all_portal_repos() - Function that compiles Portal source repo. |
| 22 | function compile_all_portal_repos { |
| 23 | compile_src $policy_src_folder |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 24 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 25 | for dirc in ${policy_repos[@]}; do |
| 26 | compile_src $policy_src_folder/$dirc |
| 27 | done |
| 28 | } |
| 29 | |
| 30 | # _build_portal_images() - Function that builds Portal Docker images from source code |
| 31 | function _build_portal_images { |
| 32 | install_maven |
| 33 | |
| 34 | pushd $policy_src_folder/deliveries |
| 35 | 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 |
| 40 | compile_src $policy_src_folder/ecomp-portal-widget-ms |
| 41 | build_docker_image $policy_src_folder/ecomp-portal-widget-ms |
| 42 | popd |
| 43 | } |
| 44 | |
| 45 | # get_portal_images() - Function to get Portal images. |
| 46 | function get_portal_images { |
| 47 | if [[ "$build_image" == "True" ]]; then |
| 48 | _build_portal_images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 49 | else |
| 50 | pull_openecomp_image portaldb ecompdb:portal |
| 51 | pull_openecomp_image portalapps ep:1610-1 |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 52 | fi |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 53 | pull_docker_image mariadb |
| 54 | } |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 55 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 56 | # _install_mariadb() - Pull and create a MariaDB container |
| 57 | function _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 |
| 62 | function install_portal { |
| 63 | install_docker |
| 64 | docker rm -f ecompdb_portal |
| 65 | docker rm -f 1610-1 |
| 66 | |
| 67 | pushd $policy_src_folder/deliveries |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 68 | mkdir -p /PROJECT/OpenSource/UbuntuEP/logs |
| 69 | install_package unzip |
| 70 | unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/ |
| 71 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 72 | install_docker_compose |
| 73 | bash portal_vm_init.sh |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 74 | |
| 75 | sleep 180 |
| 76 | |
| 77 | if [ ! -e /opt/config/boot.txt ]; then |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 78 | install_package mysql-client |
| 79 | mysql -u root -p'Aa123456' -h $IP_ADDRESS < Apps_Users_OnBoarding_Script.sql |
| 80 | echo "yes" > /opt/config/boot.txt |
| 81 | fi |
| 82 | popd |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | # init_portal() - Function that initialize Portal services |
| 86 | function init_portal { |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 87 | if [[ "$clone_repo" == "True" ]]; then |
| 88 | clone_all_portal_repos |
| 89 | if [[ "$compile_repo" == "True" ]]; then |
| 90 | compile_all_portal_repos |
| 91 | fi |
| 92 | fi |
| 93 | get_portal_images |
| 94 | _install_mariadb |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 95 | install_portal |
| 96 | } |