Inicijalna verzija paketa.
[mod-security-cn.git] / debian / prerm
1 #!/bin/sh
2
3 set -e
4
5 case "$1" in
6     remove|deconfigure)
7
8         # Include CARNet functions.
9         . /usr/share/carnet-tools/functions.sh
10
11         PKG="mod-security-cn"
12         A2DIR="/etc/apache2"
13         CONFDIR="$A2DIR/conf.d"
14         MODSECCONF="$CONFDIR/mod-security-cn.conf"
15         need_restart=0
16
17         # Remove configuration file generated by this CARNet package.
18         if [ -f "$MODSECCONF" ]; then
19             if egrep -q "^## Begin - Generated by CARNet package mod-security-cn$" "$MODSECCONF"; then
20                 cp_echo "CN: Removing configuration file ${MODSECCONF}."
21                 rm -f $MODSECCONF
22                 need_restart=1
23             fi
24         fi
25
26         # Restart Apache2 web server.
27         if [ $need_restart -eq 1 ]; then
28             if apache2ctl configtest 2>/dev/null; then
29
30                 # Restart Apache2 web server.
31                 if [ -x "/etc/init.d/apache2" ]; then
32                     if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
33                         invoke-rc.d apache2 restart || true
34                     else
35                         /etc/init.d/apache2 restart || true
36                     fi
37                 fi
38             else
39                 # Something is broken.
40                 cp_echo "CN: Your Apache2 configuration seem to be broken."
41                 cp_echo "CN: Please, check the service configuration!"
42             fi
43         fi
44
45         # Mail root
46         cp_mail "$PKG"
47
48         echo
49         ;;
50     upgrade|failed-upgrade)
51         ;;
52     *)
53         echo "prerm called with unknown argument \$1'" >&2
54         exit 0
55         ;;
56 esac
57
58 exit 0