10
10
postfix-wrapper - Postfix multi-instance API
13
Support for managing multiple Postfix instances is avail-
14
able as of version 2.6. Instances share executable files
15
and documentation, but have their own directories for con-
16
figuration, queue and data files.
18
This document describes how the familiar "postfix start"
19
etc. user interface can be used to manage one or multiple
20
Postfix instances, and gives details of an API to coordi-
21
nate activities between the <a href="postfix.1.html">postfix(1)</a> command and a
22
multi-instance manager program.
24
With multi-instance support, the default Postfix instance
25
is always required. This instance is identified by the
26
<a href="postconf.5.html#config_directory">config_directory</a> parameter's default value.
13
Support for managing multiple Postfix instances is available as of ver-
14
sion 2.6. Instances share executable files and documentation, but have
15
their own directories for configuration, queue and data files.
17
This document describes how the familiar "postfix start" etc. user
18
interface can be used to manage one or multiple Postfix instances, and
19
gives details of an API to coordinate activities between the <a href="postfix.1.html">postfix(1)</a>
20
command and a multi-instance manager program.
22
With multi-instance support, the default Postfix instance is always
23
required. This instance is identified by the <a href="postconf.5.html#config_directory">config_directory</a> parame-
28
26
<b>GENERAL OPERATION</b>
29
Multi-instance support is backwards compatible: when you
30
run only one Postfix instance, commands such as "postfix
31
start" will not change behavior at all.
27
Multi-instance support is backwards compatible: when you run only one
28
Postfix instance, commands such as "postfix start" will not change
33
Even with multiple Postfix instances, you can keep using
34
the same postfix commands in boot scripts, upgrade proce-
35
dures, and other places. The commands do more work, but
36
humans are not forced to learn new tricks.
31
Even with multiple Postfix instances, you can keep using the same post-
32
fix commands in boot scripts, upgrade procedures, and other places. The
33
commands do more work, but humans are not forced to learn new tricks.
38
35
For example, to start all Postfix instances, use:
42
Other <a href="postfix.1.html">postfix(1)</a> commands also work as expected. For exam-
43
ple, to find out what Postfix instances exist in a multi-
44
instance configuration, use:
39
Other <a href="postfix.1.html">postfix(1)</a> commands also work as expected. For example, to find
40
out what Postfix instances exist in a multi-instance configuration,
48
This enumerates the status of all Postfix instances within
49
a multi-instance configuration.
45
This enumerates the status of all Postfix instances within a multi-
46
instance configuration.
51
48
<b>MANAGING AN INDIVIDUAL POSTFIX INSTANCE</b>
52
To manage a specific Postfix instance, specify its config-
53
uration directory on the <a href="postfix.1.html">postfix(1)</a> command line:
49
To manage a specific Postfix instance, specify its configuration direc-
50
tory on the <a href="postfix.1.html">postfix(1)</a> command line:
55
52
# postfix -c <i>/path/to/config</i><b>_</b><i>directory command</i>
57
Alternatively, the <a href="postfix.1.html">postfix(1)</a> command accepts the
58
instance's configuration directory via the MAIL_CONFIG
59
environment variable (the -c command-line option has
54
Alternatively, the <a href="postfix.1.html">postfix(1)</a> command accepts the instance's configura-
55
tion directory via the MAIL_CONFIG environment variable (the -c com-
56
mand-line option has higher precedence).
62
Otherwise, the <a href="postfix.1.html">postfix(1)</a> command will operate on all
58
Otherwise, the <a href="postfix.1.html">postfix(1)</a> command will operate on all Postfix
65
61
<b>ENABLING POSTFIX(1) MULTI-INSTANCE MODE</b>
66
By default, the <a href="postfix.1.html">postfix(1)</a> command operates in single-
67
instance mode. In this mode the command invokes the post-
68
fix-script file directly (currently installed in the dae-
69
mon directory). This file contains the commands that
70
start or stop one Postfix instance, that upgrade the con-
71
figuration of one Postfix instance, and so on.
73
When the <a href="postfix.1.html">postfix(1)</a> command operates in multi-instance
74
mode as discussed below, the command needs to execute
75
start, stop, etc. commands for each Postfix instance.
76
This multiplication of commands is handled by a multi-
77
instance manager program.
79
Turning on <a href="postfix.1.html">postfix(1)</a> multi-instance mode goes as follows:
80
in the default Postfix instance's <a href="postconf.5.html">main.cf</a> file, 1) specify
81
the pathname of a multi-instance manager program with the
82
<a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> parameter; 2) populate the
83
<a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter with the configura-
84
tion directory pathnames of additional Postfix instances.
62
By default, the <a href="postfix.1.html">postfix(1)</a> command operates in single-instance mode. In
63
this mode the command invokes the postfix-script file directly (cur-
64
rently installed in the daemon directory). This file contains the com-
65
mands that start or stop one Postfix instance, that upgrade the config-
66
uration of one Postfix instance, and so on.
68
When the <a href="postfix.1.html">postfix(1)</a> command operates in multi-instance mode as dis-
69
cussed below, the command needs to execute start, stop, etc. commands
70
for each Postfix instance. This multiplication of commands is handled
71
by a multi-instance manager program.
73
Turning on <a href="postfix.1.html">postfix(1)</a> multi-instance mode goes as follows: in the
74
default Postfix instance's <a href="postconf.5.html">main.cf</a> file, 1) specify the pathname of a
75
multi-instance manager program with the <a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> parame-
76
ter; 2) populate the <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter with the con-
77
figuration directory pathnames of additional Postfix instances. For
87
80
/etc/postfix/<a href="postconf.5.html">main.cf</a>:
88
81
<a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> = $<a href="postconf.5.html#daemon_directory">daemon_directory</a>/postfix-wrapper
89
82
<a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> = /etc/postfix-test
91
The $<a href="postconf.5.html#daemon_directory">daemon_directory</a>/postfix-wrapper file implements a
92
simple manager and contains instructions for creating
93
Postfix instances by hand. The <a href="postmulti.1.html">postmulti(1)</a> command pro-
94
vides a more extensive implementation including support
95
for life-cycle management.
97
The <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> and other <a href="postconf.5.html">main.cf</a> parame-
98
ters are listed below in the CONFIGURATION PARAMETERS sec-
101
In multi-instance mode, the <a href="postfix.1.html">postfix(1)</a> command invokes the
102
$<a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> command instead of the postfix-
103
script file. This multi-instance manager in turn executes
104
the <a href="postfix.1.html">postfix(1)</a> command in single-instance mode for each
107
To illustrate the main ideas behind multi-instance opera-
108
tion, below is an example of a simple but useful multi-
109
instance manager implementation:
84
The $<a href="postconf.5.html#daemon_directory">daemon_directory</a>/postfix-wrapper file implements a simple manager
85
and contains instructions for creating Postfix instances by hand. The
86
<a href="postmulti.1.html">postmulti(1)</a> command provides a more extensive implementation including
87
support for life-cycle management.
89
The <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> and other <a href="postconf.5.html">main.cf</a> parameters are listed
90
below in the CONFIGURATION PARAMETERS section.
92
In multi-instance mode, the <a href="postfix.1.html">postfix(1)</a> command invokes the
93
$<a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> command instead of the postfix-script file.
94
This multi-instance manager in turn executes the <a href="postfix.1.html">postfix(1)</a> command in
95
single-instance mode for each Postfix instance.
97
To illustrate the main ideas behind multi-instance operation, below is
98
an example of a simple but useful multi-instance manager implementa-
139
129
<b>PER-INSTANCE MULTI-INSTANCE MANAGER CONTROLS</b>
140
Each Postfix instance has its own <a href="postconf.5.html">main.cf</a> file with param-
141
eters that control how the multi-instance manager operates
142
on that instance. This section discusses the most impor-
145
The setting "<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes" allows the
146
multi-instance manager to start (stop, etc.) the corre-
147
sponding Postfix instance. For safety reasons, this set-
148
ting is not the default.
150
The default setting "<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = no" is useful
151
for manual testing with "postfix -c <i>/path/name</i> start" etc.
152
The multi-instance manager will not start such an
153
instance, and it will skip commands such as "stop" or
154
"flush" that require a running Postfix instance. The
155
multi-instance manager will execute commands such as
156
"check", "set-permissions" or "upgrade-configuration", and
157
it will replace "start" by "check" so that problems will
158
be reported even when the instance is disabled.
130
Each Postfix instance has its own <a href="postconf.5.html">main.cf</a> file with parameters that
131
control how the multi-instance manager operates on that instance. This
132
section discusses the most important settings.
134
The setting "<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes" allows the multi-instance
135
manager to start (stop, etc.) the corresponding Postfix instance. For
136
safety reasons, this setting is not the default.
138
The default setting "<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = no" is useful for manual
139
testing with "postfix -c <i>/path/name</i> start" etc. The multi-instance
140
manager will not start such an instance, and it will skip commands such
141
as "stop" or "flush" that require a running Postfix instance. The
142
multi-instance manager will execute commands such as "check", "set-per-
143
missions" or "upgrade-configuration", and it will replace "start" by
144
"check" so that problems will be reported even when the instance is
160
147
<b>MAINTAINING SHARED AND NON-SHARED FILES</b>
161
Some files are shared between Postfix instances, such as
162
executables and manpages, and some files are per-instance,
163
such as configuration files, mail queue files, and data
164
files. See the NON-SHARED FILES section below for a list
165
of per-instance files.
167
Before Postfix multi-instance support was implemented, the
168
executables, manpages, etc., have always been maintained
169
as part of the default Postfix instance.
171
With multi-instance support, we simply continue to do
172
this. Specifically, a Postfix instance will not check or
173
update shared files when that instance's <a href="postconf.5.html#config_directory">config_directory</a>
174
value is listed with the default <a href="postconf.5.html">main.cf</a> file's
175
<a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter.
177
The consequence of this approach is that the default Post-
178
fix instance should be checked and updated before any
148
Some files are shared between Postfix instances, such as executables
149
and manpages, and some files are per-instance, such as configuration
150
files, mail queue files, and data files. See the NON-SHARED FILES sec-
151
tion below for a list of per-instance files.
153
Before Postfix multi-instance support was implemented, the executables,
154
manpages, etc., have always been maintained as part of the default
157
With multi-instance support, we simply continue to do this. Specifi-
158
cally, a Postfix instance will not check or update shared files when
159
that instance's <a href="postconf.5.html#config_directory">config_directory</a> value is listed with the default
160
<a href="postconf.5.html">main.cf</a> file's <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter.
162
The consequence of this approach is that the default Postfix instance
163
should be checked and updated before any other instances.
181
165
<b>MULTI-INSTANCE API SUMMARY</b>
182
Only the multi-instance manager implements support for the
183
<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> configuration parameter. The multi-
184
instance manager will start only Postfix instances whose
185
<a href="postconf.5.html">main.cf</a> file has "<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes". A setting
186
of "no" allows a Postfix instance to be tested by hand.
188
The <a href="postfix.1.html">postfix(1)</a> command operates on only one Postfix
189
instance when the -c option is specified, or when
190
MAIL_CONFIG is present in the process environment. This is
191
necessary to terminate recursion.
193
Otherwise, when the <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter
194
value is non-empty, the <a href="postfix.1.html">postfix(1)</a> command executes the
195
command specified with the <a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> parame-
196
ter, instead of executing the commands in postfix-script.
198
The multi-instance manager skips commands such as "stop"
199
or "reload" that require a running Postfix instance, when
200
an instance does not have "<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes".
201
This avoids false error messages.
203
The multi-instance manager replaces a "start" command by
204
"check" when a Postfix instance's <a href="postconf.5.html">main.cf</a> file does not
205
have "<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes". This substitution
206
ensures that problems will be reported even when the
207
instance is disabled.
209
No Postfix command or script will update or check shared
210
files when its <a href="postconf.5.html#config_directory">config_directory</a> value is listed in the
211
default <a href="postconf.5.html">main.cf</a>'s <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter
212
value. Therefore, the default instance should be checked
213
and updated before any Postfix instances that depend on
216
Set-gid commands such as <a href="postdrop.1.html">postdrop(1)</a> and <a href="postqueue.1.html">postqueue(1)</a>
217
effectively append the <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parame-
218
ter value to the legacy <a href="postconf.5.html#alternate_config_directories">alternate_config_directories</a>
219
parameter value. The commands use this information to
220
determine whether a -c option or MAIL_CONFIG environment
166
Only the multi-instance manager implements support for the
167
<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> configuration parameter. The multi-instance man-
168
ager will start only Postfix instances whose <a href="postconf.5.html">main.cf</a> file has
169
"<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes". A setting of "no" allows a Postfix
170
instance to be tested by hand.
172
The <a href="postfix.1.html">postfix(1)</a> command operates on only one Postfix instance when the
173
-c option is specified, or when MAIL_CONFIG is present in the process
174
environment. This is necessary to terminate recursion.
176
Otherwise, when the <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter value is non-
177
empty, the <a href="postfix.1.html">postfix(1)</a> command executes the command specified with the
178
<a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> parameter, instead of executing the commands in
181
The multi-instance manager skips commands such as "stop" or "reload"
182
that require a running Postfix instance, when an instance does not have
183
"<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> = yes". This avoids false error messages.
185
The multi-instance manager replaces a "start" command by "check" when a
186
Postfix instance's <a href="postconf.5.html">main.cf</a> file does not have "<a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> =
187
yes". This substitution ensures that problems will be reported even
188
when the instance is disabled.
190
No Postfix command or script will update or check shared files when its
191
<a href="postconf.5.html#config_directory">config_directory</a> value is listed in the default <a href="postconf.5.html">main.cf</a>'s
192
<a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter value. Therefore, the default
193
instance should be checked and updated before any Postfix instances
196
Set-gid commands such as <a href="postdrop.1.html">postdrop(1)</a> and <a href="postqueue.1.html">postqueue(1)</a> effectively
197
append the <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter value to the legacy
198
<a href="postconf.5.html#alternate_config_directories">alternate_config_directories</a> parameter value. The commands use this
199
information to determine whether a -c option or MAIL_CONFIG environment
221
200
setting specifies a legitimate value.
223
The legacy <a href="postconf.5.html#alternate_config_directories">alternate_config_directories</a> parameter remains
224
necessary for non-default Postfix instances that are run-
225
ning different versions of Postfix, or that are not man-
226
aged together with the default Postfix instance.
202
The legacy <a href="postconf.5.html#alternate_config_directories">alternate_config_directories</a> parameter remains necessary for
203
non-default Postfix instances that are running different versions of
204
Postfix, or that are not managed together with the default Postfix
228
207
<b>ENVIRONMENT VARIABLES</b>
230
When present, this forces the <a href="postfix.1.html">postfix(1)</a> command to
231
operate only on the specified Postfix instance.
232
This environment variable is exported by the <a href="postfix.1.html">post-</a>
233
<a href="postfix.1.html">fix(1)</a> -c option, so that <a href="postfix.1.html">postfix(1)</a> commands in
234
descendant processes will work correctly.
209
When present, this forces the <a href="postfix.1.html">postfix(1)</a> command to operate only
210
on the specified Postfix instance. This environment variable is
211
exported by the <a href="postfix.1.html">postfix(1)</a> -c option, so that <a href="postfix.1.html">postfix(1)</a> com-
212
mands in descendant processes will work correctly.
236
214
<b>CONFIGURATION PARAMETERS</b>
237
The text below provides only a parameter summary. See
238
<a href="postconf.5.html">postconf(5)</a> for more details.
215
The text below provides only a parameter summary. See <a href="postconf.5.html">postconf(5)</a> for
240
218
<b><a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> (empty)</b>
241
An optional list of non-default Postfix configura-
242
tion directories; these directories belong to addi-
243
tional Postfix instances that share the Postfix
244
executable files and documentation with the default
245
Postfix instance, and that are started, stopped,
219
An optional list of non-default Postfix configuration directo-
220
ries; these directories belong to additional Postfix instances
221
that share the Postfix executable files and documentation with
222
the default Postfix instance, and that are started, stopped,
246
223
etc., together with the default Postfix instance.
248
225
<b><a href="postconf.5.html#multi_instance_wrapper">multi_instance_wrapper</a> (empty)</b>
249
The pathname of a multi-instance manager command
250
that the <a href="postfix.1.html"><b>postfix</b>(1)</a> command invokes when the
251
<a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a> parameter value is non-
226
The pathname of a multi-instance manager command that the <a href="postfix.1.html"><b>post-</b></a>
227
<a href="postfix.1.html"><b>fix</b>(1)</a> command invokes when the <a href="postconf.5.html#multi_instance_directories">multi_instance_directories</a>
228
parameter value is non-empty.
254
230
<b><a href="postconf.5.html#multi_instance_name">multi_instance_name</a> (empty)</b>
255
The optional instance name of this Postfix
231
The optional instance name of this Postfix instance.
258
233
<b><a href="postconf.5.html#multi_instance_group">multi_instance_group</a> (empty)</b>
259
The optional instance group name of this Postfix
234
The optional instance group name of this Postfix instance.
262
236
<b><a href="postconf.5.html#multi_instance_enable">multi_instance_enable</a> (no)</b>
263
Allow this Postfix instance to be started, stopped,
264
etc., by a multi-instance manager.
237
Allow this Postfix instance to be started, stopped, etc., by a
238
multi-instance manager.
266
240
<b>NON-SHARED FILES</b>
267
241
<b><a href="postconf.5.html#config_directory">config_directory</a> (see 'postconf -d' output)</b>
268
The default location of the Postfix <a href="postconf.5.html">main.cf</a> and
269
<a href="master.5.html">master.cf</a> configuration files.
242
The default location of the Postfix <a href="postconf.5.html">main.cf</a> and <a href="master.5.html">master.cf</a> con-
271
245
<b><a href="postconf.5.html#data_directory">data_directory</a> (see 'postconf -d' output)</b>
272
The directory with Postfix-writable data files (for
273
example: caches, pseudo-random numbers).
246
The directory with Postfix-writable data files (for example:
247
caches, pseudo-random numbers).
275
249
<b><a href="postconf.5.html#queue_directory">queue_directory</a> (see 'postconf -d' output)</b>
276
The location of the Postfix top-level queue direc-
250
The location of the Postfix top-level queue directory.
280
253
<a href="postfix.1.html">postfix(1)</a> Postfix control program