#!/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 #echo $cwdir #echo $wdir cd $wdir . ./user.env sed -i '/${U_PORT5}:${S_PORT5}/d' ../docker-compose.yml sed -i '/${U_PORT4}:${S_PORT4}/d' ../docker-compose.yml sed -i '/${U_PORT3}:${S_PORT3}/d' ../docker-compose.yml sed -i '/${U_PORT2}:${S_PORT2}/d' ../docker-compose.yml sed -i '/${U_PORT1}:${S_PORT1}/d' ../docker-compose.yml if [ ! -z "$S_PORT5" ]; then sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT5}:${S_PORT5}"' ../docker-compose.yml fi if [ ! -z "$S_PORT4" ]; then sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT4}:${S_PORT4}"' ../docker-compose.yml fi if [ ! -z "$S_PORT3" ]; then sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT3}:${S_PORT3}"' ../docker-compose.yml fi if [ ! -z "$S_PORT2" ]; then sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT2}:${S_PORT2}"' ../docker-compose.yml fi if [ ! -z "$S_PORT1" ]; then sed -i '/\sports:/a \ \ \ \ \ \ -\ "${U_PORT1}:${S_PORT1}"' ../docker-compose.yml fi cd $cwdir