Izmjene za stretch
[ossec-hids-cn.git] / debian / postinst
1 #!/bin/sh
2 # postinst script for bind9-cn
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
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>
12 #          <new-version>
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
18 #
19
20 case "$1" in
21     configure|reconfigure)
22       # continue below
23     ;;
24
25     *)
26         exit 0
27     ;;
28 esac
29
30 # import CN-functions
31 . /usr/share/carnet-tools/functions.sh
32
33 # get installation directory
34 if [ -e /etc/ossec-init.conf ]; then
35   . /etc/ossec-init.conf
36 fi
37 if [ "X${DIRECTORY}" = "X" ]; then
38     DIRECTORY="/var/ossec"
39 fi
40
41 # sanity check
42 if [ ! -d "$DIRECTORY/rules" ]; then
43     echo "CN: There is no "$DIRECTORY/rules" directory, exiting..."
44     echo "CN: Please reinstall ossec-hids package"
45     exit 1
46 fi
47
48 # find first available sid
49 local_rules="$DIRECTORY/rules/local_rules.xml"
50 script='
51 BEGIN {
52     FS = "\""
53 }
54 /<rule id="[0-9]*".*>/ {
55     if (max < $2)
56         max = $2
57 }
58 END {
59     print max
60 };
61 '
62 if [ -e "$local_rules" ]; then
63     sid=$(awk "$script" "$local_rules")
64 fi
65 if [ -z "$sid" ]; then
66     sid=100000
67 fi
68
69 # update local rules with our policy
70 if [ -e "$local_rules" ]; then
71     cp "$local_rules" "$local_rules.$$"
72 else
73     touch "$local_rules.$$"
74 fi
75
76 cp-update --comment '<!--' --comment-end '-->' \
77     ossec-hids-cn "$local_rules.$$" <<EOF
78 <group name="local">
79  <rule id="$(expr "$sid" + 1)" level="0">
80    <if_sid>1002</if_sid>
81    <match>rsync</match>
82    <description>Events ignored</description>
83  </rule>
84
85  <rule id="$(expr "$sid" + 2)" level="0">
86    <if_sid>1002</if_sid>
87    <program_name>^sophie|^smartd</program_name>
88    <description>Ignore Sophie/SMARTd</description>
89  </rule>
90
91  <rule id="$(expr "$sid" + 3)" level="0">
92    <if_sid>3303</if_sid>
93    <description>Events ignored</description>
94  </rule>
95
96  <rule id="$(expr "$sid" + 4)" level="0">
97    <if_sid>3356</if_sid>
98    <description>Ignore blacklisted mail</description>
99  </rule>
100
101  <rule id="$(expr "$sid" + 5)" level="0">
102    <if_sid>1002</if_sid>
103    <match>cache</match>
104    <program_name>^named</program_name>
105    <description>Ignore BIND cache warnings</description>
106  </rule> 
107
108  <rule id="$(expr "$sid" + 6)" level="0">
109    <if_sid>2933</if_sid>
110    <match>Updated timestamp for job</match>
111    <program_name>^anacron</program_name>
112    <description>Ignore Anacron warnings</description>
113  </rule> 
114 </group>
115 EOF
116 cp_mv "$local_rules.$$" "$local_rules"
117
118 # and restart the service
119 service ossec-hids restart || true
120
121 # dh_installdeb will replace this with shell code automatically
122 # generated by other debhelper scripts.
123
124 #DEBHELPER#
125
126 exit 0