mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-06 07:50:13 +01:00
Doing some testing across distros
This commit is contained in:
parent
85970f8c96
commit
015b50be5f
97
README.md
97
README.md
@ -12,39 +12,33 @@
|
||||
<a href="https://wakatime.com/badge/user/45f53c7c-9da9-4cb0-85d6-17bd38cc748b/project/5334ae20-e9a6-4c55-9fea-52d4eb9dfba6"><img src="https://wakatime.com/badge/user/45f53c7c-9da9-4cb0-85d6-17bd38cc748b/project/5334ae20-e9a6-4c55-9fea-52d4eb9dfba6.svg" alt="wakatime"></a>
|
||||
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fdonaldzou%2FWGDashboard&count_bg=%2379C83D&title_bg=%23555555&icon=github.svg&icon_color=%23E7E7E7&title=Visitor&edge_flat=false"/></a>
|
||||
</p>
|
||||
<p align="center">Monitoring WireGuard is not convinient, need to login into server and type <code>wg show</code>. That's why this platform is being created, to view all configurations and manage them in a easier way.</p>
|
||||
<p align="center"><small>Note: This project is not affiliate to the official WireGuard Project ;)</small></p>
|
||||
<p align="center">Monitoring WireGuard is not convenient, need to login into server and type <code>wg show</code>. That's why this project is being created, to view all configurations and manage them in a easy way.</p>
|
||||
<p align="center"><small><i>This project is not affiliate to the official WireGuard Project</i></small></p>
|
||||
|
||||
## 📣 What's New: v3.0
|
||||
## 📣 What's New: v4.0
|
||||
|
||||
> I can't thank enough for all of you who wait for this release, and for those who are new to this project, welcome :) Also, huge thanks who sponsored me GitHub :heart:
|
||||
|
||||
- 🎉 **New Features**
|
||||
- **Moved from TinyDB to SQLite**: SQLite provide a better performance and loading speed when getting peers! Also avoided crashing the database due to **race condition**.
|
||||
- **Added Gunicorn WSGI Server**: This could provide more stable on handling HTTP request, and more flexibility in the future (such as HTTPS support). **BIG THANKS to @pgalonza :heart:**
|
||||
- **Add Peers by Bulk:** User can add peers by bulk, just simply set the amount and click add.
|
||||
- **Delete Peers by Bulk**: User can delete peers by bulk, without deleting peers one by one.
|
||||
- **Download Peers in Zip**: User can download all *downloadable* peers in a zip.
|
||||
- **Added Pre-shared Key to peers:** Now each peer can add with a pre-shared key to enhance security. Previously added peers can add the pre-shared key through the peer setting button.
|
||||
- **Redirect Back to Previous Page:** The dashboard will now redirect you back to your previous page if the current session got timed out and you need to sign in again.
|
||||
- **Added Some [🥘 Experimental Functions](#-experimental-functions)**
|
||||
|
||||
- 🪚 **Bug Fixed**
|
||||
- [IP Sorting range issues #99](https://github.com/donaldzou/WGDashboard/issues/99) [❤️ @barryboom]
|
||||
- [INvalid character written to tunnel json file #108](https://github.com/donaldzou/WGDashboard/issues/108) [❤️ @ikidd]
|
||||
- [Add IPv6 #91](https://github.com/donaldzou/WGDashboard/pull/91) [❤️ @pgalonza]
|
||||
- [Added MTU and PersistentKeepalive to QR code and download files #112](https://github.com/donaldzou/WGDashboard/pull/112) [:heart: @reafian]
|
||||
- **And many other bugs provided by our beloved users** :heart:
|
||||
- **Updated dashboard design**: Re-designed some of the section with more modern style and layout, the UI is faster and more responsive, it also uses less memory. But overall is still the same dashboard you're familiarized.
|
||||
- **Peer Job Scheduler**: Now you can schedule jobs for each peer to either **restrict** or **delete** the peer if the peer's total / upload / download data usage exceeded a limit, or you can set a specific datetime to restrict or delete the peer.
|
||||
- **API Key for WGDashboard's REST API**: You can now request all the api endpoint used in the dashboard. For more details please review the API Documentation below.
|
||||
- **Logging**: Dashboard will now log all activity on the dashboard and API requests.
|
||||
- **Time-Based One-Time Password (TOTP)**: You can enable this function to add one more layer of security, and generate the TOTP with your choice of authenticator.
|
||||
- **Designs**
|
||||
- **Real-time Graphs**: You can view real-time data changes with graphs in each configuration.
|
||||
- **Night mode**: You know what that means, it avoids bugs ;)
|
||||
- **Enforce Python Virtual Environment**: I noticed newer Python version (3.12) does not allow to install packages globally, and plus I think is a good idea to use venv.
|
||||
|
||||
- **🧐 Other Changes**
|
||||
- **Key generating moved to front-end**: No longer need to use the server's WireGuard to generate keys, thanks to the `wireguard.js` from the [official repository](https://git.zx2c4.com/wireguard-tools/tree/contrib/keygen-html/wireguard.js)!
|
||||
- **Peer transfer calculation**: each peer will now show all transfer amount (previously was only showing transfer amount from the last configuration start-up).
|
||||
- **UI adjustment on running peers**: peers will have a new style indicating that it is running.
|
||||
- **`wgd.sh` finally can update itself**: So now user could update the whole dashboard from `wgd.sh`, with the `update` command.
|
||||
- **Minified JS and CSS files**: Although only a small changes on the file size, but I think is still a good practice to save a bit of bandwidth ;)
|
||||
- **Deprecated jQuery from the project, and migrated and rewrote the whole front-end with Vue.js. This allow the dashboard is future proofed, and potential cross server access with a desktop app.**
|
||||
- Rewrote the backend into a REST API structure
|
||||
- Improved SQL query efficient
|
||||
- Removed all templates, except for `index.html` where it will load the Vue.js app.
|
||||
|
||||
*And many other small changes for performance and bug fixes! :laughing:*
|
||||
|
||||
> If you have any other brilliant ideas for this project, please shout it in here [#129](https://github.com/donaldzou/WGDashboard/issues/129) :heart:
|
||||
|
||||
**For users who is using `v2.x.x` please be sure to read [this](#please-note-for-user-who-is-using-v231-or-below) before updating WGDashboard ;)**
|
||||
**For users who is using `v2.x.x` please be sure to read [this](#please-note-for-user-who-is-using-v231-or-below) before updating WGDashboard**
|
||||
|
||||
<hr>
|
||||
|
||||
@ -69,19 +63,23 @@
|
||||
|
||||
## 💡 Features
|
||||
|
||||
- **No need to re-configure existing WireGuard configuration! It can search for existed configuration files.**
|
||||
- Easy to use interface, provided username and password protection to the dashboard
|
||||
- Add peers and edit (Allowed IPs, DNS, Private Key...)
|
||||
- View peers and configuration real time details (Data Usage, Latest Handshakes...)
|
||||
- Share your peer configuration with QR code or file download
|
||||
- Testing tool: Ping and Traceroute to your peer's ip
|
||||
- **And more functions are coming up!**
|
||||
- Automatically look for existing WireGuard configuration under `/etc/wireguard`
|
||||
- Easy to use interface, provided credential and TOTP protection to the dashboard
|
||||
- Manage peers and configuration
|
||||
- Add Peers or by bulk with auto-generated information
|
||||
- Edit peer information
|
||||
- Delete peers with ease
|
||||
- Restrict peers
|
||||
- Generate QR Code and `.conf` file for peers
|
||||
- Schedule jobs to delete / restrict peer when conditions are met
|
||||
- View real time peer status
|
||||
- Testing tool: Ping and Traceroute to your peer
|
||||
|
||||
|
||||
## 📝 Requirement
|
||||
|
||||
- Recommend the following OS, tested by our beloved users:
|
||||
- [x] Ubuntu 18.04.1 LTS - 20.04.1 LTS [@Me]
|
||||
- [x] Ubuntu 18.04.1 LTS, 20.04.1 LTS, 22.04.4 LTS [@Me]
|
||||
- [x] Debian GNU/Linux 10 (buster) [❤️ @[robchez](https://github.com/robchez)]
|
||||
- [x] AlmaLinux 8.4 (Electric Cheetah) [❤️ @[barry-smithjr](https://github.com/)]
|
||||
- [x] CentOS 7 [❤️ @[PrzemekSkw](https://github.com/PrzemekSkw)]
|
||||
@ -116,7 +114,7 @@
|
||||
1. Download WGDashboard
|
||||
|
||||
```shell
|
||||
git clone -b v3.0.5 https://github.com/donaldzou/WGDashboard.git wgdashboard
|
||||
git clone -b v4.0 https://github.com/donaldzou/WGDashboard.git wgdashboard
|
||||
|
||||
2. Open the WGDashboard folder
|
||||
|
||||
@ -140,7 +138,7 @@
|
||||
5. Run WGDashboard
|
||||
|
||||
```shell
|
||||
./wgd.sh start
|
||||
sudo ./wgd.sh start
|
||||
```
|
||||
|
||||
**Note**:
|
||||
@ -421,6 +419,33 @@ Starting with `v3.0`, you can simply do `./wgd.sh update` !! (I hope, lol)
|
||||
|
||||
## ⏰ Changelog
|
||||
|
||||
#### v3.0.0 - v3.0.6.2 - Jan 18, 2022
|
||||
|
||||
- 🎉 **New Features**
|
||||
- **Moved from TinyDB to SQLite**: SQLite provide a better performance and loading speed when getting peers! Also avoided crashing the database due to **race condition**.
|
||||
- **Added Gunicorn WSGI Server**: This could provide more stable on handling HTTP request, and more flexibility in the future (such as HTTPS support). **BIG THANKS to @pgalonza :heart:**
|
||||
- **Add Peers by Bulk:** User can add peers by bulk, just simply set the amount and click add.
|
||||
- **Delete Peers by Bulk**: User can delete peers by bulk, without deleting peers one by one.
|
||||
- **Download Peers in Zip**: User can download all *downloadable* peers in a zip.
|
||||
- **Added Pre-shared Key to peers:** Now each peer can add with a pre-shared key to enhance security. Previously added peers can add the pre-shared key through the peer setting button.
|
||||
- **Redirect Back to Previous Page:** The dashboard will now redirect you back to your previous page if the current session got timed out and you need to sign in again.
|
||||
- **Added Some [🥘 Experimental Functions](#-experimental-functions)**
|
||||
|
||||
- 🪚 **Bug Fixed**
|
||||
- [IP Sorting range issues #99](https://github.com/donaldzou/WGDashboard/issues/99) [❤️ @barryboom]
|
||||
- [INvalid character written to tunnel json file #108](https://github.com/donaldzou/WGDashboard/issues/108) [❤️ @ikidd]
|
||||
- [Add IPv6 #91](https://github.com/donaldzou/WGDashboard/pull/91) [❤️ @pgalonza]
|
||||
- [Added MTU and PersistentKeepalive to QR code and download files #112](https://github.com/donaldzou/WGDashboard/pull/112) [:heart: @reafian]
|
||||
- **And many other bugs provided by our beloved users** :heart:
|
||||
- **🧐 Other Changes**
|
||||
- **Key generating moved to front-end**: No longer need to use the server's WireGuard to generate keys, thanks to the `wireguard.js` from the [official repository](https://git.zx2c4.com/wireguard-tools/tree/contrib/keygen-html/wireguard.js)!
|
||||
- **Peer transfer calculation**: each peer will now show all transfer amount (previously was only showing transfer amount from the last configuration start-up).
|
||||
- **UI adjustment on running peers**: peers will have a new style indicating that it is running.
|
||||
- **`wgd.sh` finally can update itself**: So now user could update the whole dashboard from `wgd.sh`, with the `update` command.
|
||||
- **Minified JS and CSS files**: Although only a small changes on the file size, but I think is still a good practice to save a bit of bandwidth ;)
|
||||
|
||||
*And many other small changes for performance and bug fixes! :laughing:*
|
||||
|
||||
#### v2.3.1 - Sep 8, 2021
|
||||
|
||||
- Updated dashboard's name to **WGDashboard**!!
|
||||
|
@ -1012,7 +1012,7 @@ class DashboardConfig:
|
||||
return True, ""
|
||||
|
||||
def generatePassword(self, plainTextPassword: str):
|
||||
return bcrypt.hashpw(plainTextPassword.encode("utf-8"), bcrypt.gensalt(rounds=12))
|
||||
return bcrypt.hashpw(plainTextPassword.encode("utf-8"), bcrypt.gensalt())
|
||||
|
||||
def __checkPassword(self, plainTextPassword: str, hashedPassword: bytes):
|
||||
return bcrypt.checkpw(plainTextPassword.encode("utf-8"), hashedPassword)
|
||||
@ -1206,13 +1206,12 @@ def _getWireguardConfigurationAvailableIP(configName: str) -> tuple[bool, list[s
|
||||
API Routes
|
||||
'''
|
||||
|
||||
|
||||
@app.before_request
|
||||
def auth_req():
|
||||
authenticationRequired = DashboardConfig.GetConfig("Server", "auth_req")[1]
|
||||
d = request.args
|
||||
d = request.headers
|
||||
if authenticationRequired:
|
||||
apiKey = d.get('apiKey')
|
||||
apiKey = d.get('wg-dashboard-apikey')
|
||||
apiKeyEnabled = DashboardConfig.GetConfig("Server", "dashboard_api_key")[1]
|
||||
if apiKey is not None and len(apiKey) > 0 and apiKeyEnabled:
|
||||
apiKeyExist = len(list(filter(lambda x : x.Key == apiKey, DashboardConfig.DashboardAPIKeys))) == 1
|
||||
@ -1786,8 +1785,7 @@ def API_Welcome_Finish():
|
||||
updatePassword, updatePasswordErr = DashboardConfig.SetConfig("Account", "password",
|
||||
{
|
||||
"newPassword": data["newPassword"],
|
||||
"repeatNewPassword": data[
|
||||
"repeatNewPassword"],
|
||||
"repeatNewPassword": data["repeatNewPassword"],
|
||||
"currentPassword": "admin"
|
||||
})
|
||||
updateEnableTotp, updateEnableTotpErr = DashboardConfig.SetConfig("Account", "enable_totp", data["enable_totp"])
|
||||
@ -1806,7 +1804,7 @@ def index():
|
||||
Index page related
|
||||
@return: Template
|
||||
"""
|
||||
return render_template('index_new.html')
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
def backGroundThread():
|
||||
|
@ -2,8 +2,7 @@ bcrypt
|
||||
ifcfg
|
||||
psutil
|
||||
pyotp
|
||||
flask
|
||||
Flask
|
||||
flask-cors
|
||||
icmplib
|
||||
sqlalchemy
|
||||
flask[async]
|
||||
flask-cors
|
||||
gunicorn
|
@ -13,6 +13,7 @@
|
||||
<link rel="apple-touch-icon" sizes="192x192" href="{{ url_for('static',filename='img/192x192ios.png') }}">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="icon" href="{{ url_for('static',filename='img/logo.png') }}"/>
|
||||
<link rel="stylesheet" href="../static/app/dist/assets/index.css">
|
||||
<script src="../static/app/dist/assets/index.js" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
210
src/wgd.sh
210
src/wgd.sh
@ -16,6 +16,7 @@ fi
|
||||
|
||||
dashes='------------------------------------------------------------'
|
||||
equals='============================================================'
|
||||
helpMsg="[WGDashboard] Please check ./log/install.txt for more details. For further assistance, please open a ticket on https://github.com/donaldzou/WGDashboard/issues/new/choose, I'm more than happy to help :)"
|
||||
help () {
|
||||
printf "=================================================================================\n"
|
||||
printf "+ <WGDashboard> by Donald Zou - https://github.com/donaldzou +\n"
|
||||
@ -33,39 +34,184 @@ help () {
|
||||
}
|
||||
|
||||
_check_and_set_venv(){
|
||||
# This function will not be using in v3.0
|
||||
# deb/ubuntu users: might need a 'apt install python3.8-venv'
|
||||
# set up the local environment
|
||||
APP_ROOT=`pwd`
|
||||
VIRTUAL_ENV="${APP_ROOT%/*}/venv"
|
||||
VIRTUAL_ENV="./venv"
|
||||
if [ ! -d $VIRTUAL_ENV ]; then
|
||||
python3 -m venv $VIRTUAL_ENV
|
||||
printf "[WGDashboard] Creating Python Virtual Environment under ./venv\n"
|
||||
{ python3 -m venv $VIRTUAL_ENV; } >> ./log/instal.txt
|
||||
fi
|
||||
printf "[WGDashboard] Activate Python Virtual Environment under ./venv\n"
|
||||
. ${VIRTUAL_ENV}/bin/activate
|
||||
}
|
||||
|
||||
install_wgd(){
|
||||
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 Python 3.7 or above |\n"
|
||||
printf "%s\n" "$dashes"
|
||||
_determineOS(){
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
OS=$ID
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
OS="redhat"
|
||||
# elif [ -f /etc/arch-release ]; then
|
||||
# OS="arch"
|
||||
else
|
||||
printf "[WGDashboard] Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS."
|
||||
printf "%s\n" "$helpMsg"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "db" ]
|
||||
then mkdir "db"
|
||||
fi
|
||||
if [ ! -d "log" ]
|
||||
then mkdir "log"
|
||||
fi
|
||||
printf "| Upgrading pip |\n"
|
||||
python3 -m pip install -U pip > /dev/null 2>&1
|
||||
printf "| Installing latest Python dependencies |\n"
|
||||
python3 -m pip install -U -r requirements.txt > /dev/null 2>&1
|
||||
printf "| WGDashboard installed successfully! |\n"
|
||||
printf "| Enter ./wgd.sh start to start the dashboard |\n"
|
||||
fi
|
||||
}
|
||||
|
||||
_installPython(){
|
||||
case "$OS" in
|
||||
ubuntu|debian)
|
||||
{ sudo apt update ; sudo apt install -y python3; printf "\n\n"; } >> ./log/install.txt
|
||||
;;
|
||||
centos|fedora|redhat)
|
||||
if command -v dnf &> /dev/null; then
|
||||
{ sudo dnf install -y python3; printf "\n\n"; } >> ./log/install.txt
|
||||
else
|
||||
{ sudo yum install -y python3; printf "\n\n"; } >> ./log/install.txt
|
||||
fi
|
||||
;;
|
||||
# arch)
|
||||
# { sudo pacman -Sy python python-pip; printf "\n\n"; } >> ./log/install.txt
|
||||
# ;;
|
||||
# *)
|
||||
# printf "[WGDashboard] Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based and Arch-based OS."
|
||||
# printf "%s" "$helpMsg"
|
||||
# exit 1
|
||||
# ;;
|
||||
esac
|
||||
|
||||
if ! python3 --version > /dev/null 2>&1
|
||||
then
|
||||
printf "[WGDashboard] Python is still not installed, halting script now.\n"
|
||||
printf "%s\n" "$helpMsg"
|
||||
exit 1
|
||||
else
|
||||
printf "[WGDashboard] \xE2\x9C\x94 Python is installed\n"
|
||||
fi
|
||||
}
|
||||
|
||||
_installPythonVenv(){
|
||||
case "$OS" in
|
||||
ubuntu|debian)
|
||||
{ sudo apt update ; sudo apt install -y python3-venv; printf "\n\n"; } >> ./log/install.txt
|
||||
;;
|
||||
centos|fedora|redhat)
|
||||
if command -v dnf &> /dev/null; then
|
||||
{ sudo dnf install -y python3-virtualenv; printf "\n\n"; } >> ./log/install.txt
|
||||
else
|
||||
{ sudo yum install -y python3-virtualenv; printf "\n\n"; } >> ./log/install.txt
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
printf "[WGDashboard] Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS."
|
||||
printf "%s\n" "$helpMsg"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! python3 -m venv -h > /dev/null 2>&1
|
||||
then
|
||||
printf "[WGDashboard] Python Virtual Environment is still not installed, halting script now.\n"
|
||||
printf "%s\n" "$helpMsg"
|
||||
else
|
||||
printf "[WGDashboard] \xE2\x9C\x94 Python Virtual Environment is installed\n"
|
||||
fi
|
||||
}
|
||||
|
||||
_installPythonPip(){
|
||||
case "$OS" in
|
||||
ubuntu|debian)
|
||||
{ sudo apt update ; sudo apt install -y python3-pip; printf "\n\n"; } >> ./log/install.txt
|
||||
;;
|
||||
centos|fedora|redhat)
|
||||
if command -v dnf &> /dev/null; then
|
||||
{ sudo dnf install -y python3-pip; printf "\n\n"; } >> ./log/install.txt
|
||||
else
|
||||
{ sudo yum install -y python3-pip printf "\n\n"; } >> ./log/install.txt
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
printf "[WGDashboard] Sorry, your OS is not support auto install. Currently the install script only support Debian-based, Red Hat-based OS."
|
||||
printf "%s\n" "$helpMsg"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if ! python3 -m pip -h > /dev/null 2>&1
|
||||
then
|
||||
printf "[WGDashboard] Python Package Manager (PIP) is still not installed, halting script now.\n"
|
||||
printf "%s\n" "$helpMsg"
|
||||
else
|
||||
printf "[WGDashboard] \xE2\x9C\x94 Python Package Manager (PIP) is installed\n"
|
||||
fi
|
||||
}
|
||||
|
||||
_checkWireguard(){
|
||||
if ! wg -h > /dev/null 2>&1
|
||||
then
|
||||
printf "[WGDashboard] WireGuard is not installed. Please follow instruction on https://www.wireguard.com/install/ to install. \n"
|
||||
exit 1
|
||||
fi
|
||||
if ! wg-quick -h > /dev/null 2>&1
|
||||
then
|
||||
printf "[WGDashboard] WireGuard is not installed. Please follow instruction on https://www.wireguard.com/install/ to install. \n"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
install_wgd(){
|
||||
printf "[WGDashboard] Starting to install WGDashboard\n"
|
||||
_checkWireguard
|
||||
|
||||
if [ ! -d "log" ]
|
||||
then
|
||||
printf "[WGDashboard] Creating ./log folder\n"
|
||||
mkdir "log"
|
||||
fi
|
||||
_determineOS
|
||||
if ! python3 --version > /dev/null 2>&1
|
||||
then
|
||||
printf "[WGDashboard] Python is not installed, trying to install now\n"
|
||||
_installPython
|
||||
else
|
||||
printf "[WGDashboard] \xE2\x9C\x94 Python is installed\n"
|
||||
fi
|
||||
if ! python3 -m venv -h > /dev/null 2>&1
|
||||
then
|
||||
printf "[WGDashboard] Python Virtual Environment is not installed, trying to install now\n"
|
||||
_installPythonVenv
|
||||
else
|
||||
printf "[WGDashboard] \xE2\x9C\x94 Python Virtual Environment is installed\n"
|
||||
fi
|
||||
if ! python3 -m pip -h > /dev/null 2>&1
|
||||
then
|
||||
printf "[WGDashboard] Python Package Manager (PIP) is not installed, trying to install now\n"
|
||||
_installPythonPip
|
||||
else
|
||||
printf "[WGDashboard] \xE2\x9C\x94 Python Package Manager (PIP) is installed\n"
|
||||
fi
|
||||
|
||||
|
||||
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] WGDashboard required Python 3.7 or above\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "db" ]
|
||||
then
|
||||
printf "[WGDashboard] Creating ./db folder\n"
|
||||
mkdir "db"
|
||||
fi
|
||||
_check_and_set_venv
|
||||
printf "[WGDashboard] Upgrading Python Package Manage (PIP)\n"
|
||||
{ date; python3 -m pip install -g pip printf "\n\n"; } >> ./log/install.txt
|
||||
printf "[WGDashboard] Installing latest Python dependencies\n"
|
||||
{ date; python3 -m pip install -g -r requirements.txt ; printf "\n\n"; } >> ./log/install.txt
|
||||
printf "[WGDashboard] WGDashboard installed successfully!\n"
|
||||
printf "[WGDashboard] Enter ./wgd.sh start to start the dashboard\n"
|
||||
}
|
||||
|
||||
check_wgd_status(){
|
||||
if test -f "$PID_FILE"; then
|
||||
@ -93,18 +239,16 @@ certbot_renew_ssl () {
|
||||
|
||||
gunicorn_start () {
|
||||
printf "%s\n" "$dashes"
|
||||
printf "| Starting WGDashboard with Gunicorn in the background. |\n"
|
||||
if [ ! -d "log" ]; then
|
||||
mkdir "log"
|
||||
fi
|
||||
printf "[WGDashboard] Starting WGDashboard with Gunicorn in the background.\n"
|
||||
d=$(date '+%Y%m%d%H%M%S')
|
||||
if [[ $USER == root ]]; then
|
||||
export PATH=$PATH:/usr/local/bin:$HOME/.local/bin
|
||||
fi
|
||||
_check_and_set_venv
|
||||
gunicorn --access-logfile log/access_"$d".log \
|
||||
--log-level 'debug' --capture-output \
|
||||
--error-logfile log/error_"$d".log 'dashboard:app'
|
||||
printf "| Log files is under log/ |\n"
|
||||
printf "[WGDashboard] Log files is under ./log\n"
|
||||
printf "%s\n" "$dashes"
|
||||
}
|
||||
|
||||
@ -113,6 +257,7 @@ gunicorn_stop () {
|
||||
}
|
||||
|
||||
start_wgd () {
|
||||
_checkWireguard
|
||||
gunicorn_start
|
||||
}
|
||||
|
||||
@ -126,6 +271,7 @@ stop_wgd() {
|
||||
|
||||
start_wgd_debug() {
|
||||
printf "%s\n" "$dashes"
|
||||
_checkWireguard
|
||||
printf "| Starting WGDashboard in the foreground. |\n"
|
||||
python3 "$app_name"
|
||||
printf "%s\n" "$dashes"
|
||||
@ -146,9 +292,9 @@ update_wgd() {
|
||||
git stash > /dev/null 2>&1
|
||||
git pull https://github.com/donaldzou/WGDashboard.git $new_ver --force > /dev/null 2>&1
|
||||
printf "| Upgrading pip |\n"
|
||||
python3 -m pip install -U pip > /dev/null 2>&1
|
||||
python3 -m pip install -U pip --root-user-action > /dev/null 2>&1
|
||||
printf "| Installing latest Python dependencies |\n"
|
||||
python3 -m pip install -U -r requirements.txt > /dev/null 2>&1
|
||||
python3 -m pip install -U -r requirements.txt --root-user-action > /dev/null 2>&1
|
||||
printf "| Update Successfully! |\n"
|
||||
printf "%s\n" "$dashes"
|
||||
rm wgd.sh.old
|
||||
|
Loading…
Reference in New Issue
Block a user