r11: Preliminary etch package.
[amavisd-cn.git] / debian / prerm
1 #!/bin/sh
2
3 set -e
4 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -x
5
6 . /usr/share/carnet-tools/functions.sh
7
8 PKG=amavisd-cn
9 ALIASES=/etc/aliases
10 main_cf=/etc/postfix/main.cf
11 master_cf=/etc/postfix/master.cf
12
13 del_postconf() {
14   egrep -v "^$1[[:blank:]]*=[[:blank:]]*" $main_cf > $main_cf.dpkg-tmp.$$
15   cp_mv $main_cf.dpkg-tmp.$$ $main_cf
16 }
17
18 if [ "$1" = remove ]; then
19   if grep -q $PKG $master_cf; then
20     cp-update -r $PKG $master_cf >&-
21     del_postconf content_filter
22     echo "Removed postfix configuration for ${PKG}."
23     if pgrep -u root -f /usr/lib/postfix/master >&- && \
24        [ -x /etc/init.d/postfix ] >&- ; then
25       if [ -x /usr/sbin/invoke-rc.d ]; then
26         invoke-rc.d postfix restart
27       else
28         /etc/init.d/postfix restart
29       fi
30     fi
31   fi
32   cp-update -r $PKG $ALIASES >&-
33   if [ -x /usr/bin/newaliases ]; then
34     newaliases
35   fi
36 fi