3
# To view the formatted manual page of this file, type:
4
# POSTFIXSOURCE/mantools/srctoman - postfix-install | nroff -man
10
# Postfix installation procedure
12
# sh postfix-install [options] [name=value] ...
14
# The postfix-install script is to be run from the top-level
15
# Postfix source directory. It implements the following operations:
17
# Install or upgrade Postfix from source code. This requires
18
# super-user privileges.
20
# Build a package that can be distributed to other systems, in order
21
# to install or upgrade Postfix elsewhere. This requires no super-user
22
# privileges. To complete the installation after unpacking the
23
# package, execute as super-user the post-install script in the Postfix
24
# configuration directory.
26
# The postfix-install script is controlled by installation parameters.
27
# Specific parameters are described at the end of this document.
29
# By default, postfix-install asks the user for installation
30
# parameter settings. Most settings are stored in the installed
31
# main.cf file. Stored settings are used as site-specific defaults
32
# when the postfix-install script is run later.
34
# The names of Postfix files and directories, as well as their
35
# ownerships and permissions, are stored in the postfix-files file
36
# in the Postfix configuration directory. This information is used
37
# by the post-install script (also in the configuration directory)
38
# for creating missing queue directories when Postfix is started,
39
# and for setting correct ownership and permissions when Postfix
40
# is installed from a pre-built package or from source code.
43
# .IP -non-interactive
44
# Do not ask the user for parameter settings. Installation parameters
45
# are specified via one of the non-interactive methods described
47
# INSTALLATION PARAMETER INPUT METHODS
50
# Parameter settings can be specified through a variety of
51
# mechanisms. In order of decreasing precedence these are:
52
# .IP "interactive mode"
53
# By default, postfix-install will ask the user for installation
54
# parameter settings. These settings have the highest precedence.
56
# Parameter settings can be given as name=value arguments on
57
# the postfix-install command line.
58
# .IP "process environment"
59
# Parameter settings can be given as name=value environment
60
# variables. Environment parameters can also be specified on the
61
# make(1) command line as "make install name=value ...".
62
# .IP "installed configuration files"
63
# If a parameter is not specified via the command line or via the
64
# process environment, postfix-install will attempt to extract its
65
# value from an already installed Postfix main.cf configuration file.
66
# .IP "built-in defaults"
67
# These settings have the lowest precedence.
68
# INSTALLATION PARAMETER DESCRIPTION
71
# The description of installation parameters and their built-in
72
# default settings is as follows:
74
# Prefix that is prepended to the pathnames of installed files.
75
# Specify this ONLY when creating pre-built packages for distribution to
76
# other systems. The built-in default is "/", the local root directory.
77
# This parameter setting is not recorded in the installed main.cf file.
79
# Directory for scratch files while installing Postfix.
80
# You must have write permission in this directory.
81
# The built-in default directory name is the current directory.
82
# This parameter setting is not recorded in the installed main.cf file.
83
# .IP config_directory
84
# The final destination directory for Postfix configuration files.
85
# The built-in default directory name is /etc/postfix.
86
# This parameter setting is not recorded in the installed main.cf file
87
# and can be changed only by recompiling Postfix.
88
# .IP daemon_directory
89
# The final destination directory for Postfix daemon programs. This
90
# directory should not be in the command search path of any users.
91
# The built-in default directory name is /usr/libexec/postfix.
92
# This parameter setting is recorded in the installed main.cf file.
93
# .IP command_directory
94
# The final destination directory for Postfix administrative commands.
95
# This directory should be in the command search path of adminstrative
96
# users. The built-in default directory name is system dependent.
97
# This parameter setting is recorded in the installed main.cf file.
99
# The destination directory for the Postfix HTML files.
100
# This parameter setting is recorded in the installed main.cf file.
101
# .IP queue_directory
102
# The final destination directory for Postfix queues.
103
# The built-in default directory name is /var/spool/postfix.
104
# This parameter setting is recorded in the installed main.cf file.
106
# The final destination pathname for the Postfix sendmail command.
107
# This is the Sendmail-compatible mail posting interface.
108
# The built-in default pathname is system dependent.
109
# This parameter setting is recorded in the installed main.cf file.
110
# .IP newaliases_path
111
# The final destination pathname for the Postfix newaliases command.
112
# This is the Sendmail-compatible command to build alias databases
113
# for the Postfix local delivery agent.
114
# The built-in default pathname is system dependent.
115
# This parameter setting is recorded in the installed main.cf file.
117
# The final destination pathname for the Postfix mailq command.
118
# This is the Sendmail-compatible command to list the mail queue.
119
# The built-in default pathname is system dependent.
120
# This parameter setting is recorded in the installed main.cf file.
122
# The owner of the Postfix queue. Its numerical user ID and group ID
123
# must not be used by any other accounts on the system.
124
# The built-in default account name is postfix.
125
# This parameter setting is recorded in the installed main.cf file.
127
# The group for mail submission and for queue management commands.
128
# Its numerical group ID must not be used by any other accounts on the
129
# system, not even by the mail_owner account.
130
# The built-in default group name is postdrop.
131
# This parameter setting is recorded in the installed main.cf file.
132
# .IP manpage_directory
133
# The destination directory for the Postfix on-line manual pages.
134
# This parameter setting is recorded in the installed main.cf file.
135
# .IP sample_directory
136
# The destination directory for the Postfix sample configuration files.
137
# This parameter is obsolete as of Postfix version 2.1.
138
# This parameter setting is recorded in the installed main.cf file.
139
# .IP readme_directory
140
# The destination directory for the Postfix README files.
141
# This parameter setting is recorded in the installed main.cf file.
143
# post-install(1) post-installation procedure
145
# $config_directory/main.cf, Postfix installation configuration.
146
# $config_directory/postfix-files, installation control file.
147
# $config_directory/install.cf, obsolete configuration file.
151
# The Secure Mailer license must be distributed with this software.
154
# IBM T.J. Watson Research
156
# Yorktown Heights, NY 10598, USA
160
# By now, shells must have functions. Ultrix users must use sh5 or lose.
163
PATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd
169
USAGE="Usage: $0 [name=value] [option]
170
-non-interactive Do not ask for installation parameters.
171
name=value Specify an installation parameter".
173
# Process command-line options and parameter settings. Work around
174
# brain damaged shells. "IFS=value command" should not make the
175
# IFS=value setting permanent. But some broken standard allows it.
180
*=*) IFS= eval $arg; IFS="$BACKUP_IFS";;
181
-non-int*) non_interactive=1;;
182
*) echo "$0: Error: $USAGE" 1>&2; exit 1;;
189
test -z "$non_interactive" -a ! -t 0 && {
190
echo $0: Error: for non-interactive use, run: \"$0 -non-interactive\" 1>&2
194
test -x bin/postconf || {
195
echo $0: Error: no bin/postconf file. Did you forget to run \"make\"? 1>&2
206
test -z "$non_interactive" && cat <<EOF | ${FMT}
208
Warning: if you use this script to install Postfix locally,
209
this script will replace existing sendmail or Postfix programs.
210
Make backups if you want to be able to recover.
212
Before installing files, this script prompts you for some
213
definitions. Most definitions will be remembered, so you have
214
to specify them only once. All definitions should have a
215
reasonable default value.
218
# The following shell functions replace files/symlinks while minimizing
219
# the time that a file does not exist, and avoid copying over files
220
# in order to not disturb running programs. That is certainly desirable
221
# when upgrading Postfix on a live machine. It also avoids surprises
222
# when building a Postfix package for distribution to other systems.
224
compare_or_replace() {
230
(cmp $src $dst >/dev/null 2>&1 && echo Skipping $dst...) || {
231
echo Updating $dst...
232
rm -f $tempdir/junk || exit 1
233
cp $src $tempdir/junk || exit 1
234
mv -f $tempdir/junk $dst || exit 1
235
test -z "$owner" || chown $owner $dst || exit 1
236
test -z "$group" || chgrp $group $dst || exit 1
237
chmod $mode $dst || exit 1
241
compare_or_symlink() {
242
(cmp $1 $2 >/dev/null 2>&1 && echo Skipping $2...) || {
244
rm -f $tempdir/junk || exit 1
245
dest=`echo $1 | sed '
251
link=`echo $2 | sed '
260
ln -s $link $tempdir/junk || exit 1
261
mv -f $tempdir/junk $2 || {
262
echo $0: Error: your mv command has trouble renaming symlinks. 1>&2
263
echo If you run Linux, upgrade to GNU fileutils-4.0 or better, 1>&2
264
echo or choose a tempdir that is in the same file system as $2. 1>&2
265
echo If you run FreeBSD, upgrade to version 5 or better. 1>&2
271
compare_or_hardlink() {
272
(cmp $1 $2 >/dev/null 2>&1 && echo Skipping $2...) || {
282
dir=`echo $path|sed -e 's/[/][/]*[^/]*$//' -e 's/^$/\//'`
283
test -d $dir || mkdir -p $dir || exit 1
287
# How to supress newlines in echo.
296
install_root_prompt="the prefix for installed file names. Specify
297
this ONLY if you are building ready-to-install packages for
298
distribution to other machines."
300
tempdir_prompt="a directory for scratch files while installing
301
Postfix. You must have write permission in this directory."
303
config_directory_prompt="the final destination directory for
304
installed Postfix configuration files."
306
daemon_directory_prompt="the final destination directory for
307
installed Postfix daemon programs. This directory should not be
308
in the command search path of any users."
310
command_directory_prompt="the final destination directory for
311
installed Postfix administrative commands. This directory should
312
be in the command search path of adminstrative users."
314
queue_directory_prompt="the final destination directory for Postfix
317
sendmail_path_prompt="the final destination pathname for the
318
installed Postfix sendmail command. This is the Sendmail-compatible
319
mail posting interface."
321
newaliases_path_prompt="the final destination pathname for the
322
installed Postfix newaliases command. This is the Sendmail-compatible
323
command to build alias databases for the Postfix local delivery
326
mailq_path_prompt="the final destination pathname for the installed
327
Postfix mailq command. This is the Sendmail-compatible mail queue
330
mail_owner_prompt="the owner of the Postfix queue. Specify an
331
account with numerical user ID and group ID values that are not
332
used by any other accounts on the system."
334
setgid_group_prompt="the group for mail submission and for queue
335
management commands. Specify a group name with a numerical group
336
ID that is not shared with other accounts, not even with the Postfix
337
mail_owner account. You can no longer specify \"no\" here."
339
manpage_directory_prompt="the destination directory for the Postfix on-line
340
manual pages. You can no longer specify \"no\" here."
342
sample_directory_prompt="the destination directory for the Postfix
343
sample configuration files."
345
readme_directory_prompt="the destination directory for the Postfix
346
README files. Specify \"no\" if you do not want to install these files."
348
html_directory_prompt="the destination directory for the Postfix
349
HTML files. Specify \"no\" if you do not want to install these files."
351
# Default settings, just to get started.
355
: ${config_directory=`bin/postconf -h -d config_directory`}
357
# Find out the location of installed configuration files.
359
test -z "$non_interactive" && for name in install_root tempdir config_directory
364
eval echo Please specify \$${name}_prompt | ${FMT}
365
eval echo \$n "$name: [\$$name]\ \$c"
370
/*) eval $name=$ans; break;;
371
*) echo; echo $0: Error: $name should be an absolute path name. 1>&2;;
377
# In case some systems special-case pathnames beginning with //.
379
case $install_root in
383
CONFIG_DIRECTORY=$install_root$config_directory
385
# If a parameter is not set via the command line or environment,
386
# try to use settings from installed configuration files.
388
# Extract parameter settings from the obsolete install.cf file, as
389
# a transitional aid.
391
grep setgid_group $CONFIG_DIRECTORY/main.cf >/dev/null 2>&1 || {
392
test -f $CONFIG_DIRECTORY/install.cf && {
393
for name in sendmail_path newaliases_path mailq_path setgid manpages
397
"") eval unset $name;;
399
eval : \${$name="\`. $CONFIG_DIRECTORY/install.cf; echo \$$name\`"} \
402
: ${setgid_group=$setgid}
403
: ${manpage_directory=$manpages}
407
# Extract parameter settings from the installed main.cf file.
409
test -f $CONFIG_DIRECTORY/main.cf && {
410
for name in daemon_directory command_directory queue_directory mail_owner \
411
setgid_group sendmail_path newaliases_path mailq_path manpage_directory \
412
sample_directory html_directory readme_directory
416
"") eval unset $name;;
418
eval : \${$name=\`bin/postconf -c $CONFIG_DIRECTORY -h $name\`} ||
423
# Use built-in defaults as the final source of parameter settings.
425
for name in daemon_directory command_directory queue_directory mail_owner \
426
setgid_group sendmail_path newaliases_path mailq_path manpage_directory \
427
sample_directory html_directory readme_directory
431
"") eval unset $name;;
433
eval : \${$name=\`bin/postconf -d -h $name\`} || exit 1
436
# Override settings manually.
438
test -z "$non_interactive" && for name in daemon_directory command_directory \
439
queue_directory sendmail_path newaliases_path mailq_path mail_owner \
440
setgid_group html_directory manpage_directory readme_directory
445
eval echo Please specify \$${name}_prompt | ${FMT}
446
eval echo \$n "$name: [\$$name]\ \$c"
450
*) eval $name=$ans; break;;
457
case "$setgid_group" in
458
no) (echo $0: Error: the setgid_group parameter no longer accepts
459
echo \"no\" values. Try again with \"setgid_group=groupname\" on the
460
echo command line or execute \"make install\" and specify setgid_group
461
echo interactively.) | ${FMT} 1>&2
465
case "$manpage_directory" in
466
no) (echo $0: Error: the manpage_directory parameter no longer accepts
467
echo \"no\" values. Try again with \"manpage_directory=/path/name\"
468
echo on the command line or execute \"make install\" and specify
469
echo manpage_directory interactively.) | ${FMT} 1>&2
473
for path in "$html_directory" "$readme_directory"
478
*) echo $0: Error: \"$path\" should be \"no\" or an absolute path name. 1>&2
483
for path in "$daemon_directory" "$command_directory" "$queue_directory" \
484
"$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory"
488
*) echo $0: Error: \"$path\" should be an absolute path name. 1>&2; exit 1;;
492
for path in mailq_path newaliases_path sendmail_path
494
eval test -d $install_root\$$path && {
495
echo $0: Error: \"$path\" specifies a directory. 1>&2
500
for path in command_directory config_directory daemon_directory \
501
manpage_directory queue_directory html_directory readme_directory
503
eval test -f $install_root\$$path && {
504
echo $0: Error: \"$path\" specifies a regular file. 1>&2
509
test -d $tempdir || mkdir -p $tempdir || exit 1
511
trap "rm -f $tempdir/junk" 0 1 2 3 15
513
( rm -f $tempdir/junk && touch $tempdir/junk ) || {
514
echo $0: Error: you have no write permission to $tempdir. 1>&2
515
echo Specify an alternative directory for scratch files. 1>&2
519
test -z "$install_root" && {
521
chown root $tempdir/junk >/dev/null 2>&1 || {
522
echo Error: you have no permission to change file ownership. 1>&2
526
chown "$mail_owner" $tempdir/junk >/dev/null 2>&1 || {
527
echo $0: Error: \"$mail_owner\" needs an entry in the passwd file. 1>&2
528
echo Remember, \"$mail_owner\" needs a dedicated user and group id. 1>&2
532
chgrp "$setgid_group" $tempdir/junk >/dev/null 2>&1 || {
533
echo $0: Error: \"$setgid_group\" needs an entry in the group file. 1>&2
534
echo Remember, \"$setgid_group\" needs a dedicated group id. 1>&2
540
rm -f $tempdir/junk || exit 1
546
DAEMON_DIRECTORY=$install_root$daemon_directory
547
COMMAND_DIRECTORY=$install_root$command_directory
548
QUEUE_DIRECTORY=$install_root$queue_directory
549
SENDMAIL_PATH=$install_root$sendmail_path
550
HTML_DIRECTORY=$install_root$html_directory
551
MANPAGE_DIRECTORY=$install_root$manpage_directory
552
SAMPLE_DIRECTORY=$install_root$sample_directory
553
README_DIRECTORY=$install_root$readme_directory
555
# Avoid repeated tests for existence of these; default permissions suffice.
557
test -d $DAEMON_DIRECTORY || mkdir -p $DAEMON_DIRECTORY || exit 1
558
test -d $COMMAND_DIRECTORY || mkdir -p $COMMAND_DIRECTORY || exit 1
559
test -d $COMMAND_DIRECTORY || mkdir -p $COMMAND_DIRECTORY || exit 1
560
test "$html_directory" = "no" -o -d $HTML_DIRECTORY ||
561
mkdir -p $HTML_DIRECTORY || exit 1
562
test "$readme_directory" = "no" -o -d $README_DIRECTORY ||
563
mkdir -p $README_DIRECTORY || exit 1
565
# Upgrade or first-time installation?
567
if [ -f $CONFIG_DIRECTORY/main.cf ]
569
post_install_options="upgrade-source"
571
post_install_options="first-install"
574
# Install files, using information from the postfix-files file.
576
exec < conf/postfix-files || exit 1
577
while IFS=: read path type owner group mode flags junk
588
# Skip over files that ought to be removed.
589
# Leave it up to post-install to report them to the user.
595
# Skip over files that must be preserved.
598
*p*) eval test -f $install_root$path && {
599
eval echo "Skipping $install_root$path..."
604
# Save source path before it is clobbered.
607
[hl]) eval source=$owner;;
610
# If installing from source code, apply special permissions or ownership.
611
# If building a package, don't apply special permissions or ownership.
613
case $install_root in
615
[$]*) eval owner=$owner;;
619
[$]*) eval group=$group;;
632
# Create/update directory.
634
d) eval path=$install_root$path
635
test "$path" = "${install_root}no" -o -d $path || {
636
mkdir -p $path || exit 1
637
test -z "$owner" || chown $owner $path || exit 1
638
test -z "$group" || chgrp $group $path || exit 1
639
chmod $mode $path || exit 1
643
# Create/update regular file.
645
f) echo $path | (IFS=/ read prefix file; IFS="$BACKUP_IFS"
648
compare_or_replace $mode "$owner" "$group" libexec/$file \
649
$DAEMON_DIRECTORY/$file || exit 1;;
650
'$command_directory')
651
compare_or_replace $mode "$owner" "$group" bin/$file \
652
$COMMAND_DIRECTORY/$file || exit 1;;
654
compare_or_replace $mode "$owner" "$group" conf/$file \
655
$CONFIG_DIRECTORY/$file || exit 1;;
657
check_parent $SENDMAIL_PATH || exit 1
658
compare_or_replace $mode "$owner" "$group" bin/sendmail \
659
$SENDMAIL_PATH || exit 1;;
661
test "$html_directory" = "no" ||
662
compare_or_replace $mode "$owner" "$group" html/$file \
663
$HTML_DIRECTORY/$file || exit 1;;
664
'$manpage_directory')
665
check_parent $MANPAGE_DIRECTORY/$file || exit 1
666
compare_or_replace $mode "$owner" "$group" man/$file \
667
$MANPAGE_DIRECTORY/$file || exit 1;;
669
test "$readme_directory" = "no" ||
670
compare_or_replace $mode "$owner" "$group" README_FILES/$file \
671
$README_DIRECTORY/$file || exit 1;;
672
*) echo $0: Error: unknown entry $path in conf/postfix-files 1>&2
679
h) eval dest_path=$install_root$path
680
check_parent $dest_path || exit 1
681
eval source_path=$install_root$source
682
compare_or_hardlink $source_path $dest_path || exit 1
687
l) eval dest_path=$install_root$path
688
check_parent $dest_path || exit 1
689
eval source_path=$install_root$source
690
compare_or_symlink $source_path $dest_path || exit 1
693
*) echo $0: Error: unknown type $type for $path in conf/postfix-files 1>&2
699
# Save the installation parameters to main.cf even when they haven't
700
# changed from their current default. Defaults can change between
701
# Postfix releases, and software should not suddenly be installed in
702
# the wrong place when Postfix is being upgraded.
704
bin/postconf -c $CONFIG_DIRECTORY -e \
705
"daemon_directory = $daemon_directory" \
706
"command_directory = $command_directory" \
707
"queue_directory = $queue_directory" \
708
"mail_owner = $mail_owner" \
709
"setgid_group = $setgid_group" \
710
"sendmail_path = $sendmail_path" \
711
"mailq_path = $mailq_path" \
712
"newaliases_path = $newaliases_path" \
713
"html_directory = $html_directory" \
714
"manpage_directory = $manpage_directory" \
715
"sample_directory = $sample_directory" \
716
"readme_directory = $readme_directory" \
719
# If Postfix is being installed locally from source code, do the
720
# post-install processing now.
722
test -n "$install_root" || {
723
bin/postfix post-install $post_install_options || exit 1