post-install revision 1.1.1.6 1 1.1 tron #!/bin/sh
2 1.1 tron # $NetBSD: post-install,v 1.1.1.6 2014/07/06 19:27:40 tron Exp $
3 1.1 tron #
4 1.1 tron
5 1.1 tron # To view the formatted manual page of this file, type:
6 1.1 tron # POSTFIXSOURCE/mantools/srctoman - post-install | nroff -man
7 1.1 tron
8 1.1 tron #++
9 1.1 tron # NAME
10 1.1 tron # post-install
11 1.1 tron # SUMMARY
12 1.1 tron # Postfix post-installation script
13 1.1 tron # SYNOPSIS
14 1.1 tron # postfix post-install [name=value] command ...
15 1.1 tron # DESCRIPTION
16 1.1 tron # The post-install script performs the finishing touch of a Postfix
17 1.1 tron # installation, after the executable programs and configuration
18 1.1 tron # files are installed. Usage is one of the following:
19 1.1 tron # .IP o
20 1.1 tron # While installing Postfix from source code on the local machine, the
21 1.1 tron # script is run by the postfix-install script to update selected file
22 1.1 tron # or directory permissions and to update Postfix configuration files.
23 1.1 tron # .IP o
24 1.1 tron # While installing Postfix from a pre-built package, the script is run
25 1.1 tron # by the package management procedure to set all file or directory
26 1.1 tron # permissions and to update Postfix configuration files.
27 1.1 tron # .IP o
28 1.1 tron # The script can be used to change installation parameter settings such
29 1.1 tron # as mail_owner or setgid_group after Postfix is already installed.
30 1.1 tron # .IP o
31 1.1 tron # The script can be used to upgrade configuration files and to upgrade
32 1.1 tron # file/directory permissions of a secondary Postfix instance.
33 1.1 tron # .IP o
34 1.1 tron # At Postfix start-up time, the script is run from "postfix check" to
35 1.1 tron # create missing queue directories.
36 1.1 tron # .PP
37 1.1 tron # The post-install script is controlled by installation parameters.
38 1.1 tron # Specific parameters are described at the end of this document.
39 1.1 tron # All installation parameters must be specified ahead of time via
40 1.1 tron # one of the methods described below.
41 1.1 tron #
42 1.1 tron # Arguments
43 1.1 tron # .IP create-missing
44 1.1 tron # Create missing queue directories with ownerships and permissions
45 1.1.1.6 tron # according to the contents of $daemon_directory/postfix-files
46 1.1.1.6 tron # and optionally in $daemon_directory/postfix-files.d/*, using
47 1.1.1.6 tron # the mail_owner and setgid_group parameter settings from the
48 1.1.1.6 tron # command line, process environment or from the installed
49 1.1.1.6 tron # main.cf file.
50 1.1 tron #
51 1.1 tron # This is required at Postfix start-up time.
52 1.1 tron # .IP set-permissions
53 1.1 tron # Set all file/directory ownerships and permissions according to the
54 1.1.1.6 tron # contents of $daemon_directory/postfix-files and optionally
55 1.1.1.6 tron # in $daemon_directory/postfix-files.d/*, using the mail_owner
56 1.1.1.6 tron # and setgid_group parameter settings from the command line,
57 1.1.1.6 tron # process environment or from the installed main.cf file.
58 1.1.1.6 tron # Implies create-missing.
59 1.1 tron #
60 1.1 tron # This is required when installing Postfix from a pre-built package,
61 1.1 tron # or when changing the mail_owner or setgid_group installation parameter
62 1.1 tron # settings after Postfix is already installed.
63 1.1 tron # .IP upgrade-permissions
64 1.1 tron # Update ownership and permission of existing files/directories as
65 1.1.1.6 tron # specified in $daemon_directory/postfix-files and optionally
66 1.1.1.6 tron # in $daemon_directory/postfix-files.d/*, using the mail_owner
67 1.1.1.6 tron # and setgid_group parameter settings from the command line,
68 1.1.1.6 tron # process environment or from the installed main.cf file.
69 1.1.1.6 tron # Implies create-missing.
70 1.1 tron #
71 1.1 tron # This is required when upgrading an existing Postfix instance.
72 1.1 tron # .IP upgrade-configuration
73 1.1 tron # Edit the installed main.cf and master.cf files, in order to account
74 1.1 tron # for missing services and to fix deprecated parameter settings.
75 1.1 tron #
76 1.1 tron # This is required when upgrading an existing Postfix instance.
77 1.1 tron # .IP upgrade-source
78 1.1 tron # Short-hand for: upgrade-permissions upgrade-configuration.
79 1.1 tron #
80 1.1 tron # This is recommended when upgrading Postfix from source code.
81 1.1 tron # .IP upgrade-package
82 1.1 tron # Short-hand for: set-permissions upgrade-configuration.
83 1.1 tron #
84 1.1 tron # This is recommended when upgrading Postfix from a pre-built package.
85 1.1 tron # .IP first-install-reminder
86 1.1 tron # Remind the user that they still need to configure main.cf and the
87 1.1 tron # aliases file, and that newaliases still needs to be run.
88 1.1 tron #
89 1.1 tron # This is recommended when Postfix is installed for the first time.
90 1.1 tron # MULTIPLE POSTFIX INSTANCES
91 1.1 tron # .ad
92 1.1 tron # .fi
93 1.1 tron # Multiple Postfix instances on the same machine can share command and
94 1.1 tron # daemon program files but must have separate configuration and queue
95 1.1 tron # directories.
96 1.1 tron #
97 1.1 tron # To create a secondary Postfix installation on the same machine,
98 1.1 tron # copy the configuration files from the primary Postfix instance to
99 1.1 tron # a secondary configuration directory and execute:
100 1.1 tron #
101 1.1 tron # postfix post-install config_directory=secondary-config-directory \e
102 1.1 tron # .in +4
103 1.1 tron # queue_directory=secondary-queue-directory \e
104 1.1 tron # .br
105 1.1 tron # create-missing
106 1.1 tron # .PP
107 1.1 tron # This creates secondary Postfix queue directories, sets their access
108 1.1 tron # permissions, and saves the specified installation parameters to the
109 1.1 tron # secondary main.cf file.
110 1.1 tron #
111 1.1 tron # Be sure to list the secondary configuration directory in the
112 1.1 tron # alternate_config_directories parameter in the primary main.cf file.
113 1.1 tron #
114 1.1 tron # To upgrade a secondary Postfix installation on the same machine,
115 1.1 tron # execute:
116 1.1 tron #
117 1.1 tron # postfix post-install config_directory=secondary-config-directory \e
118 1.1 tron # .in +4
119 1.1 tron # upgrade-permissions upgrade-configuration
120 1.1 tron # INSTALLATION PARAMETER INPUT METHODS
121 1.1 tron # .ad
122 1.1 tron # .fi
123 1.1 tron # Parameter settings can be specified through a variety of
124 1.1 tron # mechanisms. In order of decreasing precedence these are:
125 1.1 tron # .IP "command line"
126 1.1 tron # Parameter settings can be given as name=value arguments on
127 1.1 tron # the post-install command line. These have the highest precedence.
128 1.1 tron # Settings that override the installed main.cf file are saved.
129 1.1 tron # .IP "process environment"
130 1.1 tron # Parameter settings can be given as name=value environment
131 1.1 tron # variables.
132 1.1 tron # Settings that override the installed main.cf file are saved.
133 1.1 tron # .IP "installed configuration files"
134 1.1 tron # If a parameter is not specified via the command line or via the
135 1.1 tron # process environment, post-install will attempt to extract its
136 1.1 tron # value from the already installed Postfix main.cf configuration file.
137 1.1 tron # These settings have the lowest precedence.
138 1.1 tron # INSTALLATION PARAMETER DESCRIPTION
139 1.1 tron # .ad
140 1.1 tron # .fi
141 1.1 tron # The description of installation parameters is as follows:
142 1.1 tron # .IP config_directory
143 1.1 tron # The directory for Postfix configuration files.
144 1.1 tron # .IP daemon_directory
145 1.1 tron # The directory for Postfix daemon programs. This directory
146 1.1 tron # should not be in the command search path of any users.
147 1.1 tron # .IP command_directory
148 1.1 tron # The directory for Postfix administrative commands. This
149 1.1 tron # directory should be in the command search path of adminstrative users.
150 1.1 tron # .IP queue_directory
151 1.1 tron # The directory for Postfix queues.
152 1.1 tron # .IP data_directory
153 1.1 tron # The directory for Postfix writable data files (caches, etc.).
154 1.1 tron # .IP sendmail_path
155 1.1 tron # The full pathname for the Postfix sendmail command.
156 1.1 tron # This is the Sendmail-compatible mail posting interface.
157 1.1 tron # .IP newaliases_path
158 1.1 tron # The full pathname for the Postfix newaliases command.
159 1.1 tron # This is the Sendmail-compatible command to build alias databases
160 1.1 tron # for the Postfix local delivery agent.
161 1.1 tron # .IP mailq_path
162 1.1 tron # The full pathname for the Postfix mailq command.
163 1.1 tron # This is the Sendmail-compatible command to list the mail queue.
164 1.1 tron # .IP mail_owner
165 1.1 tron # The owner of the Postfix queue. Its numerical user ID and group ID
166 1.1 tron # must not be used by any other accounts on the system.
167 1.1 tron # .IP setgid_group
168 1.1 tron # The group for mail submission and for queue management commands.
169 1.1 tron # Its numerical group ID must not be used by any other accounts on the
170 1.1 tron # system, not even by the mail_owner account.
171 1.1 tron # .IP html_directory
172 1.1 tron # The directory for the Postfix HTML files.
173 1.1 tron # .IP manpage_directory
174 1.1 tron # The directory for the Postfix on-line manual pages.
175 1.1 tron # .IP sample_directory
176 1.1 tron # The directory for the Postfix sample configuration files.
177 1.1 tron # This feature is obsolete as of Postfix 2.1.
178 1.1 tron # .IP readme_directory
179 1.1 tron # The directory for the Postfix README files.
180 1.1 tron # SEE ALSO
181 1.1 tron # postfix-install(1) Postfix primary installation script.
182 1.1 tron # FILES
183 1.1 tron # $config_directory/main.cf, Postfix installation parameters.
184 1.1 tron # $daemon_directory/postfix-files, installation control file.
185 1.1.1.6 tron # $daemon_directory/postfix-files.d/*, optional control files.
186 1.1 tron # $config_directory/install.cf, obsolete configuration file.
187 1.1 tron # LICENSE
188 1.1 tron # .ad
189 1.1 tron # .fi
190 1.1 tron # The Secure Mailer license must be distributed with this software.
191 1.1 tron # AUTHOR(S)
192 1.1 tron # Wietse Venema
193 1.1 tron # IBM T.J. Watson Research
194 1.1 tron # P.O. Box 704
195 1.1 tron # Yorktown Heights, NY 10598, USA
196 1.1 tron #--
197 1.1 tron
198 1.1 tron umask 022
199 1.1 tron
200 1.1 tron PATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd
201 1.1 tron SHELL=/bin/sh
202 1.1 tron IFS="
203 1.1 tron "
204 1.1 tron BACKUP_IFS="$IFS"
205 1.1 tron debug=:
206 1.1 tron #debug=echo
207 1.1 tron MOST_PARAMETERS="command_directory daemon_directory data_directory
208 1.1 tron html_directory mail_owner mailq_path manpage_directory
209 1.1 tron newaliases_path queue_directory readme_directory sample_directory
210 1.1 tron sendmail_path setgid_group"
211 1.1 tron NON_SHARED="config_directory queue_directory data_directory"
212 1.1 tron
213 1.1 tron USAGE="Usage: $0 [name=value] command
214 1.1 tron create-missing Create missing queue directories.
215 1.1 tron upgrade-source When installing or upgrading from source code.
216 1.1 tron upgrade-package When installing or upgrading from pre-built package.
217 1.1 tron first-install-reminder Remind of mandatory first-time configuration steps.
218 1.1 tron name=value Specify an installation parameter".
219 1.1 tron
220 1.1 tron # Process command-line options and parameter settings. Work around
221 1.1 tron # brain damaged shells. "IFS=value command" should not make the
222 1.1 tron # IFS=value setting permanent. But some broken standard allows it.
223 1.1 tron
224 1.1 tron create=; set_perms=; upgrade_perms=; upgrade_conf=; first_install_reminder=
225 1.1 tron obsolete=; keep_list=;
226 1.1 tron
227 1.1 tron for arg
228 1.1 tron do
229 1.1 tron case $arg in
230 1.1 tron *=*) IFS= eval $arg; IFS="$BACKUP_IFS";;
231 1.1 tron create-missing) create=1;;
232 1.1 tron set-perm*) create=1; set_perms=1;;
233 1.1 tron upgrade-perm*) create=1; upgrade_perms=1;;
234 1.1 tron upgrade-conf*) upgrade_conf=1;;
235 1.1 tron upgrade-source) create=1; upgrade_conf=1; upgrade_perms=1;;
236 1.1 tron upgrade-package) create=1; upgrade_conf=1; set_perms=1;;
237 1.1 tron first-install*) first_install_reminder=1;;
238 1.1 tron *) echo "$0: Error: $USAGE" 1>&2; exit 1;;
239 1.1 tron esac
240 1.1 tron shift
241 1.1 tron done
242 1.1 tron
243 1.1 tron # Sanity checks.
244 1.1 tron
245 1.1 tron test -n "$create$upgrade_conf$first_install_reminder" || {
246 1.1 tron echo "$0: Error: $USAGE" 1>&2
247 1.1 tron exit 1
248 1.1 tron }
249 1.1 tron
250 1.1 tron # Bootstrapping problem.
251 1.1 tron
252 1.1 tron if [ -n "$command_directory" ]
253 1.1 tron then
254 1.1 tron POSTCONF="$command_directory/postconf"
255 1.1 tron else
256 1.1 tron POSTCONF="postconf"
257 1.1 tron fi
258 1.1 tron
259 1.1 tron $POSTCONF -d mail_version >/dev/null 2>/dev/null || {
260 1.1 tron echo $0: Error: no $POSTCONF command found. 1>&2
261 1.1 tron echo Re-run this command as $0 command_directory=/some/where. 1>&2
262 1.1 tron exit 1
263 1.1 tron }
264 1.1 tron
265 1.1 tron # Also used to require license etc. files only in the default instance.
266 1.1 tron
267 1.1 tron def_config_directory=`$POSTCONF -d -h config_directory` || exit 1
268 1.1 tron test -n "$config_directory" ||
269 1.1 tron config_directory="$def_config_directory"
270 1.1 tron
271 1.1 tron test -d "$config_directory" || {
272 1.1 tron echo $0: Error: $config_directory is not a directory. 1>&2
273 1.1 tron exit 1
274 1.1 tron }
275 1.1 tron
276 1.1 tron # If this is a secondary instance, don't touch shared files.
277 1.1 tron # XXX Solaris does not have "test -e".
278 1.1 tron
279 1.1 tron instances=`test ! -f $def_config_directory/main.cf ||
280 1.1 tron $POSTCONF -c $def_config_directory -h multi_instance_directories |
281 1.1 tron sed 's/,/ /'` || exit 1
282 1.1 tron
283 1.1 tron update_shared_files=1
284 1.1 tron for name in $instances
285 1.1 tron do
286 1.1 tron case "$name" in
287 1.1 tron "$def_config_directory") ;;
288 1.1 tron "$config_directory") update_shared_files=; break;;
289 1.1 tron esac
290 1.1 tron done
291 1.1 tron
292 1.1 tron test -f $daemon_directory/postfix-files || {
293 1.1 tron echo $0: Error: $daemon_directory/postfix-files is not a file. 1>&2
294 1.1 tron exit 1
295 1.1 tron }
296 1.1 tron
297 1.1 tron # SunOS5 fmt(1) truncates lines > 1000 characters.
298 1.1 tron
299 1.1 tron fake_fmt() {
300 1.1 tron sed '
301 1.1 tron :top
302 1.1 tron /^\( *\)\([^ ][^ ]*\) */{
303 1.1 tron s//\1\2\
304 1.1 tron \1/
305 1.1 tron P
306 1.1 tron D
307 1.1 tron b top
308 1.1 tron }
309 1.1 tron ' | fmt
310 1.1 tron }
311 1.1 tron
312 1.1 tron case `uname -s` in
313 1.1 tron HP-UX*) FMT=cat;;
314 1.1 tron SunOS*) FMT=fake_fmt;;
315 1.1 tron *) FMT=fmt;;
316 1.1 tron esac
317 1.1 tron
318 1.1 tron # If a parameter is not set via the command line or environment,
319 1.1 tron # try to use settings from installed configuration files.
320 1.1 tron
321 1.1 tron # Extract parameter settings from the obsolete install.cf file, as
322 1.1 tron # a transitional aid.
323 1.1 tron
324 1.1 tron grep setgid_group $config_directory/main.cf >/dev/null 2>&1 || {
325 1.1 tron test -f $config_directory/install.cf && {
326 1.1 tron for name in sendmail_path newaliases_path mailq_path setgid manpages
327 1.1 tron do
328 1.1 tron eval junk=\$$name
329 1.1 tron case "$junk" in
330 1.1 tron "") eval unset $name;;
331 1.1 tron esac
332 1.1 tron eval : \${$name="\`. $config_directory/install.cf; echo \$$name\`"} \
333 1.1 tron || exit 1
334 1.1 tron done
335 1.1 tron : ${setgid_group=$setgid}
336 1.1 tron : ${manpage_directory=$manpages}
337 1.1 tron }
338 1.1 tron }
339 1.1 tron
340 1.1 tron # Extract parameter settings from the installed main.cf file.
341 1.1 tron
342 1.1 tron test -f $config_directory/main.cf && {
343 1.1 tron for name in $MOST_PARAMETERS
344 1.1 tron do
345 1.1 tron eval junk=\$$name
346 1.1 tron case "$junk" in
347 1.1 tron "") eval unset $name;;
348 1.1 tron esac
349 1.1 tron eval : \${$name=\`$POSTCONF -c $config_directory -h $name\`} || exit 1
350 1.1 tron done
351 1.1 tron }
352 1.1 tron
353 1.1 tron # Sanity checks
354 1.1 tron
355 1.1 tron case $manpage_directory in
356 1.1 tron no) echo $0: Error: manpage_directory no longer accepts \"no\" values. 1>&2
357 1.1 tron echo Try again with \"$0 manpage_directory=/pathname ...\". 1>&2; exit 1;;
358 1.1 tron esac
359 1.1 tron
360 1.1 tron case $setgid_group in
361 1.1 tron no) echo $0: Error: setgid_group no longer accepts \"no\" values. 1>&2
362 1.1 tron echo Try again with \"$0 setgid_group=groupname ...\" 1>&2; exit 1;;
363 1.1 tron esac
364 1.1 tron
365 1.1 tron for path in "$daemon_directory" "$command_directory" "$queue_directory" \
366 1.1 tron "$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory"
367 1.1 tron do
368 1.1 tron case "$path" in
369 1.1 tron /*) ;;
370 1.1 tron *) echo $0: Error: \"$path\" should be an absolute path name. 1>&2; exit 1;;
371 1.1 tron esac
372 1.1 tron done
373 1.1 tron
374 1.1 tron for path in "$html_directory" "$readme_directory"
375 1.1 tron do
376 1.1 tron case "$path" in
377 1.1 tron /*) ;;
378 1.1 tron no) ;;
379 1.1 tron *) echo $0: Error: \"$path\" should be \"no\" or an absolute path name. 1>&2; exit 1;;
380 1.1 tron esac
381 1.1 tron done
382 1.1 tron
383 1.1 tron # Find out what parameters were not specified via command line,
384 1.1 tron # via environment, or via installed configuration files.
385 1.1 tron
386 1.1 tron missing=
387 1.1 tron for name in $MOST_PARAMETERS
388 1.1 tron do
389 1.1 tron eval test -n \"\$$name\" || missing="$missing $name"
390 1.1 tron done
391 1.1 tron
392 1.1 tron # All parameters must be specified at this point.
393 1.1 tron
394 1.1 tron test -n "$non_interactive" -a -n "$missing" && {
395 1.1 tron cat <<EOF | ${FMT} 1>&2
396 1.1 tron $0: Error: some required installation parameters are not defined.
397 1.1 tron
398 1.1 tron - Either the parameters need to be given in the $config_directory/main.cf
399 1.1 tron file from a recent Postfix installation,
400 1.1 tron
401 1.1 tron - Or the parameters need to be specified through the process
402 1.1 tron environment.
403 1.1 tron
404 1.1 tron - Or the parameters need to be specified as name=value arguments
405 1.1 tron on the $0 command line,
406 1.1 tron
407 1.1 tron The following parameters were missing:
408 1.1 tron
409 1.1 tron $missing
410 1.1 tron
411 1.1 tron EOF
412 1.1 tron exit 1
413 1.1 tron }
414 1.1 tron
415 1.1 tron POSTCONF="$command_directory/postconf"
416 1.1 tron
417 1.1 tron # Save settings, allowing command line/environment override.
418 1.1 tron
419 1.1 tron override=
420 1.1 tron for name in $MOST_PARAMETERS
421 1.1 tron do
422 1.1 tron eval test \"\$$name\" = \"`$POSTCONF -c $config_directory -h $name`\" || {
423 1.1 tron override=1
424 1.1 tron break
425 1.1 tron }
426 1.1 tron done
427 1.1 tron
428 1.1 tron test -n "$override" && {
429 1.1 tron $POSTCONF -c $config_directory -e \
430 1.1 tron "daemon_directory = $daemon_directory" \
431 1.1 tron "command_directory = $command_directory" \
432 1.1 tron "queue_directory = $queue_directory" \
433 1.1 tron "data_directory = $data_directory" \
434 1.1 tron "mail_owner = $mail_owner" \
435 1.1 tron "setgid_group = $setgid_group" \
436 1.1 tron "sendmail_path = $sendmail_path" \
437 1.1 tron "mailq_path = $mailq_path" \
438 1.1 tron "newaliases_path = $newaliases_path" \
439 1.1 tron "html_directory = $html_directory" \
440 1.1 tron "manpage_directory = $manpage_directory" \
441 1.1 tron "sample_directory = $sample_directory" \
442 1.1 tron "readme_directory = $readme_directory" \
443 1.1 tron || exit 1
444 1.1 tron }
445 1.1 tron
446 1.1 tron # Use file/directory status information in $daemon_directory/postfix-files.
447 1.1 tron
448 1.1 tron test -n "$create" && {
449 1.1.1.6 tron postfix_files_d=$daemon_directory/postfix-files.d
450 1.1.1.6 tron for postfix_file in $daemon_directory/postfix-files \
451 1.1.1.6 tron `test -d $postfix_files_d && { find $postfix_files_d -type f | sort; }`
452 1.1 tron do
453 1.1.1.6 tron exec <$postfix_file || exit 1
454 1.1.1.6 tron while IFS=: read path type owner group mode flags junk
455 1.1 tron do
456 1.1.1.6 tron IFS="$BACKUP_IFS"
457 1.1.1.6 tron set_permission=
458 1.1.1.6 tron # Skip comments. Skip shared files, if updating a secondary instance.
459 1.1.1.6 tron case $path in
460 1.1.1.6 tron [$]*) case "$update_shared_files" in
461 1.1.1.6 tron 1) $debug keep non-shared or shared $path;;
462 1.1.1.6 tron *) non_shared=
463 1.1.1.6 tron for name in $NON_SHARED
464 1.1.1.6 tron do
465 1.1.1.6 tron case $path in
466 1.1.1.6 tron "\$$name"*) non_shared=1; break;;
467 1.1.1.6 tron esac
468 1.1.1.6 tron done
469 1.1.1.6 tron case "$non_shared" in
470 1.1.1.6 tron 1) $debug keep non-shared $path;;
471 1.1.1.6 tron *) $debug skip shared $path; continue;;
472 1.1.1.6 tron esac;;
473 1.1.1.6 tron esac;;
474 1.1.1.6 tron *) continue;;
475 1.1 tron esac
476 1.1.1.6 tron # Skip hard links and symbolic links.
477 1.1.1.6 tron case $type in
478 1.1.1.6 tron [hl]) continue;;
479 1.1.1.6 tron [df]) ;;
480 1.1.1.6 tron *) echo unknown type $type for $path in $postfix_file 1>&2; exit 1;;
481 1.1.1.6 tron esac
482 1.1.1.6 tron # Expand $name, and canonicalize null fields.
483 1.1.1.6 tron for name in path owner group flags
484 1.1.1.6 tron do
485 1.1.1.6 tron eval junk=\${$name}
486 1.1.1.6 tron case $junk in
487 1.1.1.6 tron [$]*) eval $name=$junk;;
488 1.1.1.6 tron -) eval $name=;;
489 1.1.1.6 tron *) ;;
490 1.1.1.6 tron esac
491 1.1.1.6 tron done
492 1.1.1.6 tron # Skip uninstalled files.
493 1.1.1.6 tron case $path in
494 1.1.1.6 tron no|no/*) continue;;
495 1.1.1.6 tron esac
496 1.1.1.6 tron # Pick up the flags.
497 1.1.1.6 tron case $flags in *u*) upgrade_flag=1;; *) upgrade_flag=;; esac
498 1.1.1.6 tron case $flags in *c*) create_flag=1;; *) create_flag=;; esac
499 1.1.1.6 tron case $flags in *r*) recursive="-R";; *) recursive=;; esac
500 1.1.1.6 tron case $flags in *o*) obsolete_flag=1;; *) obsolete_flag=;; esac
501 1.1.1.6 tron case $flags in *[1i]*) test ! -r "$path" -a "$config_directory" != \
502 1.1.1.6 tron "$def_config_directory" && continue;; esac
503 1.1.1.6 tron # Flag obsolete objects. XXX Solaris 2..9 does not have "test -e".
504 1.1.1.6 tron if [ -n "$obsolete_flag" ]
505 1.1 tron then
506 1.1.1.6 tron test -r $path -a "$type" != "d" && obsolete="$obsolete $path"
507 1.1.1.6 tron continue;
508 1.1 tron else
509 1.1.1.6 tron keep_list="$keep_list $path"
510 1.1.1.6 tron fi
511 1.1.1.6 tron # Create missing directories with proper owner/group/mode settings.
512 1.1.1.6 tron if [ -n "$create" -a "$type" = "d" -a -n "$create_flag" -a ! -d "$path" ]
513 1.1.1.6 tron then
514 1.1.1.6 tron mkdir $path || exit 1
515 1.1.1.6 tron set_permission=1
516 1.1.1.6 tron # Update all owner/group/mode settings.
517 1.1.1.6 tron elif [ -n "$set_perms" ]
518 1.1.1.6 tron then
519 1.1.1.6 tron set_permission=1
520 1.1.1.6 tron # Update obsolete owner/group/mode settings.
521 1.1.1.6 tron elif [ -n "$upgrade_perms" -a -n "$upgrade_flag" ]
522 1.1.1.6 tron then
523 1.1.1.6 tron set_permission=1
524 1.1.1.6 tron fi
525 1.1.1.6 tron test -n "$set_permission" && {
526 1.1.1.6 tron chown $recursive $owner $path || exit 1
527 1.1.1.6 tron test -z "$group" || chgrp $recursive $group $path || exit 1
528 1.1.1.6 tron # Don't "chmod -R"; queue file status is encoded in mode bits.
529 1.1.1.6 tron if [ "$type" = "d" -a -n "$recursive" ]
530 1.1.1.6 tron then
531 1.1.1.6 tron find $path -type d -exec chmod $mode "{}" ";"
532 1.1.1.6 tron else
533 1.1.1.6 tron chmod $mode $path
534 1.1.1.6 tron fi || exit 1
535 1.1.1.6 tron }
536 1.1.1.6 tron done
537 1.1.1.6 tron IFS="$BACKUP_IFS"
538 1.1 tron done
539 1.1 tron }
540 1.1 tron
541 1.1 tron # Upgrade existing Postfix configuration files if necessary.
542 1.1 tron
543 1.1 tron test -n "$upgrade_conf" && {
544 1.1 tron
545 1.1 tron # Postfix 2.0.
546 1.1 tron # Add missing relay service to master.cf.
547 1.1 tron
548 1.1 tron grep '^relay' $config_directory/master.cf >/dev/null || {
549 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for relay service
550 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
551 1.1 tron relay unix - - n - - smtp
552 1.1 tron EOF
553 1.1 tron }
554 1.1 tron
555 1.1 tron # Postfix 1.1.
556 1.1 tron # Add missing flush service to master.cf.
557 1.1 tron
558 1.1 tron grep '^flush.*flush' $config_directory/master.cf >/dev/null || {
559 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for flush service
560 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
561 1.1 tron flush unix - - n 1000? 0 flush
562 1.1 tron EOF
563 1.1 tron }
564 1.1 tron
565 1.1 tron # Postfix 2.1.
566 1.1 tron # Add missing trace service to master.cf.
567 1.1 tron
568 1.1 tron grep 'trace.*bounce' $config_directory/master.cf >/dev/null || {
569 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for trace service
570 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
571 1.1 tron trace unix - - n - 0 bounce
572 1.1 tron EOF
573 1.1 tron }
574 1.1 tron
575 1.1 tron # Postfix 2.1.
576 1.1 tron # Add missing verify service to master.cf.
577 1.1 tron
578 1.1 tron grep '^verify.*verify' $config_directory/master.cf >/dev/null || {
579 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for verify service
580 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
581 1.1 tron verify unix - - n - 1 verify
582 1.1 tron EOF
583 1.1 tron }
584 1.1 tron
585 1.1 tron # Postfix 2.1.
586 1.1 tron # Fix verify service process limit.
587 1.1 tron
588 1.1 tron grep '^verify.*[ ]0[ ]*verify' \
589 1.1 tron $config_directory/master.cf >/dev/null && {
590 1.1 tron echo Editing $config_directory/master.cf, setting verify process limit to 1
591 1.1 tron ed $config_directory/master.cf <<EOF || exit 1
592 1.1 tron /^verify.*[ ]0[ ]*verify/
593 1.1 tron s/\([ ]\)0\([ ]\)/\11\2/
594 1.1 tron p
595 1.1 tron w
596 1.1 tron q
597 1.1 tron EOF
598 1.1 tron }
599 1.1 tron
600 1.1 tron # Postfix 1.1.
601 1.1 tron # Change privileged pickup service into unprivileged.
602 1.1 tron
603 1.1 tron grep "^pickup[ ]*fifo[ ]*n[ ]*n" \
604 1.1 tron $config_directory/master.cf >/dev/null && {
605 1.1 tron echo Editing $config_directory/master.cf, making the pickup service unprivileged
606 1.1 tron ed $config_directory/master.cf <<EOF || exit 1
607 1.1 tron /^pickup[ ]*fifo[ ]*n[ ]*n/
608 1.1 tron s/\(n[ ]*\)n/\1-/
609 1.1 tron p
610 1.1 tron w
611 1.1 tron q
612 1.1 tron EOF
613 1.1 tron }
614 1.1 tron
615 1.1 tron # Postfix 1.1.
616 1.1 tron # Change private cleanup and flush services into public.
617 1.1 tron
618 1.1 tron for name in cleanup flush
619 1.1 tron do
620 1.1 tron grep "^$name[ ]*unix[ ]*[-y]" \
621 1.1 tron $config_directory/master.cf >/dev/null && {
622 1.1 tron echo Editing $config_directory/master.cf, making the $name service public
623 1.1 tron ed $config_directory/master.cf <<EOF || exit 1
624 1.1 tron /^$name[ ]*unix[ ]*[-y]/
625 1.1 tron s/[-y]/n/
626 1.1 tron p
627 1.1 tron w
628 1.1 tron q
629 1.1 tron EOF
630 1.1 tron }
631 1.1 tron done
632 1.1 tron
633 1.1 tron # Postfix 2.2.
634 1.1 tron # File systems have improved since Postfix came out, and all we
635 1.1 tron # require now is that defer and deferred are hashed because those
636 1.1 tron # can contain lots of files.
637 1.1 tron
638 1.1 tron found=`$POSTCONF -c $config_directory -h hash_queue_names`
639 1.1 tron missing=
640 1.1 tron (echo "$found" | grep defer >/dev/null) || missing="$missing defer"
641 1.1 tron (echo "$found" | grep deferred>/dev/null)|| missing="$missing deferred"
642 1.1 tron test -n "$missing" && {
643 1.1 tron echo fixing main.cf hash_queue_names for missing $missing
644 1.1 tron $POSTCONF -c $config_directory -e hash_queue_names="$found$missing" ||
645 1.1 tron exit 1
646 1.1 tron }
647 1.1 tron
648 1.1 tron # Turn on safety nets for new features that could bounce mail that
649 1.1 tron # would be accepted by a previous Postfix version.
650 1.1 tron
651 1.1 tron # [The "unknown_local_recipient_reject_code = 450" safety net,
652 1.1 tron # introduced with Postfix 2.0 and deleted after Postfix 2.3.]
653 1.1 tron
654 1.1 tron # Postfix 2.0.
655 1.1 tron # Add missing proxymap service to master.cf.
656 1.1 tron
657 1.1 tron grep '^proxymap.*proxymap' $config_directory/master.cf >/dev/null || {
658 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for proxymap service
659 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
660 1.1 tron proxymap unix - - n - - proxymap
661 1.1 tron EOF
662 1.1 tron }
663 1.1 tron
664 1.1 tron # Postfix 2.1.
665 1.1 tron # Add missing anvil service to master.cf.
666 1.1 tron
667 1.1 tron grep '^anvil.*anvil' $config_directory/master.cf >/dev/null || {
668 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for anvil service
669 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
670 1.1 tron anvil unix - - n - 1 anvil
671 1.1 tron EOF
672 1.1 tron }
673 1.1 tron
674 1.1 tron # Postfix 2.2.
675 1.1 tron # Add missing scache service to master.cf.
676 1.1 tron
677 1.1 tron grep '^scache.*scache' $config_directory/master.cf >/dev/null || {
678 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for scache service
679 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
680 1.1 tron scache unix - - n - 1 scache
681 1.1 tron EOF
682 1.1 tron }
683 1.1 tron
684 1.1 tron # Postfix 2.2.
685 1.1 tron # Add missing discard service to master.cf.
686 1.1 tron
687 1.1 tron grep '^discard.*discard' $config_directory/master.cf >/dev/null || {
688 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for discard service
689 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
690 1.1 tron discard unix - - n - - discard
691 1.1 tron EOF
692 1.1 tron }
693 1.1 tron
694 1.1 tron # Postfix 2.2.
695 1.1 tron # Update the tlsmgr fifo->unix service.
696 1.1 tron
697 1.1 tron grep "^tlsmgr[ ]*fifo[ ]" \
698 1.1 tron $config_directory/master.cf >/dev/null && {
699 1.1 tron echo Editing $config_directory/master.cf, updating the tlsmgr from fifo to unix service
700 1.1 tron ed $config_directory/master.cf <<EOF || exit 1
701 1.1 tron /^tlsmgr[ ]*fifo[ ]/
702 1.1 tron s/fifo/unix/
703 1.1 tron s/[0-9][0-9]*/&?/
704 1.1 tron p
705 1.1 tron w
706 1.1 tron q
707 1.1 tron EOF
708 1.1 tron }
709 1.1 tron
710 1.1 tron # Postfix 2.2.
711 1.1 tron # Add missing tlsmgr service to master.cf.
712 1.1 tron
713 1.1 tron grep '^tlsmgr.*tlsmgr' $config_directory/master.cf >/dev/null || {
714 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for tlsmgr service
715 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
716 1.1 tron tlsmgr unix - - n 1000? 1 tlsmgr
717 1.1 tron EOF
718 1.1 tron }
719 1.1 tron
720 1.1 tron # Postfix 2.2.
721 1.1 tron # Add missing retry service to master.cf.
722 1.1 tron
723 1.1 tron grep '^retry.*error' $config_directory/master.cf >/dev/null || {
724 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for retry service
725 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
726 1.1 tron retry unix - - n - - error
727 1.1 tron EOF
728 1.1 tron }
729 1.1 tron
730 1.1 tron # Postfix 2.5.
731 1.1 tron # Add missing proxywrite service to master.cf.
732 1.1 tron
733 1.1 tron grep '^proxywrite.*proxymap' $config_directory/master.cf >/dev/null || {
734 1.1 tron echo Editing $config_directory/master.cf, adding missing entry for proxywrite service
735 1.1 tron cat >>$config_directory/master.cf <<EOF || exit 1
736 1.1 tron proxywrite unix - - n - 1 proxymap
737 1.1 tron EOF
738 1.1 tron }
739 1.1 tron
740 1.1 tron # Postfix 2.5.
741 1.1 tron # Fix a typo in the default master.cf proxywrite entry.
742 1.1 tron
743 1.1 tron grep '^proxywrite.*-[ ]*proxymap' $config_directory/master.cf >/dev/null && {
744 1.1 tron echo Editing $config_directory/master.cf, setting proxywrite process limit to 1
745 1.1 tron ed $config_directory/master.cf <<EOF || exit 1
746 1.1 tron /^proxywrite.*-[ ]*proxymap/
747 1.1 tron s/-\([ ]*proxymap\)/1\1/
748 1.1 tron p
749 1.1 tron w
750 1.1 tron q
751 1.1 tron EOF
752 1.1 tron }
753 1.1 tron
754 1.1.1.2 tron # Postfix 2.8.
755 1.1.1.2 tron # Add missing postscreen service to master.cf.
756 1.1.1.2 tron
757 1.1.1.2 tron grep '^#*smtp.*postscreen' $config_directory/master.cf >/dev/null || {
758 1.1.1.2 tron echo Editing $config_directory/master.cf, adding missing entry for postscreen TCP service
759 1.1.1.2 tron cat >>$config_directory/master.cf <<EOF || exit 1
760 1.1.1.2 tron #smtp inet n - n - 1 postscreen
761 1.1.1.2 tron EOF
762 1.1.1.2 tron }
763 1.1.1.2 tron
764 1.1.1.2 tron # Postfix 2.8.
765 1.1.1.2 tron # Add missing smtpd (unix-domain) service to master.cf.
766 1.1.1.2 tron
767 1.1.1.2 tron grep '^#*smtpd.*smtpd' $config_directory/master.cf >/dev/null || {
768 1.1.1.2 tron echo Editing $config_directory/master.cf, adding missing entry for smtpd unix-domain service
769 1.1.1.2 tron cat >>$config_directory/master.cf <<EOF || exit 1
770 1.1.1.2 tron #smtpd pass - - n - - smtpd
771 1.1.1.2 tron EOF
772 1.1.1.2 tron }
773 1.1.1.2 tron
774 1.1.1.2 tron # Postfix 2.8.
775 1.1.1.2 tron # Add temporary dnsblog (unix-domain) service to master.cf.
776 1.1.1.2 tron
777 1.1.1.2 tron grep '^#*dnsblog.*dnsblog' $config_directory/master.cf >/dev/null || {
778 1.1.1.2 tron echo Editing $config_directory/master.cf, adding missing entry for dnsblog unix-domain service
779 1.1.1.2 tron cat >>$config_directory/master.cf <<EOF || exit 1
780 1.1.1.2 tron #dnsblog unix - - n - 0 dnsblog
781 1.1.1.2 tron EOF
782 1.1.1.2 tron }
783 1.1.1.2 tron
784 1.1.1.2 tron # Postfix 2.8.
785 1.1.1.2 tron # Add tlsproxy (unix-domain) service to master.cf.
786 1.1.1.2 tron
787 1.1.1.2 tron grep '^#*tlsproxy.*tlsproxy' $config_directory/master.cf >/dev/null || {
788 1.1.1.2 tron echo Editing $config_directory/master.cf, adding missing entry for tlsproxy unix-domain service
789 1.1.1.2 tron cat >>$config_directory/master.cf <<EOF || exit 1
790 1.1.1.2 tron #tlsproxy unix - - n - 0 tlsproxy
791 1.1.1.2 tron EOF
792 1.1.1.2 tron }
793 1.1.1.2 tron
794 1.1 tron # Report (but do not remove) obsolete files.
795 1.1 tron
796 1.1 tron test -n "$obsolete" && {
797 1.1 tron cat <<EOF | ${FMT}
798 1.1 tron
799 1.1 tron Note: the following files or directories still exist but are
800 1.1 tron no longer part of Postfix:
801 1.1 tron
802 1.1 tron $obsolete
803 1.1 tron
804 1.1 tron EOF
805 1.1 tron }
806 1.1 tron
807 1.1.1.3 tron # Postfix 2.9.
808 1.1.1.3 tron # Safety net for incompatible changes in IPv6 defaults.
809 1.1.1.3 tron # PLEASE DO NOT REMOVE THIS CODE. ITS PURPOSE IS TO AVOID AN
810 1.1.1.3 tron # UNEXPECTED DROP IN PERFORMANCE AFTER UPGRADING FROM POSTFIX
811 1.1.1.3 tron # BEFORE 2.9.
812 1.1.1.3 tron # This code assumes that the default is "inet_protocols = ipv4"
813 1.1.1.3 tron # when IPv6 support is not compiled in. See util/sys_defs.h.
814 1.1.1.3 tron
815 1.1.1.3 tron test "`$POSTCONF -dh inet_protocols`" = "ipv4" ||
816 1.1.1.4 tron test -n "`$POSTCONF -c $config_directory -n inet_protocols`" || {
817 1.1.1.4 tron cat <<EOF | ${FMT}
818 1.1.1.4 tron COMPATIBILITY: editing $config_directory/main.cf, setting
819 1.1.1.4 tron inet_protocols=ipv4. Specify inet_protocols explicitly if you
820 1.1.1.4 tron want to enable IPv6.
821 1.1.1.4 tron In a future release IPv6 will be enabled by default.
822 1.1.1.4 tron EOF
823 1.1.1.3 tron $POSTCONF -c $config_directory inet_protocols=ipv4 || exit 1
824 1.1.1.3 tron }
825 1.1.1.4 tron
826 1.1.1.4 tron # Disabled because unhelpful down-stream maintainers disable the safety net.
827 1.1.1.4 tron # # Postfix 2.10.
828 1.1.1.4 tron # # Safety net for incompatible changes due to the introduction
829 1.1.1.4 tron # # of the smtpd_relay_restrictions feature to separate the
830 1.1.1.4 tron # # mail relay policy from the spam blocking policy.
831 1.1.1.4 tron # # PLEASE DO NOT REMOVE THIS CODE. ITS PURPOSE IS TO PREVENT
832 1.1.1.4 tron # # INBOUND MAIL FROM UNEXPECTEDLY BOUNCING AFTER UPGRADING FROM
833 1.1.1.4 tron # # POSTFIX BEFORE 2.10.
834 1.1.1.4 tron # test -n "`$POSTCONF -c $config_directory -n smtpd_relay_restrictions`" || {
835 1.1.1.4 tron # cat <<EOF | ${FMT}
836 1.1.1.4 tron # COMPATIBILITY: editing $config_directory/main.cf, overriding
837 1.1.1.4 tron # smtpd_relay_restrictions to prevent inbound mail from
838 1.1.1.4 tron # unexpectedly bouncing.
839 1.1.1.4 tron # Specify an empty smtpd_relay_restrictions value to keep using
840 1.1.1.4 tron # smtpd_recipient_restrictions as before.
841 1.1.1.4 tron #EOF
842 1.1.1.4 tron # $POSTCONF -c $config_directory "smtpd_relay_restrictions = \
843 1.1.1.4 tron # permit_mynetworks permit_sasl_authenticated \
844 1.1.1.4 tron # defer_unauth_destination" || exit 1
845 1.1.1.4 tron # }
846 1.1 tron }
847 1.1 tron
848 1.1 tron # A reminder if this is the first time Postfix is being installed.
849 1.1 tron
850 1.1 tron test -n "$first_install_reminder" && {
851 1.1 tron
852 1.1 tron ALIASES=`$POSTCONF -c $config_directory -h alias_database | sed 's/^[^:]*://'`
853 1.1 tron NEWALIASES_PATH=`$POSTCONF -c $config_directory -h newaliases_path`
854 1.1 tron cat <<EOF | ${FMT}
855 1.1 tron
856 1.1 tron Warning: you still need to edit myorigin/mydestination/mynetworks
857 1.1 tron parameter settings in $config_directory/main.cf.
858 1.1 tron
859 1.1 tron See also http://www.postfix.org/STANDARD_CONFIGURATION_README.html
860 1.1 tron for information about dialup sites or about sites inside a
861 1.1 tron firewalled network.
862 1.1 tron
863 1.1 tron BTW: Check your $ALIASES file and be sure to set up aliases
864 1.1 tron that send mail for root and postmaster to a real person, then
865 1.1 tron run $NEWALIASES_PATH.
866 1.1 tron
867 1.1 tron EOF
868 1.1 tron
869 1.1 tron }
870 1.1 tron
871 1.1 tron exit 0
872