3cfb0245e95fef328c7fbbc95011c0378a7e3e6c
[clamav-cn.git] / debian / postinst
1 #!/bin/sh
2
3 set -e
4
5 [ "$1" = "configure" ] || exit 0
6 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
7
8 # Load CARNet functions
9 . /usr/share/carnet-tools/functions.sh
10
11 #if dpkg --compare-versions "$2" lt 2:0.91.1-1 ; then
12 #  cp_backup_conffile /etc/clamav/clamd.conf
13 #  rm -f /etc/clamav/clamd.conf
14 #  cp -a /usr/share/doc/clamav-cn/examples/clamd.conf /etc/clamav/clamd.conf
15 #  restart="yes"
16 #fi
17 #
18 #if dpkg --compare-versions "$2" lt 2:0.91.1-1 ; then
19 #  cp_backup_conffile /etc/clamav/freshclam.conf
20 #  rm -f /etc/clamav/freshclam.conf
21 #  cp -a /usr/share/doc/clamav-cn/examples/freshclam.conf /etc/clamav/freshclam.conf
22 #  restart="yes"
23 #fi
24
25 cp_check_and_sed "^AllowSupplementaryGroups false" \
26                  "s/AllowSupplementaryGroups false/AllowSupplementaryGroups true/g" \
27                  /etc/clamav/clamd.conf && restart="yes" || true
28
29 if ! grep -q ^AllowSupplementaryGroups /etc/clamav/clamd.conf; then
30   echo "AllowSupplementaryGroups true" >> /etc/clamav/clamd.conf
31   reload="yes"
32 fi
33
34 chown -R clamav:clamav /var/run/clamav /var/lib/clamav /var/log/clamav
35
36 # dodaj korisnika clamav u grupu amavis (ako postoji...)
37 getent group amavis > /dev/null && usermod -G amavis clamav && restart="yes"
38
39 # ispravi opciju od clamscana u amavis konfi
40 # --disable-summary -> --no-summary
41 if [ -f /etc/amavis/conf.d/15-av_scanners ]; then
42   cp_check_and_sed "\-\-disable-summary" \
43                    "s/--disable-summary/--no-summary/g" \
44                    /etc/amavis/conf.d/15-av_scanners && restart_amavis="yes" || true
45
46   if [ -f /etc/amavis/conf.d/15-av_scanners.cn-old ]; then
47     rm -f /etc/amavis/conf.d/15-av_scanners.cn-old
48   fi
49 fi
50
51 if [ "$restart_amavis" = "yes" ]; then
52   if [ -x /usr/sbin/invoke-rc.d ]; then
53     [ -x /etc/init.d/amavisd-cn ] && invoke-rc.d amavisd-cn restart
54   else
55     [ -x /etc/init.d/amavisd-cn ] && /etc/init.d/amavisd-cn restart
56   fi
57   # nije potreban restart clamava
58   restart="no"
59 fi
60
61
62 # restart if needed
63 [ "$restart" = "yes" ] || exit 0
64 if [ -x /usr/sbin/invoke-rc.d ]; then
65   [ -x /etc/init.d/clamav-daemon ] && invoke-rc.d clamav-daemon restart
66 else
67   [ -x /etc/init.d/clamav-daemon ] && /etc/init.d/clamav-daemon restart
68 fi
69
70 if [ -x /usr/sbin/invoke-rc.d ]; then
71   [ -x /etc/init.d/clamav-freshclam ] && invoke-rc.d clamav-freshclam restart
72 else
73   [ -x /etc/init.d/clamav-freshclam ] && /etc/init.d/clamav-freshclam restart
74 fi