forked from kgyrtkirk/hive-dev-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenter.bash
executable file
·30 lines (24 loc) · 885 Bytes
/
enter.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash -e
[ "$1" == "" ] && echo "usage: $0 <container name>" && exit 1
DOCKER=docker
function isContainerRunning() {
[ "`$DOCKER ps -q -f name=$1`" != "" ]
}
# FIXME: make this cleaner
if [ "$DISPLAY" != "" ];then
echo " * enabling X forward..."
if [ "`which sw_vers`" != "" ] ; then
# MacOSX assumed
xhost + 127.0.0.1
RUN_OPTS+=" -e DISPLAY=host.docker.internal:0"
else
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
RUN_OPTS+=" -e DISPLAY -e XAUTHORITY=$XAUTH -v $XSOCK:$XSOCK -v $XAUTH:$XAUTH"
fi
fi
#export HIVE_TEST_DOCKER_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.Gateway}}{{end}}' `hostname`)
isContainerRunning "$1" || docker start "$1"
docker exec -it "$1" /bin/bash -login