From 6f7b9815ca047510504504f37e11f7f99c13530d Mon Sep 17 00:00:00 2001 From: Daan Selen Date: Thu, 6 Feb 2025 11:41:41 +0100 Subject: [PATCH] Hotfix for stop entrapment and addition of workdir in Dockerfile --- Dockerfile | 1 + entrypoint.sh | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1d125c1..9d45e70 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,5 +85,6 @@ COPY entrypoint.sh /entrypoint.sh # Exposing the default WireGuard Dashboard port for web access. EXPOSE 10086 +WORKDIR $WGDASH ENTRYPOINT ["/bin/bash", "/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 221903e..da3f585 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,7 +7,7 @@ trap 'stop_service' SIGTERM stop_service() { echo "[WGDashboard] Stopping WGDashboard..." - ./wgd.sh stop + bash ./wgd.sh stop exit 0 } @@ -18,6 +18,12 @@ ensure_installation() { # When using a custom directory to store the files, this part moves over and makes sure the installation continues. echo "Quick-installing..." + chmod +x "${WGDASH}"/src/wgd.sh + cd "${WGDASH}"/src || exit + + echo "Removing clear command from wgd.sh for better Docker logging." + sed -i '/clear/d' ./wgd.sh + if [ ! -d "/data/db" ]; then echo "Creating database dir" mkdir /data/db @@ -45,9 +51,6 @@ ensure_installation() { echo "Moving PIP dependency from ephemerality to runtime environment: bcrypt" mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages - - chmod +x "${WGDASH}"/src/wgd.sh - cd "${WGDASH}"/src || exit ./wgd.sh install echo "Looks like the installation succeeded. Moving on." @@ -129,10 +132,7 @@ start_core() { printf "\n---------------------- STARTING CORE -----------------------\n" echo "Activating Python venv and executing the WireGuard Dashboard service." - - . "${WGDASH}"/src/venv/bin/activate - cd "${WGDASH}"/src || return - bash wgd.sh start + bash ./wgd.sh start } ensure_blocking() { @@ -143,17 +143,14 @@ ensure_blocking() { local logdir="${WGDASH}/src/log" latestErrLog=$(find "$logdir" -name "error_*.log" -type f -print | sort -r | head -n 1) - #latestAccLog=$(find "$logdir" -name "access_*.log" -type f -print | sort -r | head -n 1) # Removed access line due to console spam. # Only tail the logs if they are found - if [ -n "$latestErrLog" ] || [ -n "$latestAccLog" ]; then - tail -f "$latestErrLog" + if [ -n "$latestErrLog" ]; then + tail -f "$latestErrLog" & + wait $! else - echo "No log files found to tail." + echo "No log files found to tail. Something went wrong, exiting..." fi - - # Blocking command to keep the container running as a last resort. - sleep infinity } # Execute functions for the WireGuard Dashboard services, then set the environment variables