Browse Source

update fail2ban v1.0.2 for debian

MHSanaei 1 year ago
parent
commit
38378fe36f
2 changed files with 29 additions and 20 deletions
  1. 15 15
      install.sh
  2. 14 5
      x-ui.sh

+ 15 - 15
install.sh

@@ -81,19 +81,21 @@ fi
 
 install_base() {
     case "${release}" in
-        centos|fedora|almalinux|rocky)
-            yum -y update && yum install -y -q wget curl tar
-            ;;
-        arch|manjaro)
-            pacman -Syu && pacman -Syu --noconfirm wget curl tar
-            ;;
-        *)
-            apt-get update && apt install -y -q wget curl tar
-            ;;
+    centos | almalinux | rocky)
+        yum -y update && yum install -y -q wget curl tar
+        ;;
+    fedora)
+        dnf -y update && dnf install -y -q wget curl tar
+        ;;
+    arch | manjaro)
+        pacman -Syu && pacman -Syu --noconfirm wget curl tar
+        ;;
+    *)
+        apt-get update && apt install -y -q wget curl tar
+        ;;
     esac
 }
 
-
 # This function will be called when user installed x-ui out of security
 config_after_install() {
     echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}"
@@ -167,11 +169,10 @@ install_x-ui() {
 
     # Check the system's architecture and rename the file accordingly
     if [[ $(arch3xui) == "armv5" || $(arch3xui) == "armv6" || $(arch3xui) == "armv7" ]]; then
-
-    mv bin/xray-linux-$(arch3xui) bin/xray-linux-arm
-    chmod +x bin/xray-linux-arm
+        mv bin/xray-linux-$(arch3xui) bin/xray-linux-arm
+        chmod +x bin/xray-linux-arm
     fi
-    
+
     chmod +x x-ui bin/xray-linux-$(arch3xui)
     cp -f x-ui.service /etc/systemd/system/
     wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh
@@ -201,7 +202,6 @@ install_x-ui() {
     echo -e "----------------------------------------------"
 }
 
-
 echo -e "${green}Running...${plain}"
 install_base
 install_x-ui $1

+ 14 - 5
x-ui.sh

@@ -982,12 +982,16 @@ iplimit_main() {
 install_iplimit() {
     if ! command -v fail2ban-client &>/dev/null; then
         echo -e "${green}Fail2ban is not installed. Installing now...!${plain}\n"
+        
         # Check the OS and install necessary packages
         case "${release}" in
             ubuntu|debian)
-                apt update && apt install fail2ban -y ;;
+                wget -O fail2ban.deb https://github.com/fail2ban/fail2ban/releases/download/1.0.2/fail2ban_1.0.2-1.upstream1_all.deb
+                wget -O fail2ban.deb.asc https://github.com/fail2ban/fail2ban/releases/download/1.0.2/fail2ban_1.0.2-1.upstream1_all.deb.asc
+                dpkg -i fail2ban.deb ;;
             centos|almalinux|rocky)
-                yum -y update && yum -y install fail2ban ;;
+                yum update -y && yum install epel-release -y
+                yum -y install fail2ban ;;
             fedora)
                 dnf -y update && dnf -y install fail2ban ;;
             *)
@@ -1027,6 +1031,7 @@ install_iplimit() {
     # Launching fail2ban
     if ! systemctl is-active --quiet fail2ban; then
         systemctl start fail2ban
+        systemctl enable fail2ban
     else
         systemctl restart fail2ban
     fi
@@ -1054,11 +1059,15 @@ remove_iplimit(){
             systemctl stop fail2ban
             case "${release}" in
                 ubuntu|debian)
-                    apt-get purge fail2ban -y;;
+                    apt-get remove -y fail2ban
+                    apt-get purge -y fail2ban -y
+                    apt-get autoremove -y;;
                 centos|almalinux|rocky)
-                    yum remove fail2ban -y;;
+                    yum remove fail2ban -y
+                    yum autoremove -y;;
                 fedora)
-                    dnf remove fail2ban -y;;
+                    dnf remove fail2ban -y
+                    dnf autoremove -y;;
                 *)
                     echo -e "${red}Unsupported operating system. Please uninstall Fail2ban manually.${plain}\n"
                     exit 1 ;;