Honeynode Docker refactoring for Java11
[transportpce.git] / tests / Xtesting / DockerSims / start_sims.sh
1 #!/bin/sh
2
3 . $(dirname $0)/dockercmd_profile.sh
4
5 DOCKER_OPTIONS="-e USER=${RESTCONF_USER} -e PASSWORD=${RESTCONF_PASSWORD} -e DEVICE_VERSION=${DEVICE_VERSION} -dit ${DOCKER_IMAGE}"
6
7 for image in $IMAGE_LIST;do
8     suffix_port=`echo -n $image| cut -d: -f1`
9     image_name=`echo -n $image| cut -d: -f2`
10     device_file=`echo -n $image| cut -d: -f3`
11     #echo "$image_name $suffix_port $device_file"
12     if [ ! "$(${DOCKER_CMD} ps -q -f name=${image_name})" ];then
13        if [  "$(${DOCKER_CMD} ps -aq -f status=exited -f name=${image_name})" ];then
14           ${DOCKER_CMD} rm ${image_name}
15        fi
16     elif [  "$(${DOCKER_CMD} ps -q -f status=running -f name=${image_name})" ];then
17           ${DOCKER_CMD} stop ${image_name}
18     fi
19     echo ${image_name}
20     ${DOCKER_CMD} run --rm -p 178$suffix_port:1830 -p 81$suffix_port:8130 --name ${image_name} -e DEVICE_FILE=${device_file} ${DOCKER_OPTIONS}
21 done
22
23 exit
24