+#!/bin/sh
+# postinst script for bind9-cn
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> `configure' <most-recently-configured-version>
+# * <old-postinst> `abort-upgrade' <new version>
+# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+# <new-version>
+# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+# <failed-install-package> <version> `removing'
+# <conflicting-package> <version>
+# 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
+. /usr/share/carnet-tools/functions.sh
+
+CONF=/etc/fail2ban/jail.conf
+
+if [ -e "$CONF" ]; then
+ # enable ssh and pam-generic services
+ perl -ne 'if (/\[(ssh|pam-generic)\]/ .. /enabled/) { $_ =~ s/enabled = false/enabled = true/gi }; print $_' "$CONF" > "$CONF.$$" && \
+ mv "$CONF.$$" "$CONF"
+ rm -f "$CONF.$$"
+
+ # add network address and class if needed
+ cp_get_netaddr || true
+ NETADDR="$RET"
+ IGNOREIP=$(grep '^ignoreip' "$CONF")
+ if ! echo "$IGNOREIP" | grep -q "$NETADDR"; then
+ cp_check_and_sed '^ignoreip' \
+ "s;^\(ignoreip.*\)$;\1 $NETADDR;g" "$CONF" || true
+ fi
+fi
+
+# restart the services
+if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+ invoke-rc.d fail2ban restart || exit $?
+else
+ /etc/init.d/fail2ban restart || exit $?
+fi
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0