From e45360e8ed249e3b81091cbe6dbf69d3fb33d8a7 Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Tue, 21 Jan 2025 15:59:28 +0800 Subject: [PATCH] Add version option in `./wgd.sh` --- src/dashboard.py | 6 ++++-- src/wgd.sh | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index 4ae30719..2b0ad683 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -512,10 +512,12 @@ class WireguardConfiguration: self.__parser.write(configFile) self.__initPeersList() - print(f"[WGDashboard] Initialized Configuration: {name}") + if __name__ == "__main__": + print(f"[WGDashboard] Initialized Configuration: {name}") if self.getAutostartStatus() and not self.getStatus() and startup: self.toggleConfiguration() - print(f"[WGDashboard] Autostart Configuration: {name}") + if __name__ == "__main__": + print(f"[WGDashboard] Autostart Configuration: {name}") def __initPeersList(self): diff --git a/src/wgd.sh b/src/wgd.sh index 22e1d250..2c794a63 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -443,6 +443,15 @@ update_wgd() { fi } +get_version() { + if [ ! -f "$venv_python" ]; + then + printf "[WGDashboard] WGDashboard is not install yet. Please install it with [./wgd.sh install]\n" + else + sudo "$venv_python" -c "from dashboard import DASHBOARD_VERSION; print(DASHBOARD_VERSION)" + fi +} + if [ "$#" -lt 1 ]; then help else @@ -491,6 +500,8 @@ else else start_wgd_debug fi + elif [ "$1" = "version" ]; then + get_version else help fi