aboutsummaryrefslogtreecommitdiffstats
path: root/bootstrap/vagrant-onap/lib/portal
blob: 915ccd59ad905bf3e7effeefcac0829a31ca76a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash

source /var/onap/functions

portal_src_folder=$git_src_folder/portal
portal_repos=("portal" "portal/sdk" "ecompsdkos" "ui/dmaapbc")

# clone_all_portal_repos() - Function that clones Portal source repo.
function clone_all_portal_repos {
    for repo in ${portal_repos[@]}; do
        if [[ "$repo" == "ui/dmaapbc" ]];then
            prefix="ui"
        else
            prefix="portal"
        fi
        clone_repo $repo $portal_src_folder/${repo#*$prefix}
    done
}

# compile_all_portal_repos() - Function that compiles Portal source repo.
function compile_all_portal_repos {
    for repo in ${portal_repos[@]}; do
        if [[ "$repo" == "ui/dmaapbc" ]];then
            prefix="ui"
        else
            prefix="portal"
        fi
        compile_src $portal_src_folder/${repo#*$prefix}
    done
}

# _build_portal_images() - Function that builds Portal Docker images from source code
function _build_portal_images {
    install_maven

    pushd $portal_src_folder/deliveries
    chmod +x *.sh
    export MVN=$(which mvn)
    export GLOBAL_SETTINGS_FILE=/usr/share/maven3/conf/settings.xml
    export SETTINGS_FILE=$HOME/.m2/settings.xml
    bash build_portalapps_dockers.sh
    popd
}

# get_portal_images() - Function to get Portal images.
function get_portal_images {
    if [[ "$build_image" == "True" ]]; then
        _build_portal_images
    else
        pull_openecomp_image portaldb ecompdb:portal
        pull_openecomp_image portalapps ep:1610-1
    fi
    pull_docker_image mariadb
}

# _install_mariadb() - Pull and create a MariaDB container
function _install_mariadb {
    docker create --name data_vol_portal -v /var/lib/mysql mariadb
}

# install_portal() - Function that installs the source code of Portal
function install_portal {
    install_docker
    docker rm -f ecompdb_portal
    docker rm -f 1610-1

    pushd $portal_src_folder/deliveries
    mkdir -p /PROJECT/OpenSource/UbuntuEP/logs
    install_package unzip
    unzip -o etc.zip -d /PROJECT/OpenSource/UbuntuEP/

    _install_mariadb
    install_docker_compose
    bash portal_vm_init.sh

    sleep 180

    if [ ! -e /opt/config/boot.txt ]; then
        install_package mysql-client
        mysql -u root -p'Aa123456' -h $IP_ADDRESS < Apps_Users_OnBoarding_Script.sql
        echo "yes" > /opt/config/boot.txt
    fi
    popd
}

# init_portal() - Function that initialize Portal services
function init_portal {
    if [[ "$clone_repo" == "True" ]]; then
        clone_all_portal_repos
        if [[ "$compile_repo" == "True" ]]; then
            compile_all_portal_repos
        fi
    fi

    if [[ "$skip_get_images" == "False" ]]; then
        get_portal_images
        if [[ "$skip_install" == "False" ]]; then
            install_portal
        fi
    fi
}