Skip to content

Commit

Permalink
scripts: take firewall host and port on create
Browse files Browse the repository at this point in the history
don't rely on env for these
  • Loading branch information
inciner8r committed Nov 28, 2023
1 parent ab947d9 commit 2f86b29
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions setup/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;;
Expand All @@ -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 ;;
Expand All @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 2f86b29

Please sign in to comment.