Prva inacica paketa za Debian squeeze distribuciju.
[mod-security-cn.git] / debian / prerm
index e9c9a13..bd99613 100644 (file)
@@ -10,18 +10,17 @@ set -e
 #                    2 - file exists, but it is not tagged
 #
 chk_conf_tag () {
-
-        local conf_file
-        conf_file="$1"
-        RET=1
-
-        if [ -f "$conf_file" ]; then
-            if egrep -q "^## Begin - Generated by CARNet package mod-security-cn$" "$conf_file"; then
-                RET=0
-            else
-                RET=2
-            fi
+    local conf_file
+    conf_file="$1"
+    RET=1
+
+    if [ -f "$conf_file" ]; then
+        if egrep -q "^## Begin - Generated by CARNet package mod-security-cn$" "$conf_file"; then
+            RET=0
+        else
+            RET=2
         fi
+    fi
 }
 
 
@@ -36,6 +35,8 @@ case "$1" in
         CONFDIR="$A2DIR/conf.d"
         MODSECDIR="$A2DIR/mod-security"
         MODSECCONF="$MODSECDIR/mod-security-cn.conf"
+        MODSECRBL="$MODSECDIR/rbl_lookup.conf"
+        MODSECLNK="$CONFDIR/$(basename $MODSECCONF)"
 
         need_restart=0
 
@@ -43,35 +44,27 @@ case "$1" in
         # Disable ModSecurity configuration.
         chk_conf_tag "$MODSECCONF"
         if [ $RET -eq 0 ]; then
-            if [ -e "$CONFDIR/mod-security-cn.conf" ]; then
+            if [ -e "$MODSECLNK" ]; then
                 cp_echo "CN: Disabling ModSecurity configuration."
-                rm -f "$CONFDIR/mod-security-cn.conf"
+                rm -f "$MODSECLNK"
                 need_restart=1
             fi
         fi
 
         # Remove configuration files generated by this CARNet package.
-        for file in "$MODSECCONF" "$MODSECDIR/rbl_lookup.conf"; do
+        for file in "$MODSECCONF" "$MODSECRBL"; do
             chk_conf_tag "$file"
             if [ $RET -eq 0 ]; then
                 cp_echo "CN: Removing configuration file $file"
                 rm -f $file
                 need_restart=1
             fi
-        fi
+        done
 
         # Restart Apache2 web server.
-       if [ $need_restart -eq 1 ]; then
+        if [ $need_restart -eq 1 ]; then
             if apache2ctl configtest 2>/dev/null; then
-
-                # Restart Apache2 web server.
-                if [ -x "/etc/init.d/apache2" ]; then
-                    if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
-                        invoke-rc.d apache2 restart || true
-                    else
-                        /etc/init.d/apache2 restart || true
-                    fi
-                fi
+                invoke-rc.d apache2 force-reload || true
             else
                 # Something is broken.
                 cp_echo "CN: Your Apache2 configuration seem to be broken."
@@ -92,4 +85,6 @@ case "$1" in
         ;;
 esac
 
+#DEBHELPER#
+
 exit 0