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 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 7 | portal_src_folder=$git_src_folder/portal |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 8 | portal_repos=("portal" "portal/sdk" "ecompsdkos" "ui/dmaapbc") |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 9 | |
| 10 | # clone_all_portal_repos() - Function that clones Portal source repo. |
| 11 | function clone_all_portal_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 12 | 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 Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 19 | done |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 20 | } |
| 21 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 22 | # compile_all_portal_repos() - Function that compiles Portal source repo. |
| 23 | function compile_all_portal_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 24 | 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 Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 31 | done |
| 32 | } |
| 33 | |
| 34 | # _build_portal_images() - Function that builds Portal Docker images from source code |
| 35 | function _build_portal_images { |
| 36 | install_maven |
| 37 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 38 | pushd $portal_src_folder/deliveries |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 39 | 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 Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 44 | popd |
| 45 | } |
| 46 | |
| 47 | # get_portal_images() - Function to get Portal images. |
| 48 | function get_portal_images { |
| 49 | if [[ "$build_image" == "True" ]]; then |
| 50 | _build_portal_images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 51 | else |
| 52 | pull_openecomp_image portaldb ecompdb:portal |
| 53 | pull_openecomp_image portalapps ep:1610-1 |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 54 | fi |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 55 | pull_docker_image mariadb |
| 56 | } |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 57 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 58 | # _install_mariadb() - Pull and create a MariaDB container |
| 59 | function _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 |
| 64 | function install_portal { |
| 65 | install_docker |
| 66 | docker rm -f ecompdb_portal |
| 67 | docker rm -f 1610-1 |
| 68 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 69 | pushd $portal_src_folder/deliveries |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 70 | mkdir -p /PROJECT/OpenSource/UbuntuEP/logs |
| 71 | install_package unzip |
| 72 | unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/ |
| 73 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 74 | _install_mariadb |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 75 | install_docker_compose |
| 76 | bash portal_vm_init.sh |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 77 | |
| 78 | sleep 180 |
| 79 | |
| 80 | if [ ! -e /opt/config/boot.txt ]; then |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 81 | 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | # init_portal() - Function that initialize Portal services |
| 89 | function init_portal { |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 90 | 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 Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 96 | |
| 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 103 | } |