9 # trivial but useful multi-instance manager
13 # Postfix versions 2.6 and later provide support for multiple
14 # Postfix instances. Instances share executable files and
15 # documentation, but have their own directories for configuration,
16 # queue and data files. In many cases different instances
17 # have different myhostname and inet_interfaces settings,
18 # though this is not always necessary.
20 # This command implements a trivial Postfix multi-instance
21 # manager. It simply applies commands such as "postfix start"
22 # to all the applicable Postfix instances.
23 # MANAGING MULTIPLE INSTANCES
26 # To hook the postfix-wrapper multi-instance manager into
27 # Postfix, see the POSTFIX-WRAPPER INITIALIZATION section
28 # below. To create a new Postfix instance, see the CREATING
29 # A NEW POSTFIX INSTANCE section below.
31 # To start, stop, get status, etc., with multiple Postfix
38 # For example, to find out what Postfix instances are configured:
44 # The postfix(1) command invokes the postfix-wrapper command.
45 # This in turn applies the postfix(1) command to the default
46 # Postfix instance, and to each instance specified with the
47 # default main.cf file's multi_instance_directories parameter
50 # The postfix-wrapper command will start, stop, reload, etc.,
51 # only Postfix instances that have "multi_instance_enable =
52 # yes" in their main.cf files. When an instance is disabled,
53 # postfix-wrapper replaces "start" commands by "check" so
54 # that problems will still be reported.
56 # The startup order is taken from the multi_instance_directories
57 # parameter; the default instance is prepended to the list.
58 # The startup order is used for all postfix(1) commands,
59 # except for commands that stop Postfix instances. In those
60 # cases the order is reversed.
61 # MANAGING INDIVIDUAL INSTANCES
64 # To manage an individual Postfix instance, use:
67 # # postfix -c /path/to/config_directory command
70 # This is also needed to manage the default Postfix instance,
71 # after you turn on multi-instance support.
73 # To use the Postfix sendmail command with a non-default
74 # Postfix instance, use:
77 # # sendmail -C /path/to/config_directory ...
80 # Note 1: that's capital C, not lower-case c.
82 # Note 2: only the default Postfix instance will check or
83 # update the shared Postfix files, including the executable
84 # files and documentation.
85 # POSTFIX-WRAPPER INITIALIZATION
88 # To hook this program into Postfix, execute the command
91 # This command should be entered as one line.
93 # In the example, replace /etc/postfix with the default Postfix
94 # configuration directory, and replace /usr/libexec/postfix
95 # with the daemon directory pathname of the default Postfix
99 # # postconf -c /etc/postfix -e
100 # "multi_instance_enable=yes"
101 # "multi_instance_wrapper=/usr/libexec/postfix/postfix-wrapper"
103 # CREATING A NEW POSTFIX INSTANCE
106 # To create a Postfix instance called "postfix-test", start
107 # with generic main.cf and master.cf files and customize the
108 # locations of the queue and data directories with the commands
109 # shown below. The last command updates main.cf and creates
110 # any directories that Postfix will need.
112 # Each command below should be entered as one line.
114 # In the example, replace /etc/postfix with the default Postfix
115 # configuration directory, and replace /usr/libexec/postfix
116 # with the daemon directory pathname of the default Postfix
120 # # mkdir /etc/postfix-test
121 # # cp /usr/libexec/postfix/main.cf /etc/postfix-test
122 # # cp /usr/libexec/postfix/master.cf /etc/postfix-test
123 # # postconf -c /etc/postfix-test -e
124 # "multi_instance_name=postfix-test"
125 # # postfix -c /etc/postfix post-install
126 # "config_directory=/etc/postfix-test"
127 # "queue_directory=/var/spool/postfix-test"
128 # "data_directory=/var/lib/postfix-test"
132 # Register this Postfix instance with the default instance.
133 # This command should be entered as one line.
136 # # postconf -e "multi_instance_directories=`postconf
137 # -h multi_instance_directories` /etc/postfix-test"
140 # Edit the myhostname and inet_interfaces main.cf parameters,
141 # so that they will not conflict with the default Postfix
142 # instance, and change whatever else needs to be changed.
144 # Test the instance with:
147 # # postfix -c /etc/postfix-test start
148 # # postfix -c /etc/postfix-test status
149 # [ other tests ... ]
152 # When everything is working satisfactorily, enable start/stop/etc.
153 # by the multi-instance manager:
156 # # postconf -c /etc/postfix-test -e multi_instance_enable=yes
160 # When an operation fails, the affected Postfix instance logs
161 # a message, and the multi-instance manager skips to the next
164 # Support for the multi_instance_group feature is not implemented.
166 # postfix(1) Postfix control program
167 # postfix-wrapper(5) multi-instance manager API
168 # postmulti(1) full-blown multi-instance manager
172 # The Secure Mailer license must be distributed with this software.
175 # IBM T.J. Watson Research
177 # Yorktown Heights, NY 10598, USA
182 : ${command_directory?"do not invoke this command directly"}
183 : ${daemon_directory?"do not invoke this command directly"}
187 POSTCONF
=$command_directory/postconf
188 POSTFIX
=$command_directory/postfix
190 # Canonicalize the instance directory list. The list is specified
193 instance_dirs
=`$POSTCONF -h multi_instance_directories | sed 's/,/ /'` ||
197 stop|quick-stop|abort|drain
)
199 for dir
in $config_directory $instance_dirs
201 all_dirs
="$dir $all_dirs"
203 *) all_dirs
="$config_directory $instance_dirs";;
206 # Execute the command on all applicable instances. When a Postfix
207 # instance is disabled, replace "postfix start" by "postfix check"
208 # so that problems will still be reported.
215 test "`$POSTCONF -c $dir -h multi_instance_enable`" = yes ||
{
216 $POSTFIX -c $dir check || err
=$?
219 stop|abort|drain|flush|reload
)
220 test "`$POSTCONF -c $dir -h multi_instance_enable`" = yes ||
223 $POSTFIX -c $dir "$@" || err
=$?