From bc29b89a16b7828cffdb5336bb46000660c3b226 Mon Sep 17 00:00:00 2001 From: Dselen Date: Mon, 26 Aug 2024 13:07:42 -0500 Subject: [PATCH] Rebased and going further --- docker/alpine/Dockerfile | 3 +- docker/alpine/entrypoint.sh | 11 ------- src/wgd.sh | 62 +++++++++++++++++++++---------------- 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/docker/alpine/Dockerfile b/docker/alpine/Dockerfile index 38ec84d..ad6b58a 100644 --- a/docker/alpine/Dockerfile +++ b/docker/alpine/Dockerfile @@ -18,8 +18,7 @@ ENV update="yes" # Doing package management operations, such as upgrading RUN apk update \ && apk add --no-cache bash git curl tzdata \ - wireguard-tools sudo \ - py3-pip py3-psutil py3-bcrypt + sudo py3-psutil py3-bcrypt # Using WGDASH -- like wg_net functionally as a ARG command. But it is needed in entrypoint.sh so it needs to be exported as environment variable. ENV WGDASH=/opt/wireguarddashboard diff --git a/docker/alpine/entrypoint.sh b/docker/alpine/entrypoint.sh index 4cda068..5d815b5 100644 --- a/docker/alpine/entrypoint.sh +++ b/docker/alpine/entrypoint.sh @@ -80,17 +80,6 @@ clean_up() { echo "Removed unneeded logs!" } -#update_checker() { - #if [ "$update" = "yes" ]; then - # echo "Activating Python venv and executing the WireGuard Dashboard service." - # . "${WGDASH}/src/venv/bin/activate" - # cd "${WGDASH}"/src || exit - # bash wgd.sh update - #else - # echo "Auto Updater disabled" - #fi -#} - # === SET ENV VARS === set_envvars() { printf "\n------------- SETTING ENVIRONMENT VARIABLES ----------------\n" diff --git a/src/wgd.sh b/src/wgd.sh index ed8e8c0..680698d 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -156,7 +156,6 @@ _installPythonVenv(){ } _installPythonPip(){ - if ! $pythonExecutable -m pip -h > /dev/null 2>&1 then case "$OS" in @@ -195,34 +194,43 @@ _installPythonPip(){ fi } -_checkWireguard(){ - if [ ! wg -h > /dev/null 2>&1 ] || [ ! wg-quick -h > /dev/null 2>&1 ] - then - case "$OS" in - ubuntu|debian) - { sudo apt update ; sudo apt-get install -y wireguard; printf "\n\n"; } &>> ./log/install.txt - ;; - #centos|fedora|redhat|rhel) - # if [ "$pythonExecutable" = "python3" ]; then - # { sudo dnf install -y python3-pip; printf "\n\n"; } >> ./log/install.txt - # else - # { sudo dnf install -y ${pythonExecutable}-pip; printf "\n\n"; } >> ./log/install.txt - # fi - #;; - alpine) - { sudo apk update; sudo apk add wireguard-tools ; printf "\n\n"; } >> ./log/install.txt - ;; - *) - printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark" - printf "%s\n" "$helpMsg" - kill $TOP_PID - ;; - esac - fi +checkWireguard(){ + # Check if wg and wg-quick are installed + if ! command -v wg > /dev/null 2>&1 || ! command -v wg-quick > /dev/null 2>&1 + then + case "$OS" in + ubuntu|debian) + { + sudo apt update && sudo apt-get install -y wireguard; + printf "\nWireGuard installed on %s.\n\n" "$OS"; + } &>> ./log/install.txt + ;; + centos|fedora|redhat|rhel) + { + sudo dnf install -y wireguard-tools; + printf "\nWireGuard installed on %s.\n\n" "$OS"; + } &>> ./log/install.txt + ;; + alpine) + { + sudo apk update && sudo apk add wireguard-tools; + printf "\nWireGuard installed on %s.\n\n" "$OS"; + } &>> ./log/install.txt + ;; + *) + printf "[WGDashboard] %s Sorry, your OS is not supported. Currently, the install script only supports Debian-based, Red Hat-based, and Alpine Linux.\n" "$heavy_crossmark" + printf "%s\n" "$helpMsg" + kill $TOP_PID + ;; + esac + else + printf "WireGuard is already installed.\n" + fi } + _checkPythonVersion(){ version_pass=$($pythonExecutable -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 10) else print("0");') version=$($pythonExecutable --version) @@ -250,8 +258,6 @@ _checkPythonVersion(){ install_wgd(){ printf "[WGDashboard] Starting to install WGDashboard\n" - _checkWireguard - sudo chmod -R 755 /etc/wireguard/ if [ ! -d "log" ] then @@ -270,6 +276,8 @@ install_wgd(){ _checkPythonVersion _installPythonVenv _installPythonPip + _checkWireguard + sudo chmod -R 755 /etc/wireguard/ if [ ! -d "db" ] then