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 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 5 | # clone_all_portal_repos() - Function that clones Portal source repo. |
| 6 | function clone_all_portal_repos { |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 7 | for repo in ${repos[portal]}; do |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 8 | if [[ "$repo" == "ui/dmaapbc" ]];then |
| 9 | prefix="ui" |
| 10 | else |
| 11 | prefix="portal" |
| 12 | fi |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 13 | clone_repo $repo ${src_folders[portal]}/${repo#*$prefix} |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 14 | done |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 15 | } |
| 16 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 17 | # compile_all_portal_repos() - Function that compiles Portal source repo. |
| 18 | function compile_all_portal_repos { |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 19 | for repo in ${repos[portal]}; do |
Victor Morales | 21404d7 | 2017-10-20 13:18:26 -0700 | [diff] [blame] | 20 | if [[ "$repo" == "ui/dmaapbc" ]];then |
| 21 | prefix="ui" |
| 22 | else |
| 23 | prefix="portal" |
| 24 | fi |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 25 | compile_src ${src_folders[portal]}/${repo#*$prefix} |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 26 | done |
| 27 | } |
| 28 | |
| 29 | # _build_portal_images() - Function that builds Portal Docker images from source code |
| 30 | function _build_portal_images { |
| 31 | install_maven |
| 32 | |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 33 | pushd ${src_folders[portal]}/deliveries |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 34 | 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 Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 39 | popd |
| 40 | } |
| 41 | |
| 42 | # get_portal_images() - Function to get Portal images. |
| 43 | function get_portal_images { |
| 44 | if [[ "$build_image" == "True" ]]; then |
| 45 | _build_portal_images |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 46 | else |
| 47 | pull_openecomp_image portaldb ecompdb:portal |
| 48 | pull_openecomp_image portalapps ep:1610-1 |
Victor Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 49 | fi |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 50 | pull_docker_image mariadb |
| 51 | } |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 52 | |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 53 | # _install_mariadb() - Pull and create a MariaDB container |
| 54 | function _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 |
| 59 | function install_portal { |
| 60 | install_docker |
| 61 | docker rm -f ecompdb_portal |
| 62 | docker rm -f 1610-1 |
| 63 | |
Victor Morales | 5464664 | 2017-12-08 11:57:42 -0800 | [diff] [blame] | 64 | pushd ${src_folders[portal]}/deliveries |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 65 | mkdir -p /PROJECT/OpenSource/UbuntuEP/logs |
| 66 | install_package unzip |
| 67 | unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/ |
| 68 | |
Victor Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 69 | _install_mariadb |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 70 | install_docker_compose |
| 71 | bash portal_vm_init.sh |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 72 | |
| 73 | sleep 180 |
| 74 | |
| 75 | if [ ! -e /opt/config/boot.txt ]; then |
Victor Morales | dd07480 | 2017-07-26 16:06:35 -0500 | [diff] [blame] | 76 | 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | # init_portal() - Function that initialize Portal services |
| 84 | function init_portal { |
Shashank Kumar Shankar | 9911e68 | 2017-08-17 15:43:17 -0700 | [diff] [blame] | 85 | 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 Morales | 6a91997 | 2017-09-28 18:29:54 -0700 | [diff] [blame] | 91 | |
| 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 Morales | 89ce321 | 2017-06-16 18:32:48 -0500 | [diff] [blame] | 98 | } |