1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-22 15:20:09 +01:00

Update wgd.sh

This commit is contained in:
Donald Cheng Hong Zou 2021-09-02 22:52:01 -04:00
parent 93007cd56c
commit 465d102bd0

View File

@ -4,13 +4,14 @@ app_name="dashboard.py"
dashes='------------------------------------------------------------' dashes='------------------------------------------------------------'
help () { help () {
printf "<Wireguard Dashboard> by Donald Zou - https://github.com/donaldzou \n" printf "<Wireguard Dashboard> by Donald Zou - https://github.com/donaldzou \n"
printf "Usage: sh wgd.sh <option>" printf "Usage: ./wgd.sh <option>"
printf "\n \n" printf "\n \n"
printf "Available options: \n" printf "Available options: \n"
printf " start: To start Wireguard Dashboard.\n" printf " start: To start Wireguard Dashboard.\n"
printf " stop: To stop Wireguard Dashboard.\n" printf " stop: To stop Wireguard Dashboard.\n"
printf " debug: To start Wireguard Dashboard in debug mode (i.e run in foreground).\n" printf " debug: To start Wireguard Dashboard in debug mode (i.e run in foreground).\n"
printf " update: To update Wireguard Dashboard to the newest version from GitHub.\n" printf " update: To update Wireguard Dashboard to the newest version from GitHub.\n"
printf " install: To install Wireguard Dasboard.\n"
printf "Thank you for using this dashboard! Your support is my motivation ;) \n" printf "Thank you for using this dashboard! Your support is my motivation ;) \n"
printf "\n" printf "\n"
} }
@ -54,13 +55,13 @@ start_wgd_debug() {
} }
update_wgd() { update_wgd() {
new_ver=$(python3 -c "import json; import urllib.request; data = urllib.request.urlopen('https://api.github.com/repos/donaldzou/wireguard-dashboard/releases').read(); output = json.loads(data);print(output[0]['tag_name'])") new_ver=$(python3 -c "import json; import urllib.request; data = urllib.request.urlopen('https://api.github.com/repos/donaldzou/wireguard-dashboard/releases/latest').read(); output = json.loads(data);print(output[0]['tag_name'])")
printf "%s\n" "$dashes" printf "%s\n" "$dashes"
printf "Are you sure you want to update to the %s? (Y/N): " "$new_ver" printf "Are you sure you want to update to the %s? (Y/N): " "$new_ver"
read up read up
if [ "$up" = "Y" ]; then if [ "$up" = "Y" ]; then
printf "| Shutting down Wireguard Dashboard... |\n" printf "| Shutting down Wireguard Dashboard... |\n"
stop_wgd kill "$(ps aux | grep "[p]ython3 $app_name" | awk '{print $2}')"
printf "| Downloading %s from GitHub... |\n" "$new_ver" printf "| Downloading %s from GitHub... |\n" "$new_ver"
git stash > /dev/null 2>&1 git stash > /dev/null 2>&1
git pull https://github.com/donaldzou/wireguard-dashboard.git $new_ver --force > /dev/null 2>&1 git pull https://github.com/donaldzou/wireguard-dashboard.git $new_ver --force > /dev/null 2>&1