From ebb71355aeb32548616e1b57721db81b75e6586b Mon Sep 17 00:00:00 2001 From: Peyman <118217228+Ptechgithub@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:27:02 +0330 Subject: [PATCH] update FTunnel.sh --- FTunnel.sh | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/FTunnel.sh b/FTunnel.sh index 2e0eb24..d5cd5d4 100644 --- a/FTunnel.sh +++ b/FTunnel.sh @@ -9,17 +9,36 @@ root_access() { } # Function to check if wget is installed, and install it if not -check_dependencies() { - if [ -x "$(command -v apt-get)" ]; then - package_manager="apt-get" - elif [ -x "$(command -v yum)" ]; then - package_manager="yum" - elif [ -x "$(command -v dnf)" ]; then - package_manager="dnf" +detect_distribution() { + # Detect the Linux distribution + if [ -f /etc/os-release ]; then + source /etc/os-release + case "$ID" in + ubuntu) + package_manager="apt-get" + ;; + debian) + package_manager="apt-get" + ;; + centos) + package_manager="yum" + ;; + fedora) + package_manager="dnf" + ;; + *) + echo "Unsupported distribution!" + exit 1 + ;; + esac else - echo "Unsupported package manager. Please install wget, lsof, and iptables manually." + echo "Unsupported distribution!" exit 1 fi +} + +check_dependencies() { + detect_distribution if ! command -v wget &> /dev/null; then echo "wget is not installed. Installing..."