From a76e9ed98b02822d9e021e2556c6ae814c0cb2a8 Mon Sep 17 00:00:00 2001 From: Dselen Date: Mon, 26 Aug 2024 16:16:09 -0500 Subject: [PATCH 1/3] Testing more changes for better handling of variables. --- docker/alpine/compose.yaml | 6 +++--- docker/alpine/entrypoint.sh | 18 +++++++----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/docker/alpine/compose.yaml b/docker/alpine/compose.yaml index ae26b90..20945ee 100644 --- a/docker/alpine/compose.yaml +++ b/docker/alpine/compose.yaml @@ -1,14 +1,14 @@ services: wireguard-dashboard: - image: dselen:alpine + image: dselen/wgdashboard:alpine restart: unless-stopped container_name: wgdashboard environment: #- tz= # <--- Set container timezone, default: Europe/Amsterdam. - #- global_dns= # <--- Set global DNS address, default: 1.1.1.1. + - global_dns=9.9.9.9 # <--- Set global DNS address, default: 1.1.1.1. - enable=wg0 # <--- Set the interfaces that will be enabled on startup, default: none. The option "off" is also allowed. - isolate=wg0 # <--- When set to true, it disallows peers to talk to eachother, setting to false, allows it, default: true. - #- public_ip= # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me. + - public_ip=212.124.66.17 # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me. ports: - 10086:10086/tcp - 51820:51820/udp diff --git a/docker/alpine/entrypoint.sh b/docker/alpine/entrypoint.sh index 955fcb5..b2ff69e 100644 --- a/docker/alpine/entrypoint.sh +++ b/docker/alpine/entrypoint.sh @@ -22,10 +22,6 @@ ensure_installation() { cd "${WGDASH}"/src || exit ./wgd.sh install - echo "Generating some files..." - ./wgd.sh start - ./wgd.sh stop - echo "Looks like the installation succesfully moved over." else echo "Looks like everything is present. Or the directory is not empty." @@ -109,10 +105,6 @@ set_envvars() { sed -i "s/^remote_endpoint = .*/remote_endpoint = ${public_ip}/" /opt/wireguarddashboard/src/wg-dashboard.ini fi - - #echo "Restarting service for good measure" - #cd "${WGDASH}"/src || exit - #./wgd.sh restart } # === CORE SERVICES === @@ -121,8 +113,8 @@ start_core() { echo "Activating Python venv and executing the WireGuard Dashboard service." . "${WGDASH}"/src/venv/bin/activate - cd "${WGDASH}"/src || return # If changing the directory fails (permission or presence error), then bash will exist this function, causing the WireGuard Dashboard to not be succesfully launched. - bash wgd.sh start + cd "${WGDASH}"/src || return + bash wgd.sh start &>> /dev/null # Isolated peers feature, first converting the existing configuration files and the given names to arrays. local configurations=(/etc/wireguard/*) @@ -205,6 +197,10 @@ start_core() { ensure_blocking() { printf "\n-------------- ENSURING CONTAINER CONTINUATION -------------\n" + . "${WGDASH}"/src/venv/bin/activate + cd "${WGDASH}"/src || return + bash wgd.sh restart + sleep 1s echo "Ensuring container continuation." @@ -223,6 +219,6 @@ ensure_blocking() { # Execute functions for the WireGuard Dashboard services, then set the environment variables ensure_installation clean_up -set_envvars start_core +set_envvars ensure_blocking \ No newline at end of file From 548f3db33df745084b291e458c17085fc8c9fe9d Mon Sep 17 00:00:00 2001 From: Dselen Date: Mon, 26 Aug 2024 16:16:43 -0500 Subject: [PATCH 2/3] quickfix --- docker/alpine/compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/alpine/compose.yaml b/docker/alpine/compose.yaml index 20945ee..0d84bea 100644 --- a/docker/alpine/compose.yaml +++ b/docker/alpine/compose.yaml @@ -8,7 +8,7 @@ services: - global_dns=9.9.9.9 # <--- Set global DNS address, default: 1.1.1.1. - enable=wg0 # <--- Set the interfaces that will be enabled on startup, default: none. The option "off" is also allowed. - isolate=wg0 # <--- When set to true, it disallows peers to talk to eachother, setting to false, allows it, default: true. - - public_ip=212.124.66.17 # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me. + - public_ip= # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me. ports: - 10086:10086/tcp - 51820:51820/udp From c3cda05d9847ef659b83329c5d5ea6e6cd856819 Mon Sep 17 00:00:00 2001 From: Dselen Date: Tue, 27 Aug 2024 02:26:19 -0500 Subject: [PATCH 3/3] Move fix. --- docker/alpine/Dockerfile | 6 +++--- docker/alpine/compose.yaml | 8 ++++---- docker/alpine/entrypoint.sh | 7 ++++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index b9addcf..5828b34 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -26,9 +26,9 @@ ENV WGDASH=/opt/wireguarddashboard # Removing the Linux Image package to preserve space on the image, for this reason also deleting apt lists, to be able to install packages: run apt update. # Doing WireGuard Dashboard installation measures. Modify the git clone command to get the preferred version, with a specific branch for example. -RUN mkdir -p /setup/conf && mkdir /setup/app && mkdir ${WGDASH} \ - && git clone ${Git_Url} /setup/app -#COPY src /setup/app/src +RUN mkdir -p /setup/conf && mkdir /setup/app && mkdir ${WGDASH} + #&& git clone ${Git_Url} /setup/app +COPY src /setup/app/src # Set the volume to be used for WireGuard configuration persistency. VOLUME /etc/wireguard diff --git a/docker/alpine/compose.yaml b/docker/alpine/compose.yaml index 0d84bea..341fa27 100644 --- a/docker/alpine/compose.yaml +++ b/docker/alpine/compose.yaml @@ -1,6 +1,6 @@ services: wireguard-dashboard: - image: dselen/wgdashboard:alpine + image: dselen:alpine restart: unless-stopped container_name: wgdashboard environment: @@ -8,13 +8,13 @@ services: - global_dns=9.9.9.9 # <--- Set global DNS address, default: 1.1.1.1. - enable=wg0 # <--- Set the interfaces that will be enabled on startup, default: none. The option "off" is also allowed. - isolate=wg0 # <--- When set to true, it disallows peers to talk to eachother, setting to false, allows it, default: true. - - public_ip= # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me. + #- public_ip= # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me. ports: - 10086:10086/tcp - 51820:51820/udp volumes: - - app:/opt/wireguarddashboard - - conf:/etc/wireguard + - ./app:/opt/wireguarddashboard + - ./conf:/etc/wireguard cap_add: - NET_ADMIN diff --git a/docker/alpine/entrypoint.sh b/docker/alpine/entrypoint.sh index b2ff69e..20c2711 100644 --- a/docker/alpine/entrypoint.sh +++ b/docker/alpine/entrypoint.sh @@ -10,7 +10,8 @@ ensure_installation() { if [ -z "$(ls -A "${WGDASH}")" ]; then echo "Detected empty directory, moving over..." - mv /setup/app/{.[!.],}* "${WGDASH}" + mv /setup/app/* "${WGDASH}" + mv /setup/app/.* "${WGDASH}" python3 -m venv "${WGDASH}"/src/venv . "${WGDASH}/src/venv/bin/activate" @@ -82,7 +83,7 @@ clean_up() { # === SET ENV VARS === set_envvars() { - printf "\n------------- SETTING ENVIRONMENT VARIABLES ----------------\n" + #printf "\n------------- SETTING ENVIRONMENT VARIABLES ----------------\n" # Changing the DNS used for clients and the dashboard itself. if [ "${global_dns}" != "$(grep "peer_global_dns = " /opt/wireguarddashboard/src/wg-dashboard.ini | awk '{print $NF}')" ]; then @@ -195,7 +196,7 @@ start_core() { # === CLEAN UP === ensure_blocking() { - printf "\n-------------- ENSURING CONTAINER CONTINUATION -------------\n" + #printf "\n-------------- ENSURING CONTAINER CONTINUATION -------------\n" . "${WGDASH}"/src/venv/bin/activate cd "${WGDASH}"/src || return