view scripts/console.sh @ 605:46a67e7afd98 release/2.23.0 tip

flow: Created branch 'release/2.23.0'.
author Marc Davis <marc.davis@mcoecn.org>
date Wed, 18 Sep 2024 20:38:06 -0400
parents 9afc8cb478f6
children
line wrap: on
line source
#!/bin/bash
# connects to the telnet console of the application for the specified service of the current project
# For docker 1.12 and compose 1.9 (and higher) assume project is assigned to a network 
#  named "${project}_default" per SSDT templates.

source "${SSDT_SCRIPTS:-$(dirname "${BASH_SOURCE[0]}")}/.functions.sh"

container=$(composeGetContainer ${1?"Must specify the app service of the console to connect to"} )

ip=$(docker inspect -f '{{.NetworkSettings.IPAddress}}' $container)

if [ "$ip" == "" ]
then
   project=$(composeGetProject ${1} )
   ip=$(docker inspect -f "{{with  .NetworkSettings.Networks}}{{.${project}_default.IPAddress}}{{end}}" $container)
fi

if [ "$project" == "" ]
then 
  docker run -it -v ${PWD}:/tmp  -v ${SSDT_HOME}:/ssdt --rm docker.ssdt-ohio.org/ssdt-utils telnet $ip 2000 | tee console.log
else
  echo "connecting to telnet console on ${container} in ${project}"
  docker run -it --network ${project}_default --rm docker.ssdt-ohio.org/ssdt-utils telnet $ip 2000 | tee console.log
fi