~ubuntu-branches/ubuntu/trusty/postfix/trusty-proposed

« back to all changes in this revision

Viewing changes to postfix-install

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones
  • Date: 2005-02-27 09:33:07 UTC
  • Revision ID: james.westby@ubuntu.com-20050227093307-cn789t27ibnlh6tf
Tags: upstream-2.1.5
ImportĀ upstreamĀ versionĀ 2.1.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# To view the formatted manual page of this file, type:
 
4
#       POSTFIXSOURCE/mantools/srctoman - postfix-install | nroff -man
 
5
 
 
6
#++
 
7
# NAME
 
8
#       postfix-install 1
 
9
# SUMMARY
 
10
#       Postfix installation procedure
 
11
# SYNOPSIS
 
12
#       sh postfix-install [options] [name=value] ...
 
13
# DESCRIPTION
 
14
#       The postfix-install script is to be run from the top-level
 
15
#       Postfix source directory. It implements the following operations:
 
16
# .IP o
 
17
#       Install or upgrade Postfix from source code. This requires
 
18
#       super-user privileges.
 
19
# .IP o
 
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.
 
25
# .PP
 
26
#       The postfix-install script is controlled by installation parameters.
 
27
#       Specific parameters are described at the end of this document.
 
28
#
 
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.
 
33
#
 
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.
 
41
#
 
42
#       Arguments
 
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
 
46
#       below.
 
47
# INSTALLATION PARAMETER INPUT METHODS
 
48
# .ad
 
49
# .fi
 
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.
 
55
# .IP "command line"
 
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
 
69
# .ad
 
70
# .fi
 
71
#       The description of installation parameters and their built-in
 
72
#       default settings is as follows:
 
73
# .IP install_root
 
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.
 
78
# .IP tempdir
 
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.
 
98
# .IP html_directory
 
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.
 
105
# .IP sendmail_path
 
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.
 
116
# .IP mailq_path
 
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.
 
121
# .IP mail_owner
 
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.
 
126
# .IP setgid_group
 
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.
 
142
# SEE ALSO
 
143
#       post-install(1) post-installation procedure
 
144
# FILES
 
145
#       $config_directory/main.cf, Postfix installation configuration.
 
146
#       $config_directory/postfix-files, installation control file.
 
147
#       $config_directory/install.cf, obsolete configuration file.
 
148
# LICENSE
 
149
# .ad
 
150
# .fi
 
151
#       The Secure Mailer license must be distributed with this software.
 
152
# AUTHOR(S)
 
153
#       Wietse Venema
 
154
#       IBM T.J. Watson Research
 
155
#       P.O. Box 704
 
156
#       Yorktown Heights, NY 10598, USA
 
157
#--
 
158
 
 
159
# Initialize.
 
160
# By now, shells must have functions. Ultrix users must use sh5 or lose.
 
161
 
 
162
umask 022
 
163
PATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd
 
164
SHELL=/bin/sh
 
165
IFS="   
 
166
"
 
167
BACKUP_IFS="$IFS"
 
168
 
 
169
USAGE="Usage: $0 [name=value] [option]
 
170
    -non-interactive        Do not ask for installation parameters.
 
171
    name=value              Specify an installation parameter".
 
172
 
 
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.
 
176
 
 
177
for arg
 
178
do
 
179
    case $arg in
 
180
      *=*) IFS= eval $arg; IFS="$BACKUP_IFS";;
 
181
-non-int*) non_interactive=1;;
 
182
        *) echo "$0: Error: $USAGE" 1>&2; exit 1;;
 
183
    esac
 
184
    shift
 
185
done
 
186
 
 
187
# Sanity checks.
 
188
 
 
189
test -z "$non_interactive" -a ! -t 0 && {
 
190
    echo $0: Error: for non-interactive use, run: \"$0 -non-interactive\" 1>&2
 
191
    exit 1
 
192
}
 
193
 
 
194
test -x bin/postconf || {
 
195
    echo $0: Error: no bin/postconf file. Did you forget to run \"make\"? 1>&2
 
196
    exit 1
 
197
}
 
198
 
 
199
case `uname -s` in
 
200
HP-UX*) FMT=cat;;
 
201
     *) FMT=fmt;;
 
202
esac
 
203
 
 
204
# Disclaimer.
 
205
 
 
206
test -z "$non_interactive" && cat <<EOF | ${FMT}
 
207
 
 
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.
 
211
 
 
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.
 
216
EOF
 
217
 
 
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.
 
223
 
 
224
compare_or_replace() {
 
225
    mode=$1
 
226
    owner=$2
 
227
    group=$3
 
228
    src=$4
 
229
    dst=$5
 
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
 
238
    }
 
239
}
 
240
 
 
241
compare_or_symlink() {
 
242
    (cmp $1 $2 >/dev/null 2>&1 && echo Skipping $2...) || {
 
243
        echo Updating $2...
 
244
        rm -f $tempdir/junk || exit 1
 
245
        dest=`echo $1 | sed '
 
246
            s;^'$install_root';;
 
247
            s;/\./;/;g
 
248
            s;//*;/;g
 
249
            s;^/;;
 
250
        '`
 
251
        link=`echo $2 | sed '
 
252
            s;^'$install_root';;
 
253
            s;/\./;/;g
 
254
            s;//*;/;g
 
255
            s;^/;;
 
256
            s;/[^/]*$;/;
 
257
            s;[^/]*/;../;g
 
258
            s;$;'$dest';
 
259
        '`
 
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
 
266
            exit 1
 
267
        }
 
268
    }
 
269
}
 
270
 
 
271
compare_or_hardlink() {
 
272
    (cmp $1 $2 >/dev/null 2>&1 && echo Skipping $2...) || {
 
273
        echo Updating $2...
 
274
        rm -f $2 || exit 1
 
275
        ln $1 $2 || exit 1
 
276
    }
 
277
}
 
278
 
 
279
check_parent() {
 
280
    for path
 
281
    do
 
282
        dir=`echo $path|sed -e 's/[/][/]*[^/]*$//' -e 's/^$/\//'`
 
283
        test -d $dir || mkdir -p $dir || exit 1
 
284
    done
 
285
}
 
286
 
 
287
# How to supress newlines in echo.
 
288
 
 
289
case `echo -n` in
 
290
"") n=-n; c=;;
 
291
 *) n=; c='\c';;
 
292
esac
 
293
 
 
294
# Prompts.
 
295
 
 
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."
 
299
 
 
300
tempdir_prompt="a directory for scratch files while installing
 
301
Postfix.  You must have write permission in this directory."
 
302
 
 
303
config_directory_prompt="the final destination directory for
 
304
installed Postfix configuration files."
 
305
 
 
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."
 
309
 
 
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."
 
313
 
 
314
queue_directory_prompt="the final destination directory for Postfix
 
315
queues."
 
316
 
 
317
sendmail_path_prompt="the final destination pathname for the
 
318
installed Postfix sendmail command. This is the Sendmail-compatible
 
319
mail posting interface."
 
320
 
 
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
 
324
agent."
 
325
 
 
326
mailq_path_prompt="the final destination pathname for the installed
 
327
Postfix mailq command.  This is the Sendmail-compatible mail queue
 
328
listing command."
 
329
 
 
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."
 
333
 
 
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."
 
338
 
 
339
manpage_directory_prompt="the destination directory for the Postfix on-line
 
340
manual pages. You can no longer specify \"no\" here."
 
341
 
 
342
sample_directory_prompt="the destination directory for the Postfix
 
343
sample configuration files."
 
344
 
 
345
readme_directory_prompt="the destination directory for the Postfix
 
346
README files. Specify \"no\" if you do not want to install these files."
 
347
 
 
348
html_directory_prompt="the destination directory for the Postfix
 
349
HTML files. Specify \"no\" if you do not want to install these files."
 
350
 
 
351
# Default settings, just to get started.
 
352
 
 
353
: ${install_root=/}
 
354
: ${tempdir=`pwd`}
 
355
: ${config_directory=`bin/postconf -h -d config_directory`}
 
356
 
 
357
# Find out the location of installed configuration files.
 
358
 
 
359
test -z "$non_interactive" && for name in install_root tempdir config_directory
 
360
do
 
361
    while :
 
362
    do
 
363
        echo
 
364
        eval echo Please specify \$${name}_prompt | ${FMT}
 
365
        eval echo \$n "$name: [\$$name]\  \$c"
 
366
        read ans
 
367
        case $ans in
 
368
        "") break;;
 
369
         *) case $ans in
 
370
            /*) eval $name=$ans; break;;
 
371
             *) echo; echo $0: Error: $name should be an absolute path name. 1>&2;;
 
372
            esac;;
 
373
        esac
 
374
    done
 
375
done
 
376
 
 
377
# In case some systems special-case pathnames beginning with //.
 
378
 
 
379
case $install_root in
 
380
/) install_root=
 
381
esac
 
382
 
 
383
CONFIG_DIRECTORY=$install_root$config_directory
 
384
 
 
385
# If a parameter is not set via the command line or environment,
 
386
# try to use settings from installed configuration files.
 
387
 
 
388
# Extract parameter settings from the obsolete install.cf file, as
 
389
# a transitional aid.
 
390
 
 
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
 
394
        do
 
395
            eval junk=\$$name
 
396
            case "$junk" in
 
397
            "") eval unset $name;;
 
398
            esac
 
399
            eval : \${$name="\`. $CONFIG_DIRECTORY/install.cf; echo \$$name\`"} \
 
400
                || exit 1
 
401
        done
 
402
        : ${setgid_group=$setgid}
 
403
        : ${manpage_directory=$manpages}
 
404
    }
 
405
}
 
406
 
 
407
# Extract parameter settings from the installed main.cf file.
 
408
 
 
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
 
413
    do
 
414
        eval junk=\$$name
 
415
        case "$junk" in
 
416
        "") eval unset $name;;
 
417
        esac
 
418
        eval : \${$name=\`bin/postconf -c $CONFIG_DIRECTORY -h $name\`} ||
 
419
            exit 1
 
420
    done
 
421
}
 
422
 
 
423
# Use built-in defaults as the final source of parameter settings.
 
424
 
 
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
 
428
do
 
429
    eval junk=\$$name
 
430
    case "$junk" in
 
431
    "") eval unset $name;;
 
432
    esac
 
433
    eval : \${$name=\`bin/postconf -d -h $name\`} || exit 1
 
434
done
 
435
 
 
436
# Override settings manually.
 
437
 
 
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
 
441
do
 
442
    while :
 
443
    do
 
444
        echo
 
445
        eval echo Please specify \$${name}_prompt | ${FMT}
 
446
        eval echo \$n "$name: [\$$name]\  \$c"
 
447
        read ans
 
448
        case $ans in
 
449
        "") break;;
 
450
         *) eval $name=$ans; break;;
 
451
        esac
 
452
    done
 
453
done
 
454
 
 
455
# Sanity checks
 
456
 
 
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
 
462
     exit 1;;
 
463
esac
 
464
 
 
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
 
470
     exit 1;;
 
471
esac
 
472
 
 
473
for path in "$html_directory" "$readme_directory"
 
474
do
 
475
   case "$path" in
 
476
   /*) ;;
 
477
   no) ;;
 
478
    *) echo $0: Error: \"$path\" should be \"no\" or an absolute path name. 1>&2
 
479
       exit 1;;
 
480
   esac
 
481
done
 
482
 
 
483
for path in "$daemon_directory" "$command_directory" "$queue_directory" \
 
484
    "$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory"
 
485
do
 
486
   case "$path" in
 
487
   /*) ;;
 
488
    *) echo $0: Error: \"$path\" should be an absolute path name. 1>&2; exit 1;;
 
489
   esac
 
490
done
 
491
 
 
492
for path in mailq_path newaliases_path sendmail_path
 
493
do
 
494
    eval test -d $install_root\$$path && {
 
495
        echo $0: Error: \"$path\" specifies a directory. 1>&2
 
496
        exit 1
 
497
    }
 
498
done
 
499
 
 
500
for path in command_directory config_directory daemon_directory \
 
501
    manpage_directory queue_directory html_directory readme_directory
 
502
do
 
503
    eval test -f $install_root\$$path && {
 
504
        echo $0: Error: \"$path\" specifies a regular file. 1>&2
 
505
        exit 1
 
506
    }
 
507
done
 
508
 
 
509
test -d $tempdir || mkdir -p $tempdir || exit 1
 
510
 
 
511
trap "rm -f $tempdir/junk" 0 1 2 3 15
 
512
 
 
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
 
516
    exit 1
 
517
}
 
518
 
 
519
test -z "$install_root" && {
 
520
 
 
521
    chown root $tempdir/junk >/dev/null 2>&1 || {
 
522
        echo Error: you have no permission to change file ownership. 1>&2
 
523
        exit 1
 
524
    }
 
525
 
 
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
 
529
        exit 1
 
530
    }
 
531
 
 
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
 
535
        exit 1
 
536
    }
 
537
 
 
538
}
 
539
 
 
540
rm -f $tempdir/junk || exit 1
 
541
 
 
542
trap 0 1 2 3 15
 
543
 
 
544
# Avoid clumsiness.
 
545
 
 
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
 
554
 
 
555
# Avoid repeated tests for existence of these; default permissions suffice.
 
556
 
 
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
 
564
 
 
565
# Upgrade or first-time installation?
 
566
 
 
567
if [ -f $CONFIG_DIRECTORY/main.cf ]
 
568
then
 
569
    post_install_options="upgrade-source"
 
570
else
 
571
    post_install_options="first-install"
 
572
fi
 
573
 
 
574
# Install files, using information from the postfix-files file.
 
575
 
 
576
exec < conf/postfix-files || exit 1
 
577
while IFS=: read path type owner group mode flags junk
 
578
do
 
579
    IFS="$BACKUP_IFS"
 
580
 
 
581
    # Skip comments.
 
582
 
 
583
    case $path in
 
584
    [$]*) ;;
 
585
       *) continue;;
 
586
    esac
 
587
 
 
588
    # Skip over files that ought to be removed.
 
589
    # Leave it up to post-install to report them to the user.
 
590
 
 
591
    case $flags in
 
592
    *o*) continue
 
593
    esac
 
594
 
 
595
    # Skip over files that must be preserved.
 
596
 
 
597
    case $flags in
 
598
    *p*) eval test -f $install_root$path && {
 
599
            eval echo "Skipping $install_root$path..."
 
600
            continue
 
601
         };;
 
602
    esac
 
603
 
 
604
    # Save source path before it is clobbered.
 
605
 
 
606
    case $type in
 
607
    [hl]) eval source=$owner;;
 
608
    esac
 
609
 
 
610
    # If installing from source code, apply special permissions or ownership.
 
611
    # If building a package, don't apply special permissions or ownership.
 
612
 
 
613
    case $install_root in
 
614
    "") case $owner in
 
615
        [$]*) eval owner=$owner;;
 
616
        root) owner=;;
 
617
        esac
 
618
        case $group in
 
619
        [$]*) eval group=$group;;
 
620
           -) group=;;
 
621
        esac;;
 
622
     *) case $mode in
 
623
        [1-7]755) mode=755;;
 
624
        esac
 
625
        owner=
 
626
        group=;;
 
627
    esac
 
628
 
 
629
 
 
630
    case $type in
 
631
 
 
632
     # Create/update directory.
 
633
 
 
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
 
640
        }
 
641
        continue;;
 
642
 
 
643
     # Create/update regular file.
 
644
 
 
645
     f) echo $path | (IFS=/ read prefix file; IFS="$BACKUP_IFS"
 
646
        case $prefix in
 
647
        '$daemon_directory')
 
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;;
 
653
        '$config_directory')
 
654
            compare_or_replace $mode "$owner" "$group" conf/$file \
 
655
                $CONFIG_DIRECTORY/$file || exit 1;;
 
656
        '$sendmail_path')
 
657
            check_parent $SENDMAIL_PATH || exit 1
 
658
            compare_or_replace $mode "$owner" "$group" bin/sendmail \
 
659
                $SENDMAIL_PATH || exit 1;;
 
660
        '$html_directory')
 
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;;
 
668
        '$readme_directory')
 
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
 
673
            exit 1;;
 
674
        esac) || exit 1
 
675
        continue;;
 
676
 
 
677
     # Hard link
 
678
 
 
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
 
683
        continue;;
 
684
 
 
685
     # Symbolic link
 
686
 
 
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
 
691
        continue;;
 
692
 
 
693
     *) echo $0: Error: unknown type $type for $path in conf/postfix-files 1>&2
 
694
        exit 1;;
 
695
    esac
 
696
 
 
697
    done
 
698
 
 
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.
 
703
 
 
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" \
 
717
|| exit 1
 
718
 
 
719
# If Postfix is being installed locally from source code, do the
 
720
# post-install processing now.
 
721
 
 
722
test -n "$install_root" || {
 
723
    bin/postfix post-install $post_install_options || exit 1
 
724
}