5 [ "$1" = "configure" ] || exit 0
6 [ "$DEBIAN_SCRIPT_DEBUG" ] && set -vx
9 . /usr/share/carnet-tools/functions.sh
11 hostname=`hostname -f`
12 cron="/etc/cron.d/amavis-stats"
13 htpasswd="/usr/share/amavis-stats/.htpasswd"
14 aconf="/etc/amavis-stats/apache.conf"
15 # these two are used in mail
16 package="amavis-stats-cn"
18 if [ ! -f $htpasswd ]; then
20 htpasswd -bc $htpasswd admin $passwd 2> /dev/null
21 cp_echo "CN: amavis-stats URL is http://$hostname/amavis-stats/"
22 cp_echo "CN: User: admin"
23 cp_echo "CN: Password: $passwd"
24 cp_echo "CN: Use \"htpasswd $htpasswd admin\" to change it."
28 # find out where the logs might lie
30 cp_echo "CN: Can't figure out log file, edit $cron yourself!" 1>&2
33 if [ -f /etc/rsyslog.conf ]; then
39 if grep -q /var/log/mail.info $cron; then
40 if [ ! -e "$sl" ]; then
41 # no syslog.conf or rsyslog.conf
43 elif pgrep syslog-ng > /dev/null; then
44 # syslog-ng, I'm not parsing _that_.
46 elif ! grep -q '^mail.info[ ][ ]*-?/var/log/mail.info' $sl; then
47 # where oh where does mail.info go to?
48 log=$(awk '$1 == "mail.info" {print $2}' < $sl | sed 's/^-//' | head -1)
50 log=$(awk '$1 == "mail.*" {print $2}' < $sl | sed 's/^-//' | head -1)
52 log=$(awk '$1 ~ /mail\.info/ {print $2}' < $sl | sed 's/^-//' | head -1)
54 log=$(awk '$1 ~ /mail\.\*/ {print $2}' < $sl | sed 's/^-//' | head -1)
55 if [ -z "$log" ]; then
58 sed "s,/var/log/mail.info,$log,g" < "$cron" > "${cron}.dpkg-tmp"
59 if ! cmp -s "${cron}.dpkg-tmp" "$cron"; then
60 cp "${cron}.dpkg-tmp" "$cron"
61 cp_echo "CN: ${log} set as log file in ${cron}."
68 # ash's [ continues after -a, so we need && here
69 if [ -f "$log" ] && [ "$(dirname $log)" = "/var/log/mail" ]; then
70 logdirgroup=$(ls -ld /var/log/mail | awk '{print $4}')
71 if [ "$logdirgroup" != "adm" ]; then
72 # whyever was it not adm? on woody it's mail, on sarge smmsp...?
73 # and i'm not going to give amavis-stats privileges for those
74 cp_echo "CN: chgrp adm /var/log/mail (was \"$logdirgroup\")."
75 chgrp adm /var/log/mail
76 #chgrp smmsp /var/log/mail
77 #addgroup amavis-stats smmsp > /dev/null
81 if ! grep -iq 'valid-user' $aconf; then
82 cat > ${aconf}.dpkg-tmp <<EOF
83 Alias /amavis-stats /usr/share/amavis-stats/
85 <Directory /usr/share/amavis-stats/>
86 Options +FollowSymLinks
93 AuthUserFile $htpasswd
100 # If default debian file, don't bother to save it
101 if [ "$(md5sum $aconf|awk '{print $1}')" != "b6820ee83bc5b6386c72428f42950b6b" ]; then
102 bak="$aconf.dpkg-old.$(date '+%Y-%m-%d')"
103 if [ ! -f "$bak" ]; then
104 cp -p "${aconf}" "$bak"
105 cp_echo "CN: Old apache config saved as \"$bak\"."
108 cp "${aconf}.dpkg-tmp" "$aconf"
109 rm "${aconf}.dpkg-tmp"
110 cp_echo "CN: Forced valid-user for amavis-stats web."
116 if [ ! -L /etc/apache2/conf.d/amavis-stats-cn.conf -a ! -f /etc/apache2/conf.d/amavis-stats-cn.conf ]; then
117 ln -sf /etc/amavis-stats/apache.conf /etc/apache2/conf.d/amavis-stats-cn.conf
121 if [ "$reload_apache2" = "yes" ]; then
122 if [ -x /usr/sbin/invoke-rc.d ]; then
123 [ -x /etc/init.d/apache2 ] && invoke-rc.d apache2 reload || true
125 [ -x /etc/init.d/apache2 ] && /etc/init.d/apache2 reload || true