mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-06 16:00:28 +01:00
Did some refactor on wgd.sh
This commit is contained in:
parent
c012b8c4a5
commit
e21853286e
26
src/wgd.sh
26
src/wgd.sh
@ -65,8 +65,6 @@ _determineOS(){
|
|||||||
OS=$ID
|
OS=$ID
|
||||||
elif [ -f /etc/redhat-release ]; then
|
elif [ -f /etc/redhat-release ]; then
|
||||||
OS="redhat"
|
OS="redhat"
|
||||||
# elif [ -f /etc/arch-release ]; then
|
|
||||||
# OS="arch"
|
|
||||||
else
|
else
|
||||||
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS." "$heavy_crossmark"
|
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS." "$heavy_crossmark"
|
||||||
printf "%s\n" "$helpMsg"
|
printf "%s\n" "$helpMsg"
|
||||||
@ -129,18 +127,6 @@ _installPythonVenv(){
|
|||||||
ubuntu|debian)
|
ubuntu|debian)
|
||||||
{ sudo apt-get update; sudo apt-get install ${pythonExecutable}-venv; } &>> ./log/install.txt
|
{ sudo apt-get update; sudo apt-get install ${pythonExecutable}-venv; } &>> ./log/install.txt
|
||||||
;;
|
;;
|
||||||
# centos|fedora|redhat|rhel)
|
|
||||||
# if command -v dnf &> /dev/null; then
|
|
||||||
# { sudo dnf install -y ${pythonExecutable}-virtualenv; printf "\n\n"; } >> ./log/install.txt
|
|
||||||
# else
|
|
||||||
# { sudo yum install -y ${pythonExecutable}-virtualenv; printf "\n\n"; } >> ./log/install.txt
|
|
||||||
# fi
|
|
||||||
# ;;
|
|
||||||
# *)
|
|
||||||
# printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS.\n" "$heavy_crossmark"
|
|
||||||
# printf "%s\n" "$helpMsg"
|
|
||||||
# kill $TOP_PID
|
|
||||||
# ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -337,18 +323,19 @@ stop_wgd() {
|
|||||||
|
|
||||||
startwgd_docker() {
|
startwgd_docker() {
|
||||||
_checkWireguard
|
_checkWireguard
|
||||||
printf "[WGDashboard] WireGuard Config Started\n"
|
printf "[WGDashboard][Docker] WireGuard configuration started\n"
|
||||||
{ date; start_core ; printf "\n\n"; } >> ./log/install.txt
|
{ date; start_core ; printf "\n\n"; } >> ./log/install.txt
|
||||||
gunicorn_start
|
gunicorn_start
|
||||||
}
|
}
|
||||||
|
|
||||||
start_core() {
|
start_core() {
|
||||||
local iptable_dir="/opt/wireguarddashboard/src/iptable-rules"
|
local iptable_dir="/opt/wireguarddashboard/src/iptable-rules"
|
||||||
# Check if wg0.conf exists in /etc/wireguard
|
# Check if wg0.conf exists in /etc/wireguard
|
||||||
if [[ ! -f /etc/wireguard/wg0.conf ]]; then
|
if [[ ! -f /etc/wireguard/wg0.conf ]]; then
|
||||||
echo "wg0.conf not found. Running Generate Configuration."
|
echo "[WGDashboard][Docker] wg0.conf not found. Running generate configuration."
|
||||||
newconf_wgd
|
newconf_wgd
|
||||||
else
|
else
|
||||||
echo "wg0.conf already exists. Skipping WireGuard Config Generation."
|
echo "[WGDashboard][Docker] wg0.conf already exists. Skipping WireGuard configuration generation."
|
||||||
fi
|
fi
|
||||||
# Re-assign config_files to ensure it includes any newly created configurations
|
# Re-assign config_files to ensure it includes any newly created configurations
|
||||||
local config_files=$(find /etc/wireguard -type f -name "*.conf")
|
local config_files=$(find /etc/wireguard -type f -name "*.conf")
|
||||||
@ -391,7 +378,6 @@ start_wgd_debug() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
update_wgd() {
|
update_wgd() {
|
||||||
|
|
||||||
_determineOS
|
_determineOS
|
||||||
if ! python3 --version > /dev/null 2>&1
|
if ! python3 --version > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
@ -466,7 +452,7 @@ if [ "$#" != 1 ];
|
|||||||
if check_wgd_status; then
|
if check_wgd_status; then
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
stop_wgd
|
stop_wgd
|
||||||
printf "| WGDashboard is stopped. |\n"
|
printf "[WGDashboard] WGDashboard is stopped.\n"
|
||||||
sleep 4
|
sleep 4
|
||||||
start_wgd
|
start_wgd
|
||||||
else
|
else
|
||||||
@ -474,7 +460,7 @@ if [ "$#" != 1 ];
|
|||||||
fi
|
fi
|
||||||
elif [ "$1" = "debug" ]; then
|
elif [ "$1" = "debug" ]; then
|
||||||
if check_wgd_status; then
|
if check_wgd_status; then
|
||||||
printf "| WGDashboard is already running. |\n"
|
printf "[WGDashboard] WGDashboard is already running.\n"
|
||||||
else
|
else
|
||||||
start_wgd_debug
|
start_wgd_debug
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user