Your message dated Thu, 12 Apr 2012 21:07:37 -0600
with message-id <[email protected]>
and subject line Re: Bug#433660: postfix: Proposal for init.d script handling 
of multiple instances
has caused the Debian Bug report #433660,
regarding postfix: Proposal for init.d script handling of multiple instances
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
433660: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=433660
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
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.
--- /etc/init.d/postfix.orig    2007-06-02 01:44:00.000000000 -0400
+++ /etc/init.d/postfix 2007-07-18 10:59:24.000000000 -0400
@@ -7,6 +7,7 @@
 
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 DAEMON=/usr/sbin/postfix
+DEFAULT_CONFIG="/etc/postfix"
 NAME=Postfix
 TZ=
 unset TZ
@@ -16,13 +17,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)
        exe=$(ls -l /proc/$pid/exe 2>/dev/null | sed 's/.* //; s/.*\///')
@@ -31,24 +37,56 @@
        fi
     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
            # 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 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
@@ -71,19 +109,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
@@ -91,6 +134,8 @@
        else
            log_end_msg 0
        fi
+       
+       done
     ;;
 
     restart)
@@ -99,16 +144,26 @@
     ;;
     
     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
     ;;
 
     flush|check|abort)
-       ${DAEMON} $1
+
+       for CFG in $CONFIGS; do
+       
+       ${DAEMON} -c "$CFG" $1
+       
+       done
     ;;
 
     *)

--- End Message ---
--- Begin Message ---
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


--- End Message ---

Reply via email to