Debian Bug report logs - #433660
postfix: Proposal for init.d script handling of multiple instances

version graph

Package: postfix; Maintainer for postfix is LaMont Jones <lamont@debian.org>; Source for postfix is src:postfix.

Reported by: Peter Rabbitson <rabbit@rabbit.us>

Date: Wed, 18 Jul 2007 16:00:01 UTC

Severity: wishlist

Tags: patch

Found in version postfix/2.4.3-1

Fixed in version postfix/2.8.4-1

Done: LaMont Jones <lamont@debian.org>

Bug is archived. No further changes may be made.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to debian-bugs-dist@lists.debian.org, LaMont Jones <lamont@debian.org>:
Bug#433660; Package postfix. Full text and rfc822 format available.

Acknowledgement sent to Peter Rabbitson <rabbit@rabbit.us>:
New Bug report received and forwarded. Copy sent to LaMont Jones <lamont@debian.org>. Full text and rfc822 format available.

Message #5 received at submit@bugs.debian.org (full text, mbox, reply):

From: Peter Rabbitson <rabbit@rabbit.us>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: postfix: Proposal for init.d script handling of multiple instances
Date: Wed, 18 Jul 2007 17:56:40 +0200
[Message part 1 (text/plain, inline)]
Package: postfix
Version: 2.4.3-1
Severity: wishlist
Tags: patch


Hello,

The attached patch to /etc/init.d/postfix allows running and controlling more
than one postfix instance. I am taking advantage of the postfix design, such
that one configuration is selected as primary at compile time (usually 
/etc/postfix), and then any additional config directory trees which describe a
separate postfix instance must be listed under the alternate_config_directories
parameter in /etc/postfix/main.cf. I use this information to enumerate config
directories belonging to each instance, and then loop over them for every
requested action. More information about this config parameter can be found at:
http://www.postfix.org/postconf.5.html#alternate_config_directories

Please feel free to apply this patch at the next release if you find the idea
useful. 

Cheers

Peter

P.S. I deliberately did not maintain correct indentation in order to obtain a 
smaller diff. Please fix for clarity.
[postfix_multi.diff (text/plain, attachment)]

Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#433660; Package postfix. Full text and rfc822 format available.

Acknowledgement sent to LaMont Jones <lamont@debian.org>:
Extra info received and forwarded to list. Full text and rfc822 format available.

Message #10 received at 433660@bugs.debian.org (full text, mbox, reply):

From: LaMont Jones <lamont@debian.org>
To: Peter Rabbitson <rabbit@rabbit.us>, 433660@bugs.debian.org
Subject: Re: Bug#433660: postfix: Proposal for init.d script handling of multiple instances
Date: Fri, 8 Feb 2008 23:06:13 -0700
On Wed, Jul 18, 2007 at 05:56:40PM +0200, Peter Rabbitson wrote:
> The attached patch to /etc/init.d/postfix allows running and controlling more
> than one postfix instance. I am taking advantage of the postfix design, such
> ...
> 
> Please feel free to apply this patch at the next release if you find the idea
> useful. 

Given that work in this arena is ongoing, and didn't make the cut for
2.5, I'm inclined to wait for this to come down from upstream, rather
than inventing our own solution now.

lamont




Information forwarded to debian-bugs-dist@lists.debian.org, LaMont Jones <lamont@debian.org>:
Bug#433660; Package postfix. Full text and rfc822 format available.

Acknowledgement sent to Peter Rabbitson <rabbit@rabbit.us>:
Extra info received and forwarded to list. Copy sent to LaMont Jones <lamont@debian.org>. Full text and rfc822 format available.

Message #15 received at 433660@bugs.debian.org (full text, mbox, reply):

From: Peter Rabbitson <rabbit@rabbit.us>
To: LaMont Jones <lamont@debian.org>
Cc: 433660@bugs.debian.org
Subject: Re: Bug#433660: postfix: Proposal for init.d script handling of multiple instances
Date: Sat, 09 Feb 2008 08:15:27 +0100
LaMont Jones wrote:
> On Wed, Jul 18, 2007 at 05:56:40PM +0200, Peter Rabbitson wrote:
>> The attached patch to /etc/init.d/postfix allows running and controlling more
>> than one postfix instance. I am taking advantage of the postfix design, such
>> ...
>>
>> Please feel free to apply this patch at the next release if you find the idea
>> useful. 
> 
> Given that work in this arena is ongoing, and didn't make the cut for
> 2.5, I'm inclined to wait for this to come down from upstream, rather
> than inventing our own solution now.
> 

Hey whatever works for you. I am a little surprised as this is a relatively 
small and totally unintrusive patchset, but that's why there is one maintainer 
per package not 1000 :) I'll just keep patching the init script on updates.

Thanks for considering

Cheers!




Information forwarded to debian-bugs-dist@lists.debian.org, LaMont Jones <lamont@debian.org>:
Bug#433660; Package postfix. Full text and rfc822 format available.

Acknowledgement sent to Peter Rabbitson <rabbit+bugs@rabbit.us>:
Extra info received and forwarded to list. Copy sent to LaMont Jones <lamont@debian.org>. Full text and rfc822 format available.

Message #20 received at 433660@bugs.debian.org (full text, mbox, reply):

From: Peter Rabbitson <rabbit+bugs@rabbit.us>
To: LaMont Jones <lamont@debian.org>
Cc: 433660@bugs.debian.org
Subject: Re: Bug#433660: postfix: Proposal for init.d script handling of multiple instances
Date: Tue, 24 Jun 2008 19:34:59 +0200
[Message part 1 (text/plain, inline)]
LaMont Jones wrote:
> On Wed, Jul 18, 2007 at 05:56:40PM +0200, Peter Rabbitson wrote:
>> The attached patch to /etc/init.d/postfix allows running and controlling more
>> than one postfix instance. I am taking advantage of the postfix design, such
>> ...
>>
>> Please feel free to apply this patch at the next release if you find the idea
>> useful. 
> 
> Given that work in this arena is ongoing, and didn't make the cut for
> 2.5, I'm inclined to wait for this to come down from upstream, rather
> than inventing our own solution now.
> 
> lamont

I'd like to draw your attention to this bugreport once again. I did some 
research and it seems that the upstream developers do not support/distribute 
any init.d scripts (even an example one). This being said I am not sure what 
"work in this area" you are referring to. Once again I am attaching for your 
consideration a new patch against 2.5.2-1.

Peter

[postfix_init.diff (text/x-diff, inline)]
--- postfix.old	2008-05-30 04:03:00.000000000 +0200
+++ postfix	2008-06-24 19:32:32.753474580 +0200
@@ -19,6 +19,7 @@
 
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 DAEMON=/usr/sbin/postfix
+DEFAULT_CONFIG="/etc/postfix"
 NAME=Postfix
 TZ=
 unset TZ
@@ -28,13 +29,18 @@
 
 test -f /etc/default/postfix && . /etc/default/postfix
 
-test -x $DAEMON && test -f /etc/postfix/main.cf || exit 0
+test -x $DAEMON && test -f "$DEFAULT_CONFIG/main.cf" || exit 0
 
 . /lib/lsb/init-functions
 #DISTRO=$(lsb_release -is 2>/dev/null || echo Debian)
 
 running() {
-    queue=$(postconf -h queue_directory 2>/dev/null || echo /var/spool/postfix)
+	if [ -n $1 ]; then
+	    CFG_DIR="$1"
+	else 
+		CFG_DIR="$DEFAULT_CONFIG"
+	fi
+    queue=$(postconf -c $CFG_DIR -h queue_directory 2>/dev/null)
     if [ -f ${queue}/pid/master.pid ]; then
 	pid=$(sed 's/ //g' ${queue}/pid/master.pid)
 	# what directory does the executable live in.  stupid prelink systems.
@@ -45,17 +51,48 @@
     fi
 }
 
+parse_alt_cfg() {
+	OIFS=$IFS
+	IFS=
+	while read line ; do
+		# skip comments/blanks
+		if echo $line | grep -E "^[[:space:]]*$|^#" &>/dev/null; then continue ;fi
+
+		# look for alt config parameter
+		if echo $line | grep "^alternate_config_directories[[:space:]]*=" &>/dev/null; then
+			ALT_CONFIGS=$(echo $line | sed 's/alternate_config_directories\s*=//')
+			ALT_CFG="y"
+		# if a line starts with a space and we are stil within an alt config - append
+		elif [ "$ALT_CFG" = "y" ] && echo $line | grep "^[[:space:]]" &>/dev/null; then
+			ALT_CONFIGS="$ALT_CONFIGS $line"
+		# otherwise a different parameter is encountered - we are done
+		else
+			ALT_CFG=""
+		fi
+	done < "$DEFAULT_CONFIG/main.cf"
+
+	IFS=$OIFS
+}
+
+parse_alt_cfg
+CONFIGS="$DEFAULT_CONFIG $ALT_CONFIGS"
+
+
+
 case "$1" in
     start)
-	log_daemon_msg "Starting Postfix Mail Transport Agent" postfix
-	RUNNING=$(running)
+	
+	for CFG in $CONFIGS; do
+	
+	log_daemon_msg "Starting Postfix Mail Transport Agent" "$CFG"
+	RUNNING=$(running "$CFG")
 	if [ -n "$RUNNING" ]; then
 	    log_end_msg 0
 	else
 	    # if you set myorigin to 'ubuntu.com' or 'debian.org', it's wrong, and annoys the admins of
 	    # those domains.  See also sender_canonical_maps.
 
-	    MYORIGIN=$(postconf -h myorigin | tr 'A-Z' 'a-z')
+	    MYORIGIN=$(postconf -c "$CFG" -h myorigin | tr 'A-Z' 'a-z')
 	    if [ "X${MYORIGIN#/}" != "X${MYORIGIN}" ]; then
 		MYORIGIN=$(tr 'A-Z' 'a-z' < $MYORIGIN)
 	    fi
@@ -66,17 +103,17 @@
 	    fi
 
 	    # see if anything is running chrooted.
-	    NEED_CHROOT=$(awk '/^[0-9a-z]/ && ($5 ~ "[-yY]") { print "y"; exit}' /etc/postfix/master.cf)
+	    NEED_CHROOT=$(awk '/^[0-9a-z]/ && ($5 ~ "[-yY]") { print "y"; exit}' "$CFG/master.cf")
 
 	    if [ -n "$NEED_CHROOT" ] && [ -n "$SYNC_CHROOT" ]; then
 		# Make sure that the chroot environment is set up correctly.
 		oldumask=$(umask)
 		umask 022
-		cd $(postconf -h queue_directory)
+		cd $(postconf -c "$CFG" -h queue_directory)
 
 		# if we're using tls, then we need to add etc/ssl/certs/ca-certificates.crt.
-		smtp_use_tls=$(postconf -h smtp_use_tls)
-		smtpd_use_tls=$(postconf -h smtpd_use_tls)
+		smtp_use_tls=$(postconf -c "$CFG" -h smtp_use_tls)
+		smtpd_use_tls=$(postconf -c "$CFG" -h smtpd_use_tls)
 		if [ "X$smtp_use_tls" = "Xyes" -o "X$smtpd_use_tls" = "Xyes" ]; then
 		    if [ -f "/etc/ssl/certs/ca-certificates.crt" ]; then 
 			mkdir -p etc/ssl/certs
@@ -85,7 +122,7 @@
 		fi
 
 		# if we're using unix:passwd.byname, then we need to add etc/passwd.
-		local_maps=$(postconf -h local_recipient_maps)
+		local_maps=$(postconf -c "$CFG" -h local_recipient_maps)
 		if [ "X$local_maps" != "X${local_maps#*unix:passwd.byname}" ]; then
 		    if [ "X$local_maps" = "X${local_maps#*proxy:unix:passwd.byname}" ]; then
 			sed 's/^\([^:]*\):[^:]*/\1:x/' /etc/passwd > etc/passwd
@@ -108,19 +145,24 @@
 		umask $oldumask
 	    fi
 
-	    if start-stop-daemon --start --exec ${DAEMON} -- quiet-quick-start; then
+	    if start-stop-daemon --start --exec ${DAEMON} -- -c "$CFG" quiet-quick-start; then
 		log_end_msg 0
 	    else
 		log_end_msg 1
 	    fi
 	fi
+	
+	done
     ;;
 
     stop)
-	RUNNING=$(running)
-	log_daemon_msg "Stopping Postfix Mail Transport Agent" postfix
+	
+	for CFG in $CONFIGS; do
+	
+	RUNNING=$(running "$CFG")
+	log_daemon_msg "Stopping Postfix Mail Transport Agent" "$CFG"
 	if [ -n "$RUNNING" ]; then
-	    if ${DAEMON} quiet-stop; then
+	    if ${DAEMON} -c "$CFG" quiet-stop; then
 		log_end_msg 0
 	    else
 		log_end_msg 1
@@ -128,6 +170,8 @@
 	else
 	    log_end_msg 0
 	fi
+	
+	done
     ;;
 
     restart)
@@ -136,12 +180,17 @@
     ;;
     
     force-reload|reload)
-	log_action_begin_msg "Reloading Postfix configuration"
-	if ${DAEMON} quiet-reload; then
+	
+	for CFG in $CONFIGS; do
+	
+	log_action_begin_msg "Reloading Postfix configuration ($CFG)"
+	if ${DAEMON} -c "$CFG" quiet-reload; then
 	    log_action_end_msg 0
 	else
 	    log_action_end_msg 1
 	fi
+	
+	done
     ;;
 
     status)
@@ -156,7 +205,11 @@
     ;;
 
     flush|check|abort)
-	${DAEMON} $1
+
+	for CFG in $CONFIGS; do
+	${DAEMON} -c "$CFG" $1
+	
+	done
     ;;
 
     *)

Information forwarded to debian-bugs-dist@lists.debian.org, LaMont Jones <lamont@debian.org>:
Bug#433660; Package postfix. Full text and rfc822 format available.

Acknowledgement sent to "Thijs Kinkhorst" <thijs@debian.org>:
Extra info received and forwarded to list. Copy sent to LaMont Jones <lamont@debian.org>. Full text and rfc822 format available.

Message #25 received at 433660@bugs.debian.org (full text, mbox, reply):

From: "Thijs Kinkhorst" <thijs@debian.org>
To: 433660@bugs.debian.org
Subject: Re: Bug#433660: postfix: Proposal for init.d script handling of multiple instances
Date: Wed, 30 Jul 2008 17:35:17 +0200 (CEST)
Hi,

I'd like to "vote" for inclusion of this init script into the postfix
package. We're using it here and I think it's a very elegant solution: it
just uses the already available Postfix configuration variable to see
which services to start.

That makes it work exactly the same for the normal, 1-instance user and at
the same time without additional editing of the init script for those
using multiple instances.


thanks,
Thijs





Information forwarded to debian-bugs-dist@lists.debian.org, LaMont Jones <lamont@debian.org>:
Bug#433660; Package postfix. Full text and rfc822 format available.

Acknowledgement sent to Teodor <mteodor@gmail.com>:
Extra info received and forwarded to list. Copy sent to LaMont Jones <lamont@debian.org>. Full text and rfc822 format available.

Message #30 received at 433660@bugs.debian.org (full text, mbox, reply):

From: Teodor <mteodor@gmail.com>
To: "Thijs Kinkhorst" <thijs@debian.org>, 433660@bugs.debian.org
Subject: Re: Bug#433660: postfix: Proposal for init.d script handling of multiple instances
Date: Wed, 30 Jul 2008 19:19:04 +0300
On Wed, Jul 30, 2008 at 6:35 PM, Thijs Kinkhorst <thijs@debian.org> wrote:
> Hi,
>
> I'd like to "vote" for inclusion of this init script into the postfix
> package. We're using it here and I think it's a very elegant solution: it
> just uses the already available Postfix configuration variable to see
> which services to start.
>
> That makes it work exactly the same for the normal, 1-instance user and at
> the same time without additional editing of the init script for those
> using multiple instances.

The most important thing is to make sure the new init.d script has the
same functionality for those that are running a *single* postfix
instance.

Although this setup is mainly used for ISPs, I'll like to have this
feature for postfix. Since the final freeze for lenny is in effect,
this is a new feature and it won't be accepted as freeze exception. I
hope to have it on lenny+1.

Thanks


PS: who should ask for a freeze exception for 2.5.2-2 which seem to
add only translations?




Information forwarded to debian-bugs-dist@lists.debian.org, LaMont Jones <lamont@debian.org>:
Bug#433660; Package postfix. (Tue, 03 Feb 2009 08:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Rudy Gevaert <Rudy.Gevaert@UGent.be>:
Extra info received and forwarded to list. Copy sent to LaMont Jones <lamont@debian.org>. (Tue, 03 Feb 2009 08:30:02 GMT) Full text and rfc822 format available.

Message #35 received at 433660@bugs.debian.org (full text, mbox, reply):

From: Rudy Gevaert <Rudy.Gevaert@UGent.be>
To: 433660@bugs.debian.org
Subject: multi instance in postfix
Date: Tue, 03 Feb 2009 09:28:19 +0100
Hi,

Postfix 2.6 Snapshot 20090125

Has support for multiple instances.


-- 
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Rudy Gevaert          Rudy.Gevaert@UGent.be          tel:+32 9 264 4734
Directie ICT, afd. Infrastructuur ICT Department, Infrastructure office
Groep Systemen                    Systems group
Universiteit Gent                 Ghent University
Krijgslaan 281, gebouw S9, 9000 Gent, Belgie               www.UGent.be
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --




Marked as fixed in versions postfix/2.8.4-1. Request was from LaMont Jones <lamont@debian.org> to control@bugs.debian.org. (Fri, 13 Apr 2012 03:09:12 GMT) Full text and rfc822 format available.

Reply sent to LaMont Jones <lamont@debian.org>:
You have taken responsibility. (Fri, 13 Apr 2012 03:18:09 GMT) Full text and rfc822 format available.

Notification sent to Peter Rabbitson <rabbit@rabbit.us>:
Bug acknowledged by developer. (Fri, 13 Apr 2012 03:18:10 GMT) Full text and rfc822 format available.

Message #42 received at 433660-done@bugs.debian.org (full text, mbox, reply):

From: LaMont Jones <lamont@debian.org>
To: Peter Rabbitson <rabbit@rabbit.us>, 433660-done@bugs.debian.org
Subject: Re: Bug#433660: postfix: Proposal for init.d script handling of multiple instances
Date: Thu, 12 Apr 2012 21:07:37 -0600
On Wed, Jul 18, 2007 at 05:56:40PM +0200, Peter Rabbitson wrote:
> The attached patch to /etc/init.d/postfix allows running and controlling more
> than one postfix instance. I am taking advantage of the postfix design, such
> that one configuration is selected as primary at compile time (usually 

Fixed in 2.8.4-1

lamont




Bug archived. Request was from Debbugs Internal Request <owner@bugs.debian.org> to internal_control@bugs.debian.org. (Fri, 11 May 2012 07:37:20 GMT) Full text and rfc822 format available.

Send a report that this bug log contains spam.


Debian bug tracking system administrator <owner@bugs.debian.org>. Last modified: Sun May 31 23:02:07 2015; Machine Name: beach

Debian Bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.