#[fail2ban] EXCLUDE your ip in jail # #!/bin/sh # debaniptuff.sh # by E32 monipamoi="66.66.66.66" MONFILE="/etc/fail2ban/jail.local" echo -e "\n Script: $0 \n" [[ -z "$1" ]] && echo " [ADD IP] $monipamoi to $MONFILE" || monipamoi=$1 # && echo " ADD IP: $monipamoi" # Check si le fichier existe ! if [[ -f $MONFILE ]];then echo " ✅$MONFILE exists" else echo " ⛔️$MONFILE doesn't exist" exit 1 fi pyestonsed() { sed -i "/ignoreip /c\ignoreip = 127.0.0.1 192.168.1.0/24 $monipamoi" /etc/fail2ban/jail.local } backupfile() { #On backup avant de tout nicker cp /etc/fail2ban/jail.local /etc/fail2ban/jail.local_backup } # On execute le bourdel # Check si la ligfne à modifier exist # -x, --line-regexp # Select only those matches that exactly match the whole line. # -q, --quiet, --silent if grep -q ignoreip "$MONFILE" then echo " ✅ OK let's go Baby" [[ -z "$monipamoi" ]] && echo " NO IP provided ... exit script !" ; exit 1 || echo " ADD IP: $monipamoi" backupfile pyestonsed else echo " ⛔️ NO code to modify found" exit 1 fi # echo -e "\n ✅remplacement IP: ${monipamoi} [OK]\n"