From ebbe01c65db3c8a562a4182b1438fb06b170b05f Mon Sep 17 00:00:00 2001 From: DaanSelen Date: Tue, 30 Dec 2025 14:39:22 +0100 Subject: [PATCH] refac: refactor the logic with which the Docker container links its files to the volume --- .dockerignore | 4 +++- docker/compose.yaml | 1 + docker/entrypoint.sh | 26 ++++++++++++++++++++------ 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index e2c608c2..cee71607 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,4 +2,6 @@ .github *.md tests/ -docs/ \ No newline at end of file +docs/ +src/db +src/wg-dashboard.ini diff --git a/docker/compose.yaml b/docker/compose.yaml index d8f2eac9..445c3102 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -13,6 +13,7 @@ services: # By default its all disabled, but uncomment the following lines to apply these. (uncommenting is removing the # character) # Refer to the documentation on https://wgdashboard.dev/ for more info on what everything means. #environment: + #- wg_autostart=wg0 #- tz= # <--- Set container timezone, default: Europe/Amsterdam. #- public_ip= # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me. #- wgd_port= # <--- Set the port WGDashboard will use for its web-server. diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 7a024505..977d7b6d 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -108,17 +108,31 @@ ensure_installation() { mkdir -p /data/db fi - if [ ! -d "${WGDASH}/src/db" ]; then - ln -s /data/db "${WGDASH}/src/db" - fi - if [ ! -f "${config_file}" ]; then echo "Creating wg-dashboard.ini file" touch "${config_file}" fi - if [ ! -f "${WGDASH}/src/wg-dashboard.ini" ]; then - ln -s "${config_file}" "${WGDASH}/src/wg-dashboard.ini" + if [[ ! -L "${WGDASH}/src/db" ]] && [[ -d "${WGDASH}/src/db" ]]; then + echo "Removing ${WGDASH}/src/db since its not a symbolic link." + rm -rfv "${WGDASH}/src/db" + fi + + if [[ -L "${WGDASH}/src/db" ]]; then + echo "${WGDASH}/src/db is a symbolic link." + else + ln -sv /data/db "${WGDASH}/src/db" + fi + + if [[ ! -L "${WGDASH}/src/wg-dashboard.ini" ]] && [[ -f "${WGDASH}/src/wg-dashboard.ini" ]]; then + echo "Removing ${WGDASH}/src/wg-dashboard.ini since its not a symbolic link." + rm -fv "${WGDASH}/src/wg-dashboard.ini" + fi + + if [[ -L "${WGDASH}/src/wg-dashboard.ini" ]]; then + echo "${WGDASH}/src/wg-dashboard.ini is a symbolic link." + else + ln -sv "${config_file}" "${WGDASH}/src/wg-dashboard.ini" fi # Setup WireGuard if needed