2 # postinst script for bind9-cn
4 # see: dh_installdeb(1)
8 # summary of how this script can be called:
9 # * <postinst> `configure' <most-recently-configured-version>
10 # * <old-postinst> `abort-upgrade' <new version>
11 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
13 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
14 # <failed-install-package> <version> `removing'
15 # <conflicting-package> <version>
16 # for details, see http://www.debian.org/doc/debian-policy/ or
17 # the debian-policy package
21 configure|reconfigure)
31 . /usr/share/carnet-tools/functions.sh
33 CONF=/etc/fail2ban/jail.conf
35 if [ -e "$CONF" ]; then
36 # enable ssh and pam-generic services
37 perl -ne 'if (/\[(ssh|pam-generic)\]/ .. /enabled/) { $_ =~ s/enabled = false/enabled = true/gi }; print $_' "$CONF" > "$CONF.$$" && \
41 # add network address and class if needed
42 cp_get_netaddr || true
44 IGNOREIP=$(grep '^ignoreip' "$CONF")
45 if ! echo "$IGNOREIP" | grep -q "$NETADDR"; then
46 cp_check_and_sed '^ignoreip' \
47 "s;^\(ignoreip.*\)$;\1 $NETADDR;g" "$CONF" || true
51 # restart the services
52 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
53 invoke-rc.d fail2ban restart || exit $?
55 /etc/init.d/fail2ban restart || exit $?
58 # dh_installdeb will replace this with shell code automatically
59 # generated by other debhelper scripts.