diff options
Diffstat (limited to 'utils')
-rwxr-xr-x[-rw-r--r--] | utils/webseal-simulator/scripts/simulator_docker_run.sh | 118 |
1 files changed, 71 insertions, 47 deletions
diff --git a/utils/webseal-simulator/scripts/simulator_docker_run.sh b/utils/webseal-simulator/scripts/simulator_docker_run.sh index 0bcd30bb3d..20f224a1b2 100644..100755 --- a/utils/webseal-simulator/scripts/simulator_docker_run.sh +++ b/utils/webseal-simulator/scripts/simulator_docker_run.sh @@ -1,54 +1,80 @@ #!/bin/bash +export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` +export PREFIX=${NEXUS_DOCKER_REPO}'/onap' +PREFIX='onap' +RELEASE=latest +LOCAL=true +JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m" + +[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) +[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release +[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW +[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) function usage { - echo "usage: simulator_docker_run.sh [ -r|--release <RELEASE-NAME> ] [ -e|--environment <ENV-NAME> ] [ -p|--port <Docker-hub-port>] [ -h|--help ]" + cat <<EOF +usage: simulator_docker_run.sh [-e <ENV-NAME>] [-r <RELEASE-NAME>] [-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" - docker_ids=`docker ps -a | egrep "onap/sdc-simulator|Exit" | awk '{print $1}'` - for X in ${docker_ids} - do - docker rm -f ${X} - done + 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 /data/logs/WS/ - chmod -R 777 /data/logs + mkdir -p /data/logs/WS/ + chmod -R 777 /data/logs } - -RELEASE=latest -LOCAL=true -[ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ -[ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release -[ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW -[ -f /opt/config/nexus_docker_repo.txt ] && NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) || NEXUS_DOCKER_REPO=ecomp-nexus:${PORT} - -while [ "$1" != "" ]; do - case $1 in - -r | --release ) +while getopts "r:e:u:-:" OPTION "${@}"; do + case $OPTION in + r) shift RELEASE=${1} ;; - -e | --environment ) - shift + e) + shift DEP_ENV=${1} ;; - -p | --port ) + u) shift - PORT=${1} - ;; - -h | --help ) - usage + 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 + *) + usage exit 1 esac shift @@ -56,27 +82,25 @@ done [ -f /opt/config/nexus_username.txt ] && docker login -u $NEXUS_USERNAME -p $NEXUS_PASSWD $NEXUS_DOCKER_REPO - cleanup -export IP=`ifconfig eth0 | awk -F: '/inet addr/ {gsub(/ .*/,"",$2); print $2}'` -export PREFIX=${NEXUS_DOCKER_REPO}'/onap' - -PREFIX='onap' - -echo "" -echo "${PREFIX}" - dir_perms - -JAVA_OPTIONS=" -Xmx128m -Xms128m -Xss1m" - +echo ${FE_URL} # SDC-Simulator -docker run --detach --name sdc-sim --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 /data/logs/WS/:/var/lib/jetty/logs --volume /data/environments:/root/chef-solo/environments --publish 8285:8080 --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE} - +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 /data/logs/WS/:/var/lib/jetty/logs \ + --volume /data/environments:/root/chef-solo/environments \ + --publish 8285:8080 \ + --publish 8286:8443 ${PREFIX}/sdc-simulator:${RELEASE} if [ $? -ne 0 ]; then exit 1 -fi - +fi
\ No newline at end of file |