From 737ebdd0c672c68c65888212a9720bad4384d78f Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Sat, 25 Dec 2021 15:20:04 -0500 Subject: [PATCH 01/18] Update wgd.sh --- src/wgd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wgd.sh b/src/wgd.sh index 83590c6..b91f184 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -47,7 +47,7 @@ install_wgd(){ # set up the local environment _check_and_set_venv - ${VIRTUAL_ENV}/bin/python3 -m pip -U pip + ${VIRTUAL_ENV}/bin/python3 -m pip --upgrade pip ${VIRTUAL_ENV}/bin/python3 -m pip install -U -r requirements.txt printf "| WGDashboard installed successfully! |\n" From fc11cacd24f755c813a812d86c922f64761882c9 Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Sat, 25 Dec 2021 15:20:56 -0500 Subject: [PATCH 02/18] Update wgd.sh --- src/wgd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wgd.sh b/src/wgd.sh index b91f184..b3e59aa 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -47,7 +47,7 @@ install_wgd(){ # set up the local environment _check_and_set_venv - ${VIRTUAL_ENV}/bin/python3 -m pip --upgrade pip + ${VIRTUAL_ENV}/bin/python3 -m pip install -U pip ${VIRTUAL_ENV}/bin/python3 -m pip install -U -r requirements.txt printf "| WGDashboard installed successfully! |\n" From 5b47fc16d97a95de7cb14b076e31a96f09d31a48 Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Sat, 25 Dec 2021 16:08:30 -0500 Subject: [PATCH 03/18] Update wgd.sh --- src/wgd.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wgd.sh b/src/wgd.sh index b3e59aa..693aeea 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -33,9 +33,9 @@ _check_and_set_venv(){ install_wgd(){ # Check Python3 version - version_pass=$(python3 -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 8) else print("0");') + version_pass=$(python3 -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 7) else print("0");') if [ $version_pass == "0" ] - then printf "| WGDashboard required Python3.8+ |\n" + then printf "| WGDashboard required Python3.7+ |\n" printf "%s\n" "$dashes" exit 1 fi @@ -45,9 +45,11 @@ install_wgd(){ fi printf "| Installing latest Python dependencies |\n" - # set up the local environment _check_and_set_venv ${VIRTUAL_ENV}/bin/python3 -m pip install -U pip +# ${VIRTUAL_ENV}/bin/python3 -m pip install virtualenv + # set up the local environment + ${VIRTUAL_ENV}/bin/python3 -m pip install -U -r requirements.txt printf "| WGDashboard installed successfully! |\n" From 9890d4f3bc4d6361c4b4a2da9c258cb8a04c1541 Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Sat, 25 Dec 2021 16:29:33 -0500 Subject: [PATCH 04/18] Removed using `venv` for now --- src/wgd.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wgd.sh b/src/wgd.sh index 693aeea..ffe27a8 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -45,24 +45,24 @@ install_wgd(){ fi printf "| Installing latest Python dependencies |\n" - _check_and_set_venv - ${VIRTUAL_ENV}/bin/python3 -m pip install -U pip +# _check_and_set_venv +# ${VIRTUAL_ENV}/bin/python3 -m pip install -U pip # ${VIRTUAL_ENV}/bin/python3 -m pip install virtualenv # set up the local environment - ${VIRTUAL_ENV}/bin/python3 -m pip install -U -r requirements.txt +# ${VIRTUAL_ENV}/bin/python3 -m pip install -U -r requirements.txt + python3 -m pip install -U -r requirements.txt printf "| WGDashboard installed successfully! |\n" printf "| Preparing the systemctl unit file |\n" - sed -i "s#{{APP_ROOT}}#${APP_ROOT}#" wg-dashboard.service - sed -i "s#{{VIRTUAL_ENV}}#${VIRTUAL_ENV}#" wg-dashboard.service +# sed -i "s#{{APP_ROOT}}#${APP_ROOT}#" wg-dashboard.service +# sed -i "s#{{VIRTUAL_ENV}}#${VIRTUAL_ENV}#" wg-dashboard.service # cat wg-dashboard.service | sudo SYSTEMD_EDITOR=tee systemctl edit --force --full wg-dashboard.service - systemctl daemon-reload - printf "| Consider 'systemctl enable wg-dashboard' |\n" - printf " and 'systemctl start wg-dashboard'\n" - printf " use '${0} stop' before starting with systemctl\n" +# systemctl daemon-reload +# printf "| Consider 'systemctl enable wg-dashboard' |\n" +# printf " and 'systemctl start wg-dashboard'\n" +# printf " use '${0} stop' before starting with systemctl\n" echo - printf "| Now starting Dashboard in background |\n" start_wgd } From 7ae3bb56011b61ba0ab4f10baaf1c395877514cb Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Sat, 25 Dec 2021 17:07:33 -0500 Subject: [PATCH 05/18] Testing update function --- .gitignore | 1 - src/wgd.sh | 32 ++++++++++++++++++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 6ec7b5e..85eed07 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,3 @@ private_key.txt public_key.txt venv/** log/** -*~ \ No newline at end of file diff --git a/src/wgd.sh b/src/wgd.sh index ffe27a8..a5d33a0 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -33,28 +33,30 @@ _check_and_set_venv(){ install_wgd(){ # Check Python3 version + printf "%s\n" "$dashes" + printf "| Starting to install WGDashboard |\n" version_pass=$(python3 -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 7) else print("0");') if [ $version_pass == "0" ] - then printf "| WGDashboard required Python3.7+ |\n" + then printf "| WGDashboard required Python 3.7 or above |\n" printf "%s\n" "$dashes" exit 1 fi - rm db/hi.txt > /dev/null 2>&1 + if [ ! -d "db" ] + then mkdir "db" + fi if [ ! -d "log" ] then mkdir "log" fi - printf "| Installing latest Python dependencies |\n" - # _check_and_set_venv # ${VIRTUAL_ENV}/bin/python3 -m pip install -U pip # ${VIRTUAL_ENV}/bin/python3 -m pip install virtualenv - # set up the local environment - # ${VIRTUAL_ENV}/bin/python3 -m pip install -U -r requirements.txt + printf "| Upgrading pip |\n" + python3 -m pip install -U pip + printf "| Installing latest Python dependencies |\n" python3 -m pip install -U -r requirements.txt - printf "| WGDashboard installed successfully! |\n" - - printf "| Preparing the systemctl unit file |\n" + printf "| WGDashboard installed successfully! |\n" +# printf "| Preparing the systemctl unit file |\n" # sed -i "s#{{APP_ROOT}}#${APP_ROOT}#" wg-dashboard.service # sed -i "s#{{VIRTUAL_ENV}}#${VIRTUAL_ENV}#" wg-dashboard.service # cat wg-dashboard.service | sudo SYSTEMD_EDITOR=tee systemctl edit --force --full wg-dashboard.service @@ -78,7 +80,7 @@ check_wgd_status(){ } start_wgd () { - _check_and_set_venv +# _check_and_set_venv printf "%s\n" "$dashes" printf "| Starting WGDashboard in the background. |\n" if [ ! -d "log" ] @@ -96,7 +98,7 @@ stop_wgd() { start_wgd_debug() { printf "%s\n" "$dashes" - _check_and_set_venv +# _check_and_set_venv printf "| Starting WGDashboard in the foreground. |\n" python3 "$app_name" printf "%s\n" "$dashes" @@ -110,12 +112,14 @@ update_wgd() { if [ "$up" = "Y" ]; then printf "| Shutting down WGDashboard... |\n" kill "$(ps aux | grep "[p]ython3 $app_name" | awk '{print $2}')" + mv wgd.sh wgd.sh.old printf "| Downloading %s from GitHub... |\n" "$new_ver" git stash > /dev/null 2>&1 - git pull https://github.com/donaldzou/wireguard-dashboard.git $new_ver --force > /dev/null 2>&1 + git pull +# git pull https://github.com/donaldzou/wireguard-dashboard.git $new_ver --force > /dev/null 2>&1 printf "| Installing latest Python dependencies |\n" - _check_and_set_venv - python3 -m pip install -r requirements.txt > /dev/null 2>&1 +# _check_and_set_venv + python3 -m pip install -U -r requirements.txt > /dev/null 2>&1 printf "| Update Successfully! |\n" start_wgd else From 3934248a6b67cafef077e4ce88f2ec14533a3a3e Mon Sep 17 00:00:00 2001 From: Donald Cheng Hong Zou Date: Sat, 25 Dec 2021 17:08:59 -0500 Subject: [PATCH 06/18] Update wgd.sh --- src/wgd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wgd.sh b/src/wgd.sh index a5d33a0..efd69a7 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -6,7 +6,7 @@ dashes='------------------------------------------------------------' equals='============================================================' help () { printf "=================================================================================\n" - printf "+ by Donald Zou - https://github.com/donaldzou +\n" + printf "+ by Donald Zou - https://github.com/donaldzou +\n" printf "=================================================================================\n" printf "| Usage: ./wgd.sh