diff --git a/setup/create.sh b/setup/create.sh index 49dfb22..4ddbd9a 100755 --- a/setup/create.sh +++ b/setup/create.sh @@ -20,7 +20,7 @@ function print_usage() { echo " " } -while getopts 'i:e:p:a:f:hd' option; do +while getopts 'i:e:p:a:f:q:w:hd' option; do case "${option}" in h) print_usage exit 0 ;; @@ -29,6 +29,8 @@ while getopts 'i:e:p:a:f:hd' option; do p) WG_ENDPOINT_PORT="${OPTARG}" ;; a) WG_HTTP_PORT="${OPTARG}" ;; f) FIREWALL_TO_USE="${OPTARG}" ;; + q) FW_ENDPOINT_PORT="${OPTARG}" ;; + w) FW_ENDPOINT_HOST="${OPTARG}" ;; d) DEBUG=true ;; *) print_usage exit 1 ;; @@ -40,6 +42,8 @@ done [ -z ${WG_ENDPOINT_PORT} ] && { printf '{"todo": "Create Sotreus Docker Instances","result": "failure","message": "SOTREUS Endpoint Port Not Provided"}\n'; exit 2;} [ -z ${WG_HTTP_PORT} ] && { printf '{"todo": "Create Sotreus Docker Instances","result": "failure","message": "SOTREUS API Port Not Provided"}\n'; exit 2;} [ -z ${FIREWALL_TO_USE} ] && { printf '{"todo": "Create Sotreus Docker Instances","result": "failure","message": "Firewall name Not Provided"}\n'; exit 2;} +[ -z ${FW_ENDPOINT_PORT} ] && { printf '{"todo": "Create Sotreus Docker Instances","result": "failure","message": "Firewall endpoint Not Provided"}\n'; exit 2;} +[ -z ${FW_ENDPOINT_HOST} ] && { printf '{"todo": "Create Sotreus Docker Instances","result": "failure","message": "Firewall host Not Provided"}\n'; exit 2;} FIREWALL_PASSWORD=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''` if [ "$FIREWALL_TO_USE" == "pihole" ]; then @@ -50,9 +54,9 @@ fi echo $DOCKER_COMPOSE_FILE if $DEBUG; then echo -e "Creating Docker Instances For Sotreus For [$SOTREUS_NAME]..." - SOTREUS_NAME=$SOTREUS_NAME WG_ENDPOINT_HOST=$WG_ENDPOINT_HOST WG_ENDPOINT_PORT=$WG_ENDPOINT_PORT WG_HTTP_PORT=$WG_HTTP_PORT FIREWALL_PASSWORD=$FIREWALL_PASSWORD /usr/bin/docker-compose -f $DOCKER_COMPOSE_FILE -p $SOTREUS_NAME up -d + SOTREUS_NAME=$SOTREUS_NAME WG_ENDPOINT_HOST=$WG_ENDPOINT_HOST WG_ENDPOINT_PORT=$WG_ENDPOINT_PORT WG_HTTP_PORT=$WG_HTTP_PORT FIREWALL_PASSWORD=$FIREWALL_PASSWORD DOMAIN=$WG_ENDPOINT_HOST FW_ENDPOINT_PORT=$FW_ENDPOINT_PORT FW_ENDPOINT_HOST=$FW_ENDPOINT_HOST /usr/bin/docker-compose -f $DOCKER_COMPOSE_FILE -p $SOTREUS_NAME up -d else - SOTREUS_NAME=$SOTREUS_NAME WG_ENDPOINT_HOST=$WG_ENDPOINT_HOST WG_ENDPOINT_PORT=$WG_ENDPOINT_PORT WG_HTTP_PORT=$WG_HTTP_PORT FIREWALL_PASSWORD=$FIREWALL_PASSWORD /usr/bin/docker-compose -f $DOCKER_COMPOSE_FILE -p $SOTREUS_NAME up -d > /dev/null 2>&1 + SOTREUS_NAME=$SOTREUS_NAME WG_ENDPOINT_HOST=$WG_ENDPOINT_HOST WG_ENDPOINT_PORT=$WG_ENDPOINT_PORT WG_HTTP_PORT=$WG_HTTP_PORT FIREWALL_PASSWORD=$FIREWALL_PASSWORD DOMAIN=$WG_ENDPOINT_HOST FW_ENDPOINT_PORT=$FW_ENDPOINT_PORT FW_ENDPOINT_HOST=$FW_ENDPOINT_HOST /usr/bin/docker-compose -f $DOCKER_COMPOSE_FILE -p $SOTREUS_NAME up -d > /dev/null 2>&1 fi mkdir -p /sotreus/$SOTREUS_NAME/etc-wireguard/clients