5 [ "$1" = "configure" ] || exit 0
8 cron="/etc/cron.d/amavis-stats"
9 htpasswd="/usr/share/amavis-stats/.htpasswd"
10 aconf="/etc/amavis-stats/apache.conf"
11 # these two are used in mail
12 package="amavis-stats-cn"
16 if [ "x$1" = "x-mailonly" ]; then
22 if [ `echo "$1" | wc -l` -eq 1 ]; then
28 if [ ! -f $htpasswd ]; then
30 htpasswd -bc $htpasswd admin $passwd 2> /dev/null
31 notify "CN: amavis-stats URL is http://$hostname/amavis-stats/"
32 notify "CN: User: admin"
33 notify "CN: Password: $passwd"
34 notify "CN: Use \"htpasswd $htpasswd admin\" to change it."
38 # find out where the logs might lie
40 notify "CN: Can't figure out log file, edit $cron yourself!" 1>&2
44 if grep -q /var/log/mail.info $cron; then
45 if [ ! -e "$sl" ]; then
48 elif pgrep syslog-ng > /dev/null; then
49 # syslog-ng, I'm not parsing _that_.
51 elif ! grep -q '^mail.info[ ][ ]*-?/var/log/mail.info' $sl; then
52 # where oh where does mail.info go to?
53 log=$(awk '$1 == "mail.info" {print $2}' < $sl | sed 's/^-//' | head -1)
55 log=$(awk '$1 == "mail.*" {print $2}' < $sl | sed 's/^-//' | head -1)
57 log=$(awk '$1 ~ /mail\.info/ {print $2}' < $sl | sed 's/^-//' | head -1)
59 log=$(awk '$1 ~ /mail\.\*/ {print $2}' < $sl | sed 's/^-//' | head -1)
60 if [ -z "$log" ]; then
63 sed "s,/var/log/mail.info,$log,g" < "$cron" > "${cron}.dpkg-tmp"
64 if ! cmp -s "${cron}.dpkg-tmp" "$cron"; then
65 cp "${cron}.dpkg-tmp" "$cron"
66 notify "CN: ${log} set as log file in ${cron}."
73 # ash's [ continues after -a, so we need && here
74 if [ -f "$log" ] && [ "$(dirname $log)" = "/var/log/mail" ]; then
75 logdirgroup=$(ls -ld /var/log/mail | awk '{print $4}')
76 if [ "$logdirgroup" != "adm" ]; then
77 # whyever was it not adm? on woody it's mail, on sarge smmsp...?
78 # and i'm not going to give amavis-stats privileges for those
79 notify "CN: chgrp adm /var/log/mail (was \"$logdirgroup\")."
80 chgrp adm /var/log/mail
81 #chgrp smmsp /var/log/mail
82 #addgroup amavis-stats smmsp > /dev/null
86 if ! grep -iq 'valid-user' $aconf; then
87 cat > ${aconf}.dpkg-tmp <<EOF
88 Alias /amavis-stats /usr/share/amavis-stats/
90 <Directory /usr/share/amavis-stats/>
91 Options +FollowSymLinks
98 AuthUserFile $htpasswd
105 # If default debian file, don't bother to save it
106 if [ "$(md5sum $aconf|awk '{print $1}')" != "b6820ee83bc5b6386c72428f42950b6b" ]; then
107 bak="$aconf.dpkg-old.$(date '+%Y-%m-%d')"
108 if [ ! -f "$bak" ]; then
109 cp -p "${aconf}" "$bak"
110 notify "CN: Old apache config saved as \"$bak\"."
113 cp "${aconf}.dpkg-tmp" "$aconf"
114 rm "${aconf}.dpkg-tmp"
115 notify "CN: Forced valid-user for amavis-stats web."
119 if [ "$(echo $NOTICE|wc -w)" -gt 0 ]; then
120 echo "Mailing upgrade output to root."
121 NOTICE="From: $package postinst script <root>
123 Subject: $package $version package install log
124 Date: $(/bin/date +'%a, %d %b %Y %H:%M:%S %z')
128 The $package package has been successfully installed on your computer.
129 For your convenience, a partial output of the last $package installation
136 echo "$NOTICE" | /usr/sbin/sendmail -t &
141 if [ ! -L /etc/apache2/conf.d/amavis-stats-cn.conf -a ! -f /etc/apache2/conf.d/amavis-stats-cn.conf ]; then
142 ln -sf /etc/amavis-stats/apache.conf /etc/apache2/conf.d/amavis-stats-cn.conf
146 if [ "$reload_apache2" = "yes" ]; then
147 if [ -x /usr/sbin/invoke-rc.d ]; then
148 [ -x /etc/init.d/apache2 ] && invoke-rc.d apache2 reload || true
150 [ -x /etc/init.d/apache2 ] && /etc/init.d/apache2 reload || true