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