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.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
;;
*)