comparison scripts/console.sh @ 179:ae2b4a5294ff hotfix/v1.2.2

DEP-12: fix console script for containers in multiple networks
author smith@nwoca.org
date Mon, 11 Sep 2017 22:00:37 +0100
parents 8f45c43ea7a4
children 9afc8cb478f6
comparison
equal deleted inserted replaced
178:ab65b374a12e 179:ae2b4a5294ff
1 #!/bin/bash 1 #!/bin/bash
2 # connects to the telnet console of the application for the specified service of the current project 2 # connects to the telnet console of the application for the specified service of the current project
3 # For docker 1.12 and compose 1.9 (and higher) assume project is assigned to a network 3 # For docker 1.12 and compose 1.9 (and higher) assume project is assigned to a network
4 # named "${project}_default" per SSDT templates. 4 # named "${project}_default" per SSDT templates.
5 5
6 source "$( dirname "${BASH_SOURCE[0]}")/.functions.sh" 6 source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"
7 7
8 container=$(composeGetContainer ${1?"Must specify the app service of the console to connect to"} ) 8 container=$(composeGetContainer ${1?"Must specify the app service of the console to connect to"} )
9 9
10 ip=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' $container) 10 ip=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' $container)
11 11
12 if [ "$ip" == "" ] 12 if [ "$ip" == "" ]
13 then 13 then
14 ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $container)
15 project=$(composeGetProject ${1} ) 14 project=$(composeGetProject ${1} )
15 ip=$(docker inspect -f "{{with .NetworkSettings.Networks}}{{.${project}_default.IPAddress}}{{end}}" $container)
16 fi 16 fi
17 17
18 if [ "$project" == "" ] 18 if [ "$project" == "" ]
19 then 19 then
20 docker run -it -v ${PWD}:/tmp -v ${SSDT_HOME}:/ssdt --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log 20 docker run -it -v ${PWD}:/tmp -v ${SSDT_HOME}:/ssdt --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log
21 else 21 else
22 echo "connecting to telnet console on ${container} in ${project}"
22 docker run -it --network ${project}_default --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log 23 docker run -it --network ${project}_default --rm docker.ssdt.io/ssdt-utils telnet $ip 2000 | tee console.log
23 fi 24 fi
25