X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;ds=sidebyside;f=debian%2Fprerm;fp=debian%2Fprerm;h=e9c9a1396ce32cfc14f8e9282c183bcc7380deb3;hb=eae9627db45a5346d7c6ee014dfa626848410e65;hp=aeef7d67f942496dc839d52fa3f2ace763fe682e;hpb=d898c4a3e286e07ee0f5d379dcdb055795209add;p=mod-security-cn.git diff --git a/debian/prerm b/debian/prerm index aeef7d6..e9c9a13 100644 --- a/debian/prerm +++ b/debian/prerm @@ -2,6 +2,29 @@ set -e +# chk_conf_tag () +# +# Check if configuration file has CARNet package info lines. +# return: $RET => 0 - tagged +# 1 - file does not exists +# 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 + fi +} + + case "$1" in remove|deconfigure) @@ -9,17 +32,31 @@ case "$1" in . /usr/share/carnet-tools/functions.sh PKG="mod-security-cn" - A2DIR="/etc/apache2" + A2DIR="/etc/apache2" CONFDIR="$A2DIR/conf.d" - MODSECCONF="$CONFDIR/mod-security-cn.conf" + MODSECDIR="$A2DIR/mod-security" + MODSECCONF="$MODSECDIR/mod-security-cn.conf" + need_restart=0 - # Remove configuration file generated by this CARNet package. - if [ -f "$MODSECCONF" ]; then - if egrep -q "^## Begin - Generated by CARNet package mod-security-cn$" "$MODSECCONF"; then - cp_echo "CN: Removing configuration file ${MODSECCONF}." - rm -f $MODSECCONF - need_restart=1 + + # Disable ModSecurity configuration. + chk_conf_tag "$MODSECCONF" + if [ $RET -eq 0 ]; then + if [ -e "$CONFDIR/mod-security-cn.conf" ]; then + cp_echo "CN: Disabling ModSecurity configuration." + rm -f "$CONFDIR/mod-security-cn.conf" + need_restart=1 + fi + fi + + # Remove configuration files generated by this CARNet package. + for file in "$MODSECCONF" "$MODSECDIR/rbl_lookup.conf"; 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