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:
parent
dad931e898
commit
0b4b48ceae
14
src/wgd.sh
14
src/wgd.sh
@ -49,10 +49,12 @@ check_wgd_status(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_wgd () {
|
start_wgd () {
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
printf "| Starting Wireguard Dashboard in the background. |\n"
|
printf "| Starting Wireguard Dashboard in the background. |\n"
|
||||||
d=$(date '+%Y%m%d%H%M%S')
|
d=$(date '+%Y%m%d%H%M%S')
|
||||||
python3 "$app_name" > log/"$d".txt 2>&1 &
|
python3 "$app_name" > log/"$d".txt 2>&1 &
|
||||||
printf "| Log files is under log/ |\n"
|
printf "| Log files is under log/ |\n"
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_wgd() {
|
stop_wgd() {
|
||||||
@ -60,14 +62,16 @@ stop_wgd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_wgd_debug() {
|
start_wgd_debug() {
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
printf "| Starting Wireguard Dashboard in the foreground. |\n"
|
printf "| Starting Wireguard Dashboard in the foreground. |\n"
|
||||||
python3 "$app_name"
|
python3 "$app_name"
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
}
|
}
|
||||||
|
|
||||||
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/latest').read(); output = json.loads(data);print(output['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['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"
|
||||||
@ -81,7 +85,7 @@ update_wgd() {
|
|||||||
start_wgd
|
start_wgd
|
||||||
else
|
else
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
printf "CANCEL update. \n"
|
printf "| Update Canceled. |\n"
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -93,16 +97,22 @@ if [ "$#" != 1 ];
|
|||||||
else
|
else
|
||||||
if [ "$1" = "start" ]; then
|
if [ "$1" = "start" ]; then
|
||||||
if check_wgd_status; then
|
if check_wgd_status; then
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
printf "| Wireguard Dashboard is already running. |\n"
|
printf "| Wireguard Dashboard is already running. |\n"
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
else
|
else
|
||||||
start_wgd
|
start_wgd
|
||||||
fi
|
fi
|
||||||
elif [ "$1" = "stop" ]; then
|
elif [ "$1" = "stop" ]; then
|
||||||
if check_wgd_status; then
|
if check_wgd_status; then
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
stop_wgd
|
stop_wgd
|
||||||
printf "| Wireguard Dashboard is stopped. |\n"
|
printf "| Wireguard Dashboard is stopped. |\n"
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
else
|
else
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
printf "| Wireguard Dashboard is not running. |\n"
|
printf "| Wireguard Dashboard is not running. |\n"
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
fi
|
fi
|
||||||
elif [ "$1" = "update" ]; then
|
elif [ "$1" = "update" ]; then
|
||||||
update_wgd
|
update_wgd
|
||||||
|
Loading…
Reference in New Issue
Block a user