X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Fprerm;h=379b3839948036227b1b7bb40e3b92b9497453b9;hb=d6d471ca8237b76920e6c78385214ffe26ce6dc6;hp=e9c9a1396ce32cfc14f8e9282c183bcc7380deb3;hpb=eae9627db45a5346d7c6ee014dfa626848410e65;p=mod-security-cn.git diff --git a/debian/prerm b/debian/prerm index e9c9a13..379b383 100644 --- a/debian/prerm +++ b/debian/prerm @@ -2,6 +2,12 @@ set -e +PKG=mod-security-cn + +MODSECCONF=/etc/apache2/mod-security/$PKG.conf +MODSECRBL=/etc/apache2/mod-security/rbl_lookup.conf +MODSECLNK=/etc/apache2/conf-available/security2-cn.conf + # chk_conf_tag () # # Check if configuration file has CARNet package info lines. @@ -10,86 +16,55 @@ 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 } +if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then + . /usr/share/apache2/apache2-maintscript-helper -case "$1" in - remove|deconfigure) - - # Include CARNet functions. - . /usr/share/carnet-tools/functions.sh - - PKG="mod-security-cn" - A2DIR="/etc/apache2" - CONFDIR="$A2DIR/conf.d" - MODSECDIR="$A2DIR/mod-security" - MODSECCONF="$MODSECDIR/mod-security-cn.conf" - - need_restart=0 - - - # 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 + modsecurity_enable() { + chk_conf_tag "$MODSECLNK" + if [ $RET -ne 2 ]; then + echo "CN: Disabling $PKG configuration for Apache2." + return 0 fi - - # Restart Apache2 web server. - 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 - else - # Something is broken. - cp_echo "CN: Your Apache2 configuration seem to be broken." - cp_echo "CN: Please, check the service configuration!" - fi + return 1 + } +else + echo "CN: Could not load Apache 2.4 maintainer script helper." + + modsecurity_enable() { + return 1 + } +fi + +if [ "$1" = "remove" ] || [ "$1" = "deconfigure" ]; then + # Disable ModSecurity configuration. + if modsecurity_enable; then + apache2_invoke disconf security2-cn + rm -f "$MODSECLNK" + fi + + # Remove configuration files generated by this CARNet package. + for mfile in "$MODSECCONF" "$MODSECRBL"; do + chk_conf_tag "$mfile" + if [ $RET -eq 0 ]; then + echo "CN: Removing configuration file $mfile" + rm -f "$mfile" fi + done +fi - # Mail root - cp_mail "$PKG" - - echo - ;; - upgrade|failed-upgrade) - ;; - *) - echo "prerm called with unknown argument \$1'" >&2 - exit 0 - ;; -esac +#DEBHELPER# exit 0