Package: mailgraph
Version: 1.14-1.2
Severity: normal
Tags: patch
After executing `dpkg-reconfigure mailgraph` the configuration in
/etc/default/mailgraph isn't updated. Before dpkg-reconfigure:
# cat /etc/default/mailgraph && debconf-show mailgraph
BOOT_START=true
MAIL_LOG=/var/log/mail.log
IGNORE_LOCALHOST=true
* mailgraph/ignore_localhost: true
* mailgraph/mail_log: /var/log/mail.log
* mailgraph/start_on_boot: true
After dpkg-reconfigure:
# cat /etc/default/mailgraph && debconf-show mailgraph
BOOT_START=true
MAIL_LOG=/var/log/mail.log
IGNORE_LOCALHOST=true
* mailgraph/ignore_localhost: true
* mailgraph/mail_log: /dev/random
* mailgraph/start_on_boot: false
I wrote a postinst script and tested it. It works for me, see
mailgraph-1.14_postinst.patch.
I hope this will solve #283664 and #337923 too.
This modification also allows to use an ADDITIONAL_OPTIONS variable in
/etc/default/mailgraph, for example `--rbl-is-spam'. OK, this change requires
a small adjustment to the init script, see
mailgraph-1.14_init_additional_options.patch.
This feature is desired in bug reports #285980 and #311437
Last point/patch: The text from the template `mailgraph/ignore_localhost' was
a little bit confusing me. Maybe the text from mailgraph-1.14_templates.patch
is better to understand.
Regards,
Pascal
-- System Information:
Debian Release: 5.0
APT prefers testing
APT policy: (500, 'testing'), (50, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages mailgraph depends on:
ii debconf [debconf-2.0] 1.5.24 Debian configuration management sy
ii libfile-tail-perl 0.99.3-3 File::Tail perl module
ii librrds-perl 1.3.1-4 Time-series data storage and displ
Versions of packages mailgraph recommends:
ii apache2-mpm-prefork [htt 2.2.9-10+lenny2 Apache HTTP Server - traditional n
mailgraph suggests no packages.
-- debconf information:
* mailgraph/ignore_localhost: true
* mailgraph/mail_log: /var/log/mail.log
* mailgraph/start_on_boot: true
diff -urN mailgraph-1.14.org/debian/init mailgraph-1.14/debian/init
--- mailgraph-1.14.org/debian/init 2009-01-29 23:04:19.000000000 +0100
+++ mailgraph-1.14/debian/init 2009-01-30 06:23:01.000000000 +0100
@@ -35,7 +35,7 @@
case "$1" in
start)
echo -n "Starting Postfix Mail Statistics: $NAME"
- start-stop-daemon -S -q -b -p $PID_FILE -x $DAEMON -- -l $MAIL_LOG -d --daemon_rrd=$RRD_DIR $IGNORE_OPTION
+ start-stop-daemon -S -q -b -p $PID_FILE -x $DAEMON -- -l $MAIL_LOG -d --daemon_rrd=$RRD_DIR $IGNORE_OPTION $ADDITIONAL_OPTIONS
echo "."
;;
stop)
diff -urN mailgraph-1.14.org/debian/postinst mailgraph-1.14/debian/postinst
--- mailgraph-1.14.org/debian/postinst 2009-01-29 23:04:19.000000000 +0100
+++ mailgraph-1.14/debian/postinst 2009-01-30 19:32:48.000000000 +0100
@@ -1,20 +1,77 @@
#!/bin/sh
-if [ ! -f /etc/default/mailgraph ]; then
- . /usr/share/debconf/confmodule
- db_get mailgraph/start_on_boot
- echo "BOOT_START=$RET" > /etc/default/mailgraph
- db_get mailgraph/mail_log
- echo "MAIL_LOG=$RET" >> /etc/default/mailgraph
- db_get mailgraph/ignore_localhost
- if [ "$RET" = "true" ] ; then
- echo "IGNORE_LOCALHOST=false" >> /etc/default/mailgraph
+
+##set -x
+
+CONFIG=/etc/default/mailgraph
+CONFIG_BAK=/etc/default/mailgraph.bak
+RRD_DIR=/var/lib/mailgraph
+NEED_UPDATE=0
+
+# load debconf library
+. /usr/share/debconf/confmodule
+
+write_config()
+{
+ cat <<EOF > "${CONFIG}"
+# variables for /etc/init.d/mailgraph
+#
+# Should Mailgraph start on boot (true|false) [debconf]
+BOOT_START=${BOOT_START}
+# Logfile used by mailgraph (default: /var/log/mail.log) [debconf]
+MAIL_LOG=${MAIL_LOG}
+# Ignore mails from localhost (true|false) [debconf]
+IGNORE_LOCALHOST=${IGNORE_LOCALHOST}
+# see mailgraph -h output
+ADDITIONAL_OPTIONS="${ADDITIONAL_OPTIONS}"
+EOF
+ return $?
+}
+
+update_config()
+{
+ # create backup
+ cp ${CONFIG} ${CONFIG_BAK}
+ # write new configuration
+ write_config
+ # remove backup, if configuration was created successfully
+ if [ $? -eq 0 ]; then
+ rm ${CONFIG_BAK}
else
- echo "IGNORE_LOCALHOST=true" >> /etc/default/mailgraph
+ mv ${CONFIG_BAK} ${CONFIG}
fi
+}
+
+make_rrd_dir()
+{
+ if [ ! -d ${RRD_DIR} ]; then
+ mkdir ${RRD_DIR}
+ chown www-data:www-data ${RRD_DIR}
+ fi
+}
+
+if [ -f ${CONFIG} ]; then
+ . ${CONFIG}
+ NEED_UPDATE=1
+fi
+
+db_get mailgraph/start_on_boot
+BOOT_START=${RET}
+db_get mailgraph/mail_log
+MAIL_LOG=${RET}
+db_get mailgraph/ignore_localhost
+IGNORE_LOCALHOST=${RET}
+
+if [ ! -n "${ADDITIONAL_OPTIONS}" ]; then
+ ADDITIONAL_OPTIONS=""
fi
-if [ ! -d /var/lib/mailgraph ]; then
- mkdir /var/lib/mailgraph
- chown www-data:www-data /var/lib/mailgraph
+
+if [ ${NEED_UPDATE} -eq 0 ]; then
+ write_config
+else
+ update_config
fi
+
+make_rrd_dir
+
#DEBHELPER#
exit 0
diff -urN mailgraph-1.14.org/debian/templates mailgraph-1.14/debian/templates
--- mailgraph-1.14.org/debian/templates 2009-01-29 23:04:19.000000000 +0100
+++ mailgraph-1.14/debian/templates 2009-01-30 20:31:29.000000000 +0100
@@ -16,7 +16,7 @@
Template: mailgraph/ignore_localhost
Type: boolean
Default: true
-_Description: Count incoming mail as outgoing mail?
- If you count incoming mail as outgoing mail (default), mail is counted more
- than once if you use content filters like amavis, so you'll get wrong values.
- If you're using some content filter, disable this.
+_Description: Ignore mail to/from localhost?
+ If you are using a content filter like amavis, incoming mail is counted more
+ then once. This will result in wrong values.
+ If you're using some content filter you should select 'yes'