From 317590c4bd3e5d4f055440d004d98f43fd0fda83 Mon Sep 17 00:00:00 2001
From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl>
Date: Wed, 6 May 2020 15:11:14 +0200
Subject: [PATCH] Add more helper stuff to make the start-jive script work

Still not there because docker-compose appears to do some
things behind closed doors and I cannot figure them out yet.
---
 tools/itango/start-jive.sh | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100755 tools/itango/start-jive.sh

diff --git a/tools/itango/start-jive.sh b/tools/itango/start-jive.sh
new file mode 100755
index 000000000..06fa7e09a
--- /dev/null
+++ b/tools/itango/start-jive.sh
@@ -0,0 +1,38 @@
+OS=$(uname)
+
+case ${OS} in
+    Linux)
+        display=""
+        XTRA_OPTIONS="-u $(id -u ${USER}):$(id -g ${USER}) -v /etc/passwd:/etc/passwd:ro -v /etc/groups:/etc/groups:ro"
+
+        ;;
+    Darwin)
+        display="$(scutil --nwi | grep 'address' | cut -d':' -f2 | tr -d ' ' | head -n1):0"
+        XTRA_OPTIONS=""
+        ;;
+esac
+
+display=${display:-${DISPLAY}}
+
+OPTIONS="-e HOME=/hosthome -e DISPLAY=${display} -e XAUTHORITY=/hosthome/.Xauthority -e TANGO_HOST=databaseds:10000 -v ${HOME}:/hosthome -v /tmp/.X11-unix:/tmp/.X11-unix"
+
+if [ ! -z ${XTRA_OPTIONS} ]; then
+    OPTIONS="${OPTIONS} ${XTRA_OPTIONS}"
+fi
+
+if [ ${#} -eq 1 ]; then
+    command=${1}
+    shift
+else
+    command=/usr/local/bin/jive
+fi
+
+#docker run --rm -it --network host ${OPTIONS} nexus.engageska-portugal.pt/ska-docker/tango-java:latest ${command} ${@}
+container_name=nexus.engageska-portugal.pt/ska-docker/tango-java:latest
+container=$(docker ps | egrep ${container_name} | cut -d' ' -f1)
+if [ ! -z ${container} ]; then
+    docker exec -it ${container} ${command} ${@}
+else
+    echo "Container \"${container_name}\" is not running."
+fi
+
-- 
GitLab