Izbaceno koristenje geoLookup operatora.
[mod-security-cn.git] / debian / prerm
1 #!/bin/sh
2
3 set -e
4
5 # chk_conf_tag ()
6 #
7 #   Check if configuration file has CARNet package info lines.
8 #   return:  $RET => 0 - tagged
9 #                    1 - file does not exists
10 #                    2 - file exists, but it is not tagged
11 #
12 chk_conf_tag () {
13
14         local conf_file
15         conf_file="$1"
16         RET=1
17
18         if [ -f "$conf_file" ]; then
19             if egrep -q "^## Begin - Generated by CARNet package mod-security-cn$" "$conf_file"; then
20                 RET=0
21             else
22                 RET=2
23             fi
24         fi
25 }
26
27
28 case "$1" in
29     remove|deconfigure)
30
31         # Include CARNet functions.
32         . /usr/share/carnet-tools/functions.sh
33
34         PKG="mod-security-cn"
35         A2DIR="/etc/apache2"
36         CONFDIR="$A2DIR/conf.d"
37         MODSECDIR="$A2DIR/mod-security"
38         MODSECCONF="$MODSECDIR/mod-security-cn.conf"
39
40         need_restart=0
41
42
43         # Disable ModSecurity configuration.
44         chk_conf_tag "$MODSECCONF"
45         if [ $RET -eq 0 ]; then
46             if [ -e "$CONFDIR/mod-security-cn.conf" ]; then
47                 cp_echo "CN: Disabling ModSecurity configuration."
48                 rm -f "$CONFDIR/mod-security-cn.conf"
49                 need_restart=1
50             fi
51         fi
52
53         # Remove configuration files generated by this CARNet package.
54         for file in "$MODSECCONF" "$MODSECDIR/rbl_lookup.conf"; do
55             chk_conf_tag "$file"
56             if [ $RET -eq 0 ]; then
57                 cp_echo "CN: Removing configuration file $file"
58                 rm -f $file
59                 need_restart=1
60             fi
61         fi
62
63         # Restart Apache2 web server.
64         if [ $need_restart -eq 1 ]; then
65             if apache2ctl configtest 2>/dev/null; then
66
67                 # Restart Apache2 web server.
68                 if [ -x "/etc/init.d/apache2" ]; then
69                     if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
70                         invoke-rc.d apache2 restart || true
71                     else
72                         /etc/init.d/apache2 restart || true
73                     fi
74                 fi
75             else
76                 # Something is broken.
77                 cp_echo "CN: Your Apache2 configuration seem to be broken."
78                 cp_echo "CN: Please, check the service configuration!"
79             fi
80         fi
81
82         # Mail root
83         cp_mail "$PKG"
84
85         echo
86         ;;
87     upgrade|failed-upgrade)
88         ;;
89     *)
90         echo "prerm called with unknown argument \$1'" >&2
91         exit 0
92         ;;
93 esac
94
95 exit 0