You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.2 KiB

#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
TARGET="$(readlink "$SOURCE")"
if [[ $TARGET == /* ]]; then
SOURCE="$TARGET"
else
DIR="$( dirname "$SOURCE" )"
SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
fi
done
SRPATH="$( dirname "$SOURCE" )"
SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
if [ "$SFPATH" != "$SRPATH" ]; then
RDIR=$SRPATH # relativ path directory
fi
cwdir=$PWD
wdir=$SFPATH
if [[ $# -eq 0 ]] ; then
echo 'no service'
exit 1
fi
if [[ -z "$1" ]] ; then
echo 'no service'
exit 1
fi
if [[ -z "$2" ]] ; then
echo 'no port'
exit 1
fi
R_PORT1=$2
service=$1
xhost +local:docker
docker stop edit_$service
docker container rm edit_$service
docker run --rm --volumes-from $service -p $R_PORT1:8080 -e TZ=Europe/Athens -e DISPLAY=$DISPLAY -v $(pwd)/swarmlab_editor_service:/tmp/start -v /tmp/.X11-unix:/tmp/.X11-unix --name edit_$service hub.swarmlab.io:5480/swarmlab-codeserver /bin/bash -c "echo \"start:${service}\"; /tmp/start"