X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fpostinst;h=a669349b552a071f0d5c4eaa17fe8a252d7872f5;hb=b086d514ba1b5d92d683220ba7a112124b86bf7a;hp=2254b3819caa663a267b51d13be2fe5ad6a55a53;hpb=077c74632a01d75b9d12a96af0b9d85e6217a72f;p=fail2ban-cn.git diff --git a/debian/postinst b/debian/postinst index 2254b38..a669349 100755 --- a/debian/postinst +++ b/debian/postinst @@ -4,7 +4,7 @@ set -e [ "$1" = "configure" ] || exit 0 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx -# Load CARNet Tools +# Load CARNET Tools . /usr/share/carnet-tools/functions.sh CONF="/etc/fail2ban/jail.conf" @@ -48,12 +48,19 @@ if [ -e "$CONF" ]; then # add network address and class if needed cp_get_netaddr || true NETADDR="$RET" - IGNOREIP=$(grep '^ignoreip' "$CONF") - if ! echo "$IGNOREIP" | grep -q "$NETADDR"; then - echo "CN: Enabling local IP ranges exclusion..." - cp_check_and_sed '^ignoreip' \ - "s;^\(ignoreip.*\)$;\1 $NETADDR;g" "$CONF" || true - fi + IGNOREIP=$(grep '^ignoreip' "$CONF" || true) + if grep -q '^ignoreip' "$CONF"; then + IGNOREIP=$(grep '^ignoreip' "$CONF") + if ! echo "$IGNOREIP" | grep -q "$NETADDR"; then + echo "CN: Enabling local IP ranges exclusion..." + cp_check_and_sed '^ignoreip' \ + "s;^\(ignoreip.*\)$;\1 $NETADDR;g" "$CONF" || true + fi + elif grep -q '^#ignoreip' "$CONF"; then + echo "CN: Enabling local IP ranges exclusion..." + cp_check_and_sed '^#ignoreip' \ + "s;^#ignoreip.*$;ignoreip = $NETADDR;g" "$CONF" || true + fi fi # restart the services