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.

55 lines
1.3 KiB

3 years ago
#!/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
3 years ago
if [[ -z "$2" ]] ; then
echo 'no port'
exit 1
fi
3 years ago
3 years ago
R_PORT1=$2
3 years ago
3 years ago
service=$1
#string=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '')
serviceeditor=${service//_}
serviceeditor=${serviceeditor//-}
3 years ago
xhost +local:docker
docker stop edit_${serviceeditor}
docker container rm edit_${serviceeditor}
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_${serviceeditor} hub.swarmlab.io:5480/swarmlab-codeserver /bin/bash -c "echo \"start:${service}\"; /tmp/start"
3 years ago