mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-08-27 23:41:14 +00:00
Update
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
dashboard_version = 'v2.0'
|
||||
|
||||
|
||||
# Python Built-in Library
|
||||
import os
|
||||
from flask import Flask, request, render_template, redirect, url_for, session, abort
|
||||
@@ -11,10 +14,8 @@ import configparser
|
||||
# PIP installed library
|
||||
import ifcfg
|
||||
from tinydb import TinyDB, Query
|
||||
dashboard_version = 'v2.0'
|
||||
dashboard_conf = 'wg-dashboard.ini'
|
||||
update = ""
|
||||
|
||||
app = Flask("Wireguard Dashboard")
|
||||
app.secret_key = secrets.token_urlsafe(16)
|
||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||
@@ -254,8 +255,8 @@ def auth_req():
|
||||
request.endpoint != "signout" and \
|
||||
request.endpoint != "auth" and \
|
||||
"username" not in session:
|
||||
print(request.path)
|
||||
print("not loggedin")
|
||||
session['message'] = "You need to sign in first!"
|
||||
return redirect(url_for("signin"))
|
||||
else:
|
||||
if request.endpoint in ['signin', 'signout', 'auth', 'settings', 'update_acct', 'update_pwd', 'update_app_ip_port', 'update_wg_conf_path']:
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<li class="nav-item"><a class="nav-link sb-settings-url" href="/settings">Settings</a></li>
|
||||
{% endif %}
|
||||
{% if session['update'] == "true" %}
|
||||
<li class="nav-item sb-update-li"><a class="nav-link sb-update-url" href="/">New Update Available!<span class="dot dot-running"></span></a></li>
|
||||
<li class="nav-item sb-update-li"><a class="nav-link sb-update-url" href="https://github.com/donaldzou/wireguard-dashboard/#-how-to-update-the-dashboard">New Update Available!<span class="dot dot-running"></span></a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
<hr>
|
||||
|
36
src/wgd.sh
36
src/wgd.sh
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
app_name="dashboard.py"
|
||||
|
||||
dashes='------------------------------------------------------------'
|
||||
help () {
|
||||
printf "<Wireguard Dashboard> by Donald Zou - https://github.com/donaldzou \n"
|
||||
printf "Usage: sh wg-dashboard.sh <option>"
|
||||
@@ -44,14 +44,34 @@ start_wgd_debug() {
|
||||
}
|
||||
|
||||
update_wgd() {
|
||||
git pull
|
||||
if check_wgd_status; then
|
||||
stop_wgd
|
||||
sleep 2
|
||||
printf "Wireguard Dashboard is stopped. \n"
|
||||
start_wgd_debug
|
||||
|
||||
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'])")
|
||||
printf "%s\n" "$dashes"
|
||||
printf "Are you sure you want to update to the %s? (Y/N): " "$new_ver"
|
||||
read up
|
||||
if [ "$up" = "Y" ]; then
|
||||
printf "%s\n" "$dashes"
|
||||
printf "| Shutting down Wireguard Dashboard... |\n"
|
||||
printf "%s\n" "$dashes"
|
||||
printf "| Downloading %s from GitHub... |\n" "$new_ver"
|
||||
printf "%s\n" "$dashes"
|
||||
git pull https://github.com/donaldzou/wireguard-dashboard.git $new_ver > /dev/null 2>&1
|
||||
printf "| Update Successfully! |\n"
|
||||
printf "%s\n" "$dashes"
|
||||
printf "| Now you can start the dashboard with >> sh wgd.sh start |\n"
|
||||
printf "%s\n" "$dashes"
|
||||
# if check_wgd_status; then
|
||||
# stop_wgd
|
||||
# sleep 2
|
||||
# printf "Wireguard Dashboard is stopped. \n"
|
||||
# start_wgd_debug
|
||||
# else
|
||||
# start_wgd_debug
|
||||
# fi
|
||||
else
|
||||
start_wgd_debug
|
||||
printf "%s\n" "$dashes"
|
||||
printf "Cancel update. \n"
|
||||
printf "%s\n" "$dashes"
|
||||
fi
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user