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 # get installation directory
34 . /etc/ossec-init.conf
35 if [ "X${DIRECTORY}" = "X" ]; then
36 DIRECTORY="/var/ossec"
40 if [ ! -d "$DIRECTORY/rules" ]; then
41 echo "CN: There is no "$DIRECTORY/rules" directory, exiting..."
42 echo "CN: Please reinstall ossec-hids package"
46 # find first available sid
47 local_rules="$DIRECTORY/rules/local_rules.xml"
52 /<rule id="[0-9]*".*>/ {
60 if [ -e "$local_rules" ]; then
61 sid=$(awk "$script" "$local_rules")
63 if [ -z "$sid" ]; then
67 # update local rules with our policy
68 if [ -e "$local_rules" ]; then
69 cp "$local_rules" "$local_rules.$$"
71 touch "$local_rules.$$"
74 cp-update --comment '<!--' --comment-end '-->' \
75 ossec-hids-cn "$local_rules.$$" <<EOF
76 <group name="syslog,errors,local">
77 <rule id="$(expr "$sid" + 1)" level="0">
80 <description>Events ignored</description>
83 <rule id="$(expr "$sid" + 2)" level="0">
85 <program_name>^sophie|^smartd</program_name>
86 <description>Events ignored</description>
90 <group name="syslog,postfix,local">
91 <rule id="$(expr "$sid" + 3)" level="0">
93 <description>Events ignored</description>
96 <rule id="$(expr "$sid" + 4)" level="0">
98 <description>Ignore blacklisted mail</description>
102 cp_mv "$local_rules.$$" "$local_rules"
104 # and restart the service
105 if [ -x /usr/sbin/invoke-rc.d ]; then
106 invoke-rc.d ossec-hids restart
108 /etc/init.d/ossec-hids restart
111 # dh_installdeb will replace this with shell code automatically
112 # generated by other debhelper scripts.