mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 23:27:45 +01:00
Merge branch 'main' into change-path
This commit is contained in:
commit
99abe6bcd2
1
.gitignore
vendored
1
.gitignore
vendored
@ -14,4 +14,3 @@ private_key.txt
|
|||||||
public_key.txt
|
public_key.txt
|
||||||
venv/**
|
venv/**
|
||||||
log/**
|
log/**
|
||||||
*~
|
|
@ -1 +0,0 @@
|
|||||||
You can delete this later ;)
|
|
54
src/wgd.sh
54
src/wgd.sh
@ -32,37 +32,25 @@ _check_and_set_venv(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
install_wgd(){
|
install_wgd(){
|
||||||
# Check Python3 version
|
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 >= 8) 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");')
|
||||||
if [ $version_pass == "0" ]
|
if [ $version_pass == "0" ]
|
||||||
then printf "| WGDashboard required Python3.8+ |\n"
|
then printf "| WGDashboard required Python 3.7 or above |\n"
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
rm db/hi.txt > /dev/null 2>&1
|
if [ ! -d "db" ]
|
||||||
|
then mkdir "db"
|
||||||
|
fi
|
||||||
if [ ! -d "log" ]
|
if [ ! -d "log" ]
|
||||||
then mkdir "log"
|
then mkdir "log"
|
||||||
fi
|
fi
|
||||||
|
printf "| Upgrading pip |\n"
|
||||||
|
python3 -m pip install -U pip
|
||||||
printf "| Installing latest Python dependencies |\n"
|
printf "| Installing latest Python dependencies |\n"
|
||||||
|
python3 -m pip install -U -r requirements.txt
|
||||||
# set up the local environment
|
printf "| WGDashboard installed successfully! |\n"
|
||||||
_check_and_set_venv
|
printf "| Enter ./wgd start to start the dashboard |\n"
|
||||||
${VIRTUAL_ENV}/bin/python3 -m pip -U pip
|
|
||||||
${VIRTUAL_ENV}/bin/python3 -m pip install -U -r requirements.txt
|
|
||||||
printf "| WGDashboard installed successfully! |\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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +64,6 @@ check_wgd_status(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_wgd () {
|
start_wgd () {
|
||||||
_check_and_set_venv
|
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
printf "| Starting WGDashboard in the background. |\n"
|
printf "| Starting WGDashboard in the background. |\n"
|
||||||
if [ ! -d "log" ]
|
if [ ! -d "log" ]
|
||||||
@ -94,7 +81,6 @@ stop_wgd() {
|
|||||||
|
|
||||||
start_wgd_debug() {
|
start_wgd_debug() {
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
_check_and_set_venv
|
|
||||||
printf "| Starting WGDashboard in the foreground. |\n"
|
printf "| Starting WGDashboard in the foreground. |\n"
|
||||||
python3 "$app_name"
|
python3 "$app_name"
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
@ -107,15 +93,21 @@ update_wgd() {
|
|||||||
read up
|
read up
|
||||||
if [ "$up" = "Y" ]; then
|
if [ "$up" = "Y" ]; then
|
||||||
printf "| Shutting down WGDashboard... |\n"
|
printf "| Shutting down WGDashboard... |\n"
|
||||||
kill "$(ps aux | grep "[p]ython3 $app_name" | awk '{print $2}')"
|
if check_wgd_status; then
|
||||||
|
stop_wgd
|
||||||
|
fi
|
||||||
|
mv wgd.sh wgd.sh.old
|
||||||
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
|
||||||
|
# git pull https://github.com/donaldzou/wireguard-dashboard.git $new_ver --force > /dev/null 2>&1
|
||||||
|
printf "| Upgrading pip |\n"
|
||||||
|
python3 -m pip install -U pip
|
||||||
printf "| Installing latest Python dependencies |\n"
|
printf "| Installing latest Python dependencies |\n"
|
||||||
_check_and_set_venv
|
python3 -m pip install -U -r requirements.txt
|
||||||
python3 -m pip install -r requirements.txt > /dev/null 2>&1
|
|
||||||
printf "| Update Successfully! |\n"
|
printf "| Update Successfully! |\n"
|
||||||
start_wgd
|
printf "%s\n" "$dashes"
|
||||||
|
rm wgd.sh.old
|
||||||
else
|
else
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
printf "| Update Canceled. |\n"
|
printf "| Update Canceled. |\n"
|
||||||
@ -150,7 +142,9 @@ if [ "$#" != 1 ];
|
|||||||
elif [ "$1" = "update" ]; then
|
elif [ "$1" = "update" ]; then
|
||||||
update_wgd
|
update_wgd
|
||||||
elif [ "$1" = "install" ]; then
|
elif [ "$1" = "install" ]; then
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
install_wgd
|
install_wgd
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
elif [ "$1" = "restart" ]; then
|
elif [ "$1" = "restart" ]; then
|
||||||
if check_wgd_status; then
|
if check_wgd_status; then
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
|
Loading…
Reference in New Issue
Block a user