Skip to content

Commit

Permalink
update FtTunnel.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Ptechgithub committed Sep 19, 2023
1 parent e1cd4c0 commit 77db0f0
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions FtTunnel.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
#!/bin/bash

root_access() {
# Check if the script is running as root
if [ "$EUID" -ne 0 ]; then
echo "This script requires root access. please run as root."
exit 1
fi
}

# Function to check if wget is installed, and install it if not
check_dependencies() {
if ! command -v wget &> /dev/null; then
echo "wget is not installed. Installing..."
sudo apt-get install wget
package_manager=""

# Detect the package manager
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"
else
echo "Unsupported package manager. Please install dependencies manually."
return
fi

if ! command -v lsof &> /dev/null; then
echo "lsof is not installed. Installing..."
sudo apt-get install lsof
fi
# Define the list of dependencies
dependencies=("wget" "lsof" "iptables" "unzip")

if ! command -v iptables &> /dev/null; then
echo "iptables is not installed. Installing..."
sudo apt-get install iptables
fi
# Install missing dependencies
for dependency in "${dependencies[@]}"; do
if ! command -v "$dependency"; then
echo "$dependency is not installed. Installing..."
sudo "$package_manager" install "$dependency" -y
fi
done
}


#Check installed service
check_installed() {
if [ -f "/etc/systemd/system/faketunnel.service" ]; then
Expand Down Expand Up @@ -82,6 +101,7 @@ configure_arguments() {

# Function to handle installation single port
install_single() {
root_access
check_dependencies
check_installed2
install_ftt
Expand Down Expand Up @@ -132,6 +152,7 @@ uninstall_single() {

# Function to handle installation
install_multi() {
root_access
check_dependencies
check_installed
install_ftt
Expand Down

0 comments on commit 77db0f0

Please sign in to comment.