mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-21 23:01:39 +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
|
||||
elif [ -f /etc/redhat-release ]; then
|
||||
OS="redhat"
|
||||
# elif [ -f /etc/arch-release ]; then
|
||||
# OS="arch"
|
||||
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 "%s\n" "$helpMsg"
|
||||
@ -129,18 +127,6 @@ _installPythonVenv(){
|
||||
ubuntu|debian)
|
||||
{ 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
|
||||
fi
|
||||
|
||||
@ -337,18 +323,19 @@ stop_wgd() {
|
||||
|
||||
startwgd_docker() {
|
||||
_checkWireguard
|
||||
printf "[WGDashboard] WireGuard Config Started\n"
|
||||
printf "[WGDashboard][Docker] WireGuard configuration started\n"
|
||||
{ date; start_core ; printf "\n\n"; } >> ./log/install.txt
|
||||
gunicorn_start
|
||||
}
|
||||
|
||||
start_core() {
|
||||
local iptable_dir="/opt/wireguarddashboard/src/iptable-rules"
|
||||
# Check if wg0.conf exists in /etc/wireguard
|
||||
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
|
||||
else
|
||||
echo "wg0.conf already exists. Skipping WireGuard Config Generation."
|
||||
echo "[WGDashboard][Docker] wg0.conf already exists. Skipping WireGuard configuration generation."
|
||||
fi
|
||||
# Re-assign config_files to ensure it includes any newly created configurations
|
||||
local config_files=$(find /etc/wireguard -type f -name "*.conf")
|
||||
@ -391,7 +378,6 @@ start_wgd_debug() {
|
||||
}
|
||||
|
||||
update_wgd() {
|
||||
|
||||
_determineOS
|
||||
if ! python3 --version > /dev/null 2>&1
|
||||
then
|
||||
@ -466,7 +452,7 @@ if [ "$#" != 1 ];
|
||||
if check_wgd_status; then
|
||||
printf "%s\n" "$dashes"
|
||||
stop_wgd
|
||||
printf "| WGDashboard is stopped. |\n"
|
||||
printf "[WGDashboard] WGDashboard is stopped.\n"
|
||||
sleep 4
|
||||
start_wgd
|
||||
else
|
||||
@ -474,7 +460,7 @@ if [ "$#" != 1 ];
|
||||
fi
|
||||
elif [ "$1" = "debug" ]; then
|
||||
if check_wgd_status; then
|
||||
printf "| WGDashboard is already running. |\n"
|
||||
printf "[WGDashboard] WGDashboard is already running.\n"
|
||||
else
|
||||
start_wgd_debug
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user