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 |
| 8 | portal_repos=("sdk") |
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 | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 12 | clone_repo portal $portal_src_folder |
| 13 | clone_repo ecompsdkos $portal_src_folder/ecompsdkos |
| 14 | clone_repo "ui/dmaapbc" $portal_src_folder/dmaapbc |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 15 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 16 | for dirc in ${portal_repos[@]}; do |
| 17 | clone_repo portal/$dirc $portal_src_folder/$dirc |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 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 { |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 23 | compile_src $portal_src_folder |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 24 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 25 | for dirc in ${portal_repos[@]}; do |
| 26 | compile_src $portal_src_folder/$dirc |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 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 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 34 | pushd $portal_src_folder/deliveries |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 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 |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 40 | popd |
| 41 | } |
| 42 | |
| 43 | # get_portal_images() - Function to get Portal images. |
| 44 | function get_portal_images { |
| 45 | if [[ "$build_image" == "True" ]]; then |
| 46 | _build_portal_images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 47 | else |
| 48 | pull_openecomp_image portaldb ecompdb:portal |
| 49 | pull_openecomp_image portalapps ep:1610-1 |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 50 | fi |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 51 | pull_docker_image mariadb |
| 52 | } |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 53 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 54 | # _install_mariadb() - Pull and create a MariaDB container |
| 55 | function _install_mariadb { |
| 56 | docker create --name data_vol_portal -v /var/lib/mysql mariadb |
| 57 | } |
| 58 | |
| 59 | # install_portal() - Function that installs the source code of Portal |
| 60 | function install_portal { |
| 61 | install_docker |
| 62 | docker rm -f ecompdb_portal |
| 63 | docker rm -f 1610-1 |
| 64 | |
Victor Morales | d618edd | 2017-09-18 14:57:12 -0700 | [diff] [blame] | 65 | pushd $portal_src_folder/deliveries |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 66 | mkdir -p /PROJECT/OpenSource/UbuntuEP/logs |
| 67 | install_package unzip |
| 68 | unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/ |
| 69 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 70 | _install_mariadb |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 71 | install_docker_compose |
| 72 | bash portal_vm_init.sh |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 73 | |
| 74 | sleep 180 |
| 75 | |
| 76 | if [ ! -e /opt/config/boot.txt ]; then |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 77 | install_package mysql-client |
| 78 | mysql -u root -p'Aa123456' -h $IP_ADDRESS < Apps_Users_OnBoarding_Script.sql |
| 79 | echo "yes" > /opt/config/boot.txt |
| 80 | fi |
| 81 | popd |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | # init_portal() - Function that initialize Portal services |
| 85 | function init_portal { |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 86 | if [[ "$clone_repo" == "True" ]]; then |
| 87 | clone_all_portal_repos |
| 88 | if [[ "$compile_repo" == "True" ]]; then |
| 89 | compile_all_portal_repos |
| 90 | fi |
| 91 | fi |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 92 | |
| 93 | if [[ "$skip_get_images" == "False" ]]; then |
| 94 | get_portal_images |
| 95 | if [[ "$skip_install" == "False" ]]; then |
| 96 | install_portal |
| 97 | fi |
| 98 | fi |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 99 | } |