tag 502744 patch
tag 503408 patch
tag 503409 patch
thanks

On Tue, Oct 28, 2008 at 12:04:45PM +0200, Niko Tyni wrote:

> Michael, sorry to be the bearer of bad news. As a compensation, I've
> got a proposed patch almost ready and will send it hopefully tonight.

Here we go, this is against -2 in the archive as that's a fixed
point. This is only lightly tested, please double-check :)

Note that I removed the debconf defaults you were introducing in the
mentors version; 192.168.1.1 is really just a guess. I think it's better
not to put anything at all in the config file in that case.

The default configuration is now shipped in
/usr/share/mxallowd/config.default and the postinst generates
/etc/mxallowd.conf from it on a first install.  Note that removing
/etc/mxallowd.conf counts as a local modification that's supposed to be
honoured on upgrades.

You might want to look into using ucf(1) post lenny.

BTW, the init script doesn't notice if the daemon doesn't start
due to missing config settings.

Cheers,
-- 
Niko Tyni   [EMAIL PROTECTED]
diff -u mxallowd-1.6a/debian/rules mxallowd-1.6a/debian/rules
--- mxallowd-1.6a/debian/rules
+++ mxallowd-1.6a/debian/rules
@@ -42,11 +42,12 @@
 	dh_testdir
 	dh_testroot
 	dh_clean -k 
-	dh_installdirs
+	dh_installdirs usr/share/mxallowd
 
 	# Add here commands to install the package into debian/mxallowd.
 	$(MAKE) DESTDIR=$(CURDIR)/debian/mxallowd/ install
-
+	mv debian/mxallowd/etc/mxallowd.conf \
+	   debian/mxallowd/usr/share/mxallowd/config.default
 
 # Build architecture-independent files here.
 binary-indep: build install
diff -u mxallowd-1.6a/debian/control mxallowd-1.6a/debian/control
diff -u mxallowd-1.6a/debian/changelog mxallowd-1.6a/debian/changelog
diff -u mxallowd-1.6a/debian/mxallowd.config mxallowd-1.6a/debian/mxallowd.config
--- mxallowd-1.6a/debian/mxallowd.config
+++ mxallowd-1.6a/debian/mxallowd.config
@@ -5,27 +5,31 @@
+parse_conffile ()
+{
+    unset FAKE_SERVERS
+    unset REAL_SERVERS
+    while read key value rest
+    do
+        case "$key" in
+            fake-mailserver)
+                FAKE_SERVERS="${FAKE_SERVERS} $value"
+            ;;
+            real-mailserver)
+                REAL_SERVERS="${REAL_SERVERS} $value"
+            ;;
+        esac
+    done < /etc/mxallowd.conf
+}
 . /usr/share/debconf/confmodule
 
-add_entry() {
-	TMP=$(mktemp -d)
-	cp /etc/mxallowd.conf ${TMP}/mxallowd.conf
-	fgrep -v "$1" ${TMP}/mxallowd.conf > /etc/mxallowd.conf
-	for server in $(echo "${2}")
-	do
-		echo "$1 ${server}" >> /etc/mxallowd.conf
-	done
-	rm -rf ${TMP}
-}
+if [ -f /etc/mxallowd.conf ]
+then
+    parse_conffile
+    [ -z "$REAL_SERVERS" ] || db_set mxallowd/real_mailservers "$REAL_SERVERS"
+    [ -z "$FAKE_SERVERS" ] || db_set mxallowd/fake_mailservers "$FAKE_SERVERS"
+fi
 
 db_title "mxallowd"
 db_input high mxallowd/real_mailservers || true
-db_go
-
-db_get mxallowd/real_mailservers
-
-[ ! -z "$RET" ] && add_entry "real-mailserver" "${RET}"
+db_go || true
 
 db_input high mxallowd/fake_mailservers || true
-db_go
-
-db_get mxallowd/fake_mailservers
-
-[ ! -z "$RET" ] && add_entry "fake-mailserver" "${RET}"
+db_go || true
diff -u mxallowd-1.6a/debian/mxallowd.postinst mxallowd-1.6a/debian/mxallowd.postinst
--- mxallowd-1.6a/debian/mxallowd.postinst
+++ mxallowd-1.6a/debian/mxallowd.postinst
@@ -6,2 +6,32 @@
 
+add_entry() {
+	for server in $(echo "${2}")
+	do
+		echo "$1 ${server}" >> $TMP
+	done
+}
+
+if [ "$1" = "configure" ] && [ -z "$2" ]
+then
+    if [ ! -f /etc/mxallowd.conf ]
+    then
+        cp /usr/share/mxallowd/config.default /etc/mxallowd.conf
+    fi
+fi
+
+TMP=$(mktemp)
+if [ -f /etc/mxallowd.conf ]
+then
+    egrep -v "^ *(real|fake)-mailserver " /etc/mxallowd.conf > $TMP
+    db_get mxallowd/real_mailservers
+    [ -z "$RET" ] || add_entry "real-mailserver" "${RET}"
+
+    db_get mxallowd/fake_mailservers
+    [ -z "$RET" ] || add_entry "fake-mailserver" "${RET}"
+
+    cp $TMP /etc/mxallowd.conf
+fi
+
+rm -f ${TMP}
+
 #DEBHELPER#
only in patch2:
unchanged:
--- mxallowd-1.6a.orig/debian/mxallowd.postrm
+++ mxallowd-1.6a/debian/mxallowd.postrm
@@ -0,0 +1,8 @@
+#! /bin/sh
+set -e
+
+if [ "$1" = "purge" ]; then
+    rm -f /etc/mxallowd.conf
+fi
+
+#DEBHELPER#
only in patch2:
unchanged:

Reply via email to