1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-19 05:50:10 +01:00

Merge branch 'main' into gunicorn-tmp

# Conflicts:
#	src/wgd.sh
This commit is contained in:
Galonza Peter 2021-12-21 22:38:31 +03:00
commit 4cef39d3b1
4 changed files with 50 additions and 9 deletions

3
.gitignore vendored
View File

@ -12,3 +12,6 @@ src/static/pic.xd
*.conf *.conf
private_key.txt private_key.txt
public_key.txt public_key.txt
venv/**
log/**
*~

View File

@ -1,8 +1,14 @@
<hr> <hr>
<p align=center>Please provide your OS name and version if you can run the dashboard on it perfectly in <a href="https://github.com/donaldzou/wireguard-dashboard/issues/31">#31</a>, since I only tested on Ubuntu. Thank you!</p>
<hr>
> Hi! I'm planning the next major update for this project, please let me know if you have any suggestions or feature requests ;) You can create an issue with the "Feature request" template. Cheers!
### Help Wanted
> If anyone know a better way to distribute releases of python application other than GitHub, please let me know in <a href="https://github.com/donaldzou/wireguard-dashboard/issues/103">#103</a>!
> Please provide your OS name and version if you can run the dashboard on it perfectly in <a href="https://github.com/donaldzou/wireguard-dashboard/issues/31">#31</a>, since I only tested on Ubuntu. Thank you!
<hr>
<p align="center"> <p align="center">
<img alt="WGDashboard" src="img/logo.png" width="128"> <img alt="WGDashboard" src="img/logo.png" width="128">
</p> </p>
@ -13,6 +19,7 @@
</p> </p>
<p align="center"> <p align="center">
<a href="https://github.com/donaldzou/wireguard-dashboard/releases/latest"><img src="https://img.shields.io/github/v/release/donaldzou/wireguard-dashboard"></a> <a href="https://github.com/donaldzou/wireguard-dashboard/releases/latest"><img src="https://img.shields.io/github/v/release/donaldzou/wireguard-dashboard"></a>
<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>
</p> </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">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"><small>Note: This project is not affiliate to the official WireGuard Project ;)</small></p>

View File

@ -1,11 +1,14 @@
[Unit] [Unit]
After=netword.service After=syslog.target network-online.target
ConditionPathIsDirectory=/etc/wireguard
[Service] [Service]
WorkingDirectory=<your dashboard directory full path here> Environment="VIRTUAL_ENV={{VIRTUAL_ENV}}"
ExecStart=/usr/bin/python3 <your dashboard directory full path here>dashboard.py WorkingDirectory={{APP_ROOT}}
ExecStart={{VIRTUAL_ENV}}/bin/python3 {{APP_ROOT}}dashboard.py
PrivateTmp=yes
Restart=always Restart=always
[Install] [Install]
WantedBy=default.target WantedBy=multi-user.target

View File

@ -29,6 +29,17 @@ help () {
printf "=================================================================================\n" printf "=================================================================================\n"
} }
_check_and_set_venv(){
# deb/ubuntu users: might need a 'apt install python3.8-venv'
# set up the local environment
APP_ROOT=`pwd`
VIRTUAL_ENV="${APP_ROOT%/*}/venv"
if [ ! -d $VIRTUAL_ENV ]; then
python3 -m venv $VIRTUAL_ENV
fi
. ${VIRTUAL_ENV}/activate
}
install_wgd(){ install_wgd(){
# Check Python3 version # Check Python3 version
version_pass=$(python3 -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 7) 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");')
@ -42,9 +53,24 @@ install_wgd(){
then mkdir "log" then mkdir "log"
fi fi
printf "| Installing latest Python dependencies |\n" printf "| Installing latest Python dependencies |\n"
# set up the local environment
_check_and_set_venv
python3 -m pip install -r requirements.txt > /dev/null 2>&1 python3 -m pip install -r requirements.txt > /dev/null 2>&1
printf "| WGDashboard installed successfully! |\n" printf "| WGDashboard installed successfully! |\n"
printf "| Starting Dashboard |\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
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 start_wgd
} }
@ -108,6 +134,7 @@ gunicorn_stop () {
} }
start_wgd () { start_wgd () {
_check_and_set_venv
if [[ $environment == 'production' ]]; then if [[ $environment == 'production' ]]; then
gunicorn_start gunicorn_start
else else
@ -132,6 +159,7 @@ stop_wgd() {
} }
start_wgd_debug() { start_wgd_debug() {
_check_and_set_venv
printf "%s\n" "$dashes" printf "%s\n" "$dashes"
printf "| Starting WGDashboard in the foreground. |\n" printf "| Starting WGDashboard in the foreground. |\n"
python3 "$app_name" python3 "$app_name"
@ -150,6 +178,7 @@ update_wgd() {
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
printf "| Installing latest Python dependencies |\n" printf "| Installing latest Python dependencies |\n"
_check_and_set_venv
python3 -m pip install -r requirements.txt > /dev/null 2>&1 python3 -m pip install -r requirements.txt > /dev/null 2>&1
printf "| Update Successfully! |\n" printf "| Update Successfully! |\n"
start_wgd start_wgd
@ -208,4 +237,3 @@ if [ "$#" != 1 ];
help help
fi fi
fi fi