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