Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 3 | source /var/onap/functions |
| 4 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 5 | portal_src_folder=$git_src_folder/portal |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 6 | portal_repos=("portal" "portal/sdk" "ecompsdkos" "ui/dmaapbc") |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 7 | |
| 8 | # clone_all_portal_repos() - Function that clones Portal source repo. |
| 9 | function clone_all_portal_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 10 | for repo in ${portal_repos[@]}; do |
| 11 | if [[ "$repo" == "ui/dmaapbc" ]];then |
| 12 | prefix="ui" |
| 13 | else |
| 14 | prefix="portal" |
| 15 | fi |
| 16 | clone_repo $repo $portal_src_folder/${repo#*$prefix} |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 17 | done |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 18 | } |
| 19 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 20 | # compile_all_portal_repos() - Function that compiles Portal source repo. |
| 21 | function compile_all_portal_repos { |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 22 | for repo in ${portal_repos[@]}; do |
| 23 | if [[ "$repo" == "ui/dmaapbc" ]];then |
| 24 | prefix="ui" |
| 25 | else |
| 26 | prefix="portal" |
| 27 | fi |
| 28 | compile_src $portal_src_folder/${repo#*$prefix} |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 29 | done |
| 30 | } |
| 31 | |
| 32 | # _build_portal_images() - Function that builds Portal Docker images from source code |
| 33 | function _build_portal_images { |
| 34 | install_maven |
| 35 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 36 | pushd $portal_src_folder/deliveries |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 37 | chmod +x *.sh |
| 38 | export MVN=$(which mvn) |
| 39 | export GLOBAL_SETTINGS_FILE=/usr/share/maven3/conf/settings.xml |
| 40 | export SETTINGS_FILE=$HOME/.m2/settings.xml |
| 41 | bash build_portalapps_dockers.sh |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 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 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 67 | pushd $portal_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 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 72 | _install_mariadb |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 73 | install_docker_compose |
| 74 | bash portal_vm_init.sh |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 75 | |
| 76 | sleep 180 |
| 77 | |
| 78 | if [ ! -e /opt/config/boot.txt ]; then |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 79 | install_package mysql-client |
| 80 | mysql -u root -p'Aa123456' -h $IP_ADDRESS < Apps_Users_OnBoarding_Script.sql |
| 81 | echo "yes" > /opt/config/boot.txt |
| 82 | fi |
| 83 | popd |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | # init_portal() - Function that initialize Portal services |
| 87 | function init_portal { |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 88 | if [[ "$clone_repo" == "True" ]]; then |
| 89 | clone_all_portal_repos |
| 90 | if [[ "$compile_repo" == "True" ]]; then |
| 91 | compile_all_portal_repos |
| 92 | fi |
| 93 | fi |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 94 | |
| 95 | if [[ "$skip_get_images" == "False" ]]; then |
| 96 | get_portal_images |
| 97 | if [[ "$skip_install" == "False" ]]; then |
| 98 | install_portal |
| 99 | fi |
| 100 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 101 | } |