summaryrefslogtreecommitdiffstats
path: root/utils/webseal-simulator/scripts/simulator_docker_run.sh
blob: 51fc082e248c2d158813052611842d012e7fdf82 (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
102
103
104
105
#!/bin/bash

export PREFIX=${NEXUS_DOCKER_REPO}'/onap'
PREFIX='onap'
RELEASE=latest
LOCAL=true
JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m"

[ -f ${WORKSPACE}/opt/config/env_name.txt ] && DEP_ENV=$(cat ${WORKSPACE}/opt/config/env_name.txt)
[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat ${WORKSPACE}/opt/config/nexus_username.txt)    || NEXUS_USERNAME=release
[ -f ${WORKSPACE}/opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat ${WORKSPACE}/opt/config/nexus_password.txt)      || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW
[ -f ${WORKSPACE}/opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat ${WORKSPACE}/opt/config/nexus_docker_repo.txt)

function usage {
    cat <<EOF
usage: simulator_docker_run.sh [-e <ENV-NAME>] [-r <RELEASE-NAME>] [-u <FE-URL>][-h]
Optional arguments:
    -e, --environment
        Environment Name
    -r, --release
        Release Name
    -u, --fe_url
        frontend server url
    -h, --help
        Help
EOF
}

function cleanup {
    echo "performing old dockers cleanup"
    for old_container in $(docker ps -a | egrep "onap/sdc-simulator|Exit" | awk '{print $1}'); do
       docker rm -f ${old_container}
    done
}

function dir_perms {
    mkdir -p ${WORKSPACE}/data/logs/WS/
    chmod -R 777 ${WORKSPACE}/data/logs
}

while getopts "r:e:u:-:" OPTION "${@}"; do
    case $OPTION in
        r)
            shift
            RELEASE=${1}
            ;;
        e)
            shift
            DEP_ENV=${1}
            ;;
        u)
            shift
            FE_URL=${1}
            ;;
        -) # Workaround to support long option names
            case "${OPTARG}" in
                release)
                    shift
                    RELEASE=${1}
                    ;;
                environment)
                    shift
                    DEP_ENV=${1}
                    ;;
                fe_url)
                    shift
                    FE_URL=${1}
                    ;;
            esac
            ;;
        ?)
            usage
            exit
            ;;
        *)
            usage
            exit 1
    esac
    shift
done

[ -f ${WORKSPACE}/opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO

cleanup


dir_perms
echo ${FE_URL}
# SDC-Simulator
docker run --detach --name sdc-sim \
    --env FE_URL="${FE_URL}" \
    --env JAVA_OPTIONS="${JAVA_OPTIONS}" \
    --env ENVNAME="${DEP_ENV}" \
    --env http_proxy=${http_proxy} \
    --env https_proxy=${https_proxy} \
    --env no_proxy=${no_proxy} \
    --volume /etc/localtime:/etc/localtime:ro \
    --volume ${WORKSPACE}/data/logs/WS/:/var/lib/jetty/logs \
    --volume ${WORKSPACE}/data/environments:/root/chef-solo/environments \
    --publish 8285:8080 \
    --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE}

if [ $? -ne 0 ]; then
    exit 1
fi