Patchiranje amavisd-new zbog ripOLE buga
[amavisd-cn.git] / debian / postinst
1 #!/bin/sh
2 # postinst script for amavisd-cn
3 #
4 # see: dh_installdeb(1)
5
6 set -e
7
8 # summary of how this script can be called:
9 #        * <postinst> `configure' <most-recently-configured-version>
10 #        * <old-postinst> `abort-upgrade' <new version>
11 #        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
12 #          <new-version>
13 #        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
14 #          <failed-install-package> <version> `removing'
15 #          <conflicting-package> <version>
16 # for details, see http://www.debian.org/doc/debian-policy/ or
17 # the debian-policy package
18 #
19
20 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
21
22 case "$1" in
23   configure)
24     # continue below
25   ;;
26
27   abort-upgrade|abort-remove|abort-deconfigure)
28     exit 0
29   ;;
30
31   *)
32     echo "postinst called with unknown argument \`$1'" >&2
33     exit 0
34   ;;
35 esac
36
37 PATH=/bin:/usr/bin:/sbin:/usr/sbin
38 export PATH
39
40 . /usr/share/amavisd-cn/version.sh
41 . /usr/share/carnet-tools/functions.sh
42 . /usr/share/amavisd-cn/variables.sh
43 . /usr/share/amavisd-cn/functions.sh
44
45 mta=postfix
46 . /usr/share/amavisd-cn/postfix.sh
47
48 # $domain will be equal to $host if nothing better can be found
49 cp_get_mx_domain
50 domain=$RET
51
52 update_postfix $*
53
54 # Patchiramo /usr/sbin/amavisd-new zbog warninga:
55 # (!!)collect_results from (/usr/bin/ripole): exit 102 File <> is not OLE2 format\n
56
57 if ! grep -q '\[0,102\]);' /usr/sbin/amavisd-new; then
58         sed -i.BAK '33055s/\[0\]/[0,102]/' /usr/sbin/amavisd-new
59         echo "CN: Patchiram /usr/sbin/amavisd-new"
60 fi
61
62 # amavisd.conf
63 if [ -f "$ACONFOLD" ]; then
64   cp_echo "CN: Amavisd configuration is now in $ACONF."
65   noisy_backup "$ACONFOLD"
66   rm -f "$ACONFOLD"
67   cp_echo ""
68   cp_echo "CN: Please read /usr/share/doc/amavisd-cn/README.CARNET."
69 elif [ -f "$ACONFOLD.disabled" ]; then
70   noisy_backup "$ACONFOLD.disabled" "$(basename $ACONFOLD)"
71   rm -f "$ACONFOLD.disabled"
72   cp_echo "CN: Please read /usr/share/doc/amavisd-cn/README.CARNET."
73 fi
74
75 if [ -f $ACONF ]; then
76   # add other fixups to function update_conf(), way above
77   update_conf $*
78 fi
79 # nonexistent or empty config
80 if [ ! -f $ACONF -o ! -s $ACONF ]; then
81   # Create fresh config from template
82   conf_from_template
83   restart_daemon=1
84 fi
85
86 # disable SAVI as proven problematic
87 if cp_check_and_sed "^[[:blank:]]*\['Sophos SAVI'" \
88  "s/^[[:blank:]]*\(\['Sophos SAVI', ..sophos_savi \]\)/#\1/" $ACONF; then
89   cp_echo "CN: Disabled SAVI::Perl usage in ${ACONF}."
90   restart_daemon=1
91 fi
92
93 check_and_add_alias virusalert root
94 check_and_add_alias spamalert root
95
96 # ovo je rijeseno u spamassassin-cn, i ovdje nije potrebno, stoga brisemo
97 if [ -f $AHOME/.spamassassin/user_prefs ] ; then
98   user_prefs_temp=$(mktemp /tmp/user_prefs.XXXXXX)
99   cat > $user_prefs_temp <<-EEND
100         bayes_path              $AHOME/.spamassassin/bayes
101         bayes_auto_expire       0
102         auto_whitelist_path     $AHOME/.spamassassin/auto-whitelist
103         EEND
104   if cmp -s $user_prefs_temp $AHOME/.spamassassin/user_prefs; then
105     rm -f $AHOME/.spamassassin/user_prefs
106   fi
107   rm -f $user_prefs_temp
108 fi
109
110 # No sysvinit order fixes
111 :
112
113 # Fix missing redirection in cron files for amavisd-new-cronjob
114 add_redirection /etc/cron.d/amavisd-new
115
116 if [ -n "$chown_ahome" ]; then
117   # might be slow
118   echo -n "CN: Fixing ownership in /var/*/amavis... "
119   chown -R amavis:amavis $AHOME /var/run/amavis || true
120   echo "done."
121   cp_echo -mailonly "CN: Fixed ownerships in /var/*/amavis."
122 fi
123
124 restart_daemon="1"
125 if [ "$restart_daemon" ]; then
126   service amavis restart
127 fi
128 # always check that the daemons are running
129
130 # this needs to be updated when $CRONTAB file changes
131 if dpkg --compare-versions "$2" lt "2:20030616p10-4"; then
132   cp_echo ""
133   cp_echo "CN: Deleting temp files older than 1 day every day at 01:35 AM"
134   cp_echo "CN: Deleting spam-mail  older than 7 days every day at 03:15 AM"
135   cp_echo "CN: Deleting virus-mail older than 7 days every day at 04:25 AM"
136   cp_echo "    (can be changed in $CRONTAB)"
137 fi
138
139 if [ "$failed" ]; then
140   cp_echo ""
141   cp_echo "CN: Services $failed failed to restart!"
142   cp_echo "CN: Please check and start manually if needed."
143 fi
144
145 # Upgrade, but no automatically changed config;
146 # warn if new template available
147 if [ -n "$2" -a -z "$changed_config" ] && \
148    dpkg --compare-versions "$2" lt "$TMPLVERSION"; then
149   cp_echo ""
150   cp_echo "CN: It seems you have upgraded this package from version $2."
151   cp_echo "CN: Configuration template for $mta was modified in version ${TMPLVERSION}."
152   cp_echo "    You might want to review the changes, or simply copy the new template and"
153   cp_echo "    and replace the _CN_DOMAIN_ string with an adequate value:"
154   cp_echo "    cp $ACONFTMPL $ACONF"
155   cp_echo "    perl -pi -e 's/_CN_DOMAIN_/$domain/g' $ACONF"
156 fi
157
158 # Delete old conffiles...
159 for conffile in /etc/logcheck/violations.ignore.d/amavisd-new \
160          /etc/logcheck/ignore.d.server/amavisd-new \
161          /etc/logcheck/ignore.d.workstation/amavisd-new \
162          /etc/cron.daily/amavisd-new; do
163   if [ -f ${conffile} ]; then
164     cp_echo "CN: Deleting old conffile ${conffile}..."
165     rm -f ${conffile}
166   fi
167 done
168
169 cp_mail $PKG $VERSION
170
171 exit 0
172
173 #DEBHELPER#