X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fpostinst;h=a669349b552a071f0d5c4eaa17fe8a252d7872f5;hb=HEAD;hp=86ef053ea3c4ece4b9d515418e00f49e9a4188cf;hpb=0759d24230f3b80e606ff4cbbf08cd425f5dfa3a;p=fail2ban-cn.git diff --git a/debian/postinst b/debian/postinst index 86ef053..a669349 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,34 +1,10 @@ #!/bin/sh -# postinst script for bind9-cn -# -# see: dh_installdeb(1) set -e -[ "$CARNET_SCRIPT_DEBUG" ] && set -vx +[ "$1" = "configure" ] || exit 0 +[ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package -# - -case "$1" in - configure|reconfigure) - # continue below - ;; - - *) - exit 0 - ;; -esac - -# import CN-functions +# Load CARNET Tools . /usr/share/carnet-tools/functions.sh CONF="/etc/fail2ban/jail.conf" @@ -72,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