Home | History | Annotate | Line # | Download | only in conf
post-install revision 1.4.4.1
      1      1.1      tron #!/bin/sh
      2  1.4.4.1  perseant #	$NetBSD: post-install,v 1.4.4.1 2025/08/02 05:49:49 perseant 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.2  christos #	according to the contents of $meta_directory/postfix-files
     46      1.2  christos #	and optionally in $meta_directory/postfix-files.d/*, using
     47      1.2  christos #	the mail_owner and setgid_group parameter settings from the
     48      1.2  christos #	command line, process environment or from the installed
     49      1.2  christos #	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.2  christos #	contents of $meta_directory/postfix-files and optionally
     55      1.2  christos #	in $meta_directory/postfix-files.d/*, using the mail_owner
     56      1.2  christos #	and setgid_group parameter settings from the command line,
     57      1.2  christos #	process environment or from the installed main.cf file.
     58      1.2  christos #	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.2  christos #	specified in $meta_directory/postfix-files and optionally
     66      1.2  christos #	in $meta_directory/postfix-files.d/*, using the mail_owner
     67      1.2  christos #	and setgid_group parameter settings from the command line,
     68      1.2  christos #	process environment or from the installed main.cf file.
     69      1.2  christos #	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.4  christos #	directory should be in the command search path of administrative 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.2  christos # .IP shlib_directory
    181      1.2  christos #	The directory for the Postfix shared-library files, and for
    182      1.2  christos #	the Postfix dabatase plugin files with a relative pathname
    183      1.2  christos #	in the file dynamicmaps.cf.
    184      1.2  christos # .IP meta_directory
    185      1.2  christos #	The directory for non-executable files that are shared
    186      1.2  christos #	among multiple Postfix instances, such as postfix-files,
    187      1.2  christos #	dynamicmaps.cf, as well as the multi-instance template files
    188      1.2  christos #	main.cf.proto and master.cf.proto.
    189      1.1      tron # SEE ALSO
    190      1.1      tron #	postfix-install(1) Postfix primary installation script.
    191      1.1      tron # FILES
    192      1.1      tron #	$config_directory/main.cf, Postfix installation parameters.
    193      1.2  christos #	$meta_directory/postfix-files, installation control file.
    194      1.2  christos #	$meta_directory/postfix-files.d/*, optional control files.
    195      1.1      tron #	$config_directory/install.cf, obsolete configuration file.
    196      1.1      tron # LICENSE
    197      1.1      tron # .ad
    198      1.1      tron # .fi
    199      1.1      tron #	The Secure Mailer license must be distributed with this software.
    200      1.1      tron # AUTHOR(S)
    201      1.1      tron #	Wietse Venema
    202      1.1      tron #	IBM T.J. Watson Research
    203      1.1      tron #	P.O. Box 704
    204      1.1      tron #	Yorktown Heights, NY 10598, USA
    205      1.3  christos #
    206      1.3  christos #	Wietse Venema
    207      1.3  christos #	Google, Inc.
    208      1.3  christos #	111 8th Avenue
    209      1.3  christos #	New York, NY 10011, USA
    210  1.4.4.1  perseant #
    211  1.4.4.1  perseant #	Wietse Venema
    212  1.4.4.1  perseant #	porcupine.org
    213  1.4.4.1  perseant #	Amawalk, NY 10501, USA
    214      1.1      tron #--
    215      1.1      tron 
    216      1.1      tron umask 022
    217      1.1      tron 
    218      1.1      tron PATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd
    219      1.1      tron SHELL=/bin/sh
    220      1.1      tron IFS=" 	
    221      1.1      tron "
    222      1.1      tron BACKUP_IFS="$IFS"
    223      1.1      tron debug=:
    224      1.1      tron #debug=echo
    225      1.1      tron MOST_PARAMETERS="command_directory daemon_directory data_directory
    226      1.1      tron     html_directory mail_owner mailq_path manpage_directory
    227      1.1      tron     newaliases_path queue_directory readme_directory sample_directory
    228      1.2  christos     sendmail_path setgid_group shlib_directory meta_directory"
    229      1.1      tron NON_SHARED="config_directory queue_directory data_directory"
    230      1.1      tron 
    231      1.1      tron USAGE="Usage: $0 [name=value] command
    232      1.1      tron     create-missing          Create missing queue directories.
    233      1.1      tron     upgrade-source          When installing or upgrading from source code.
    234      1.1      tron     upgrade-package         When installing or upgrading from pre-built package.
    235      1.1      tron     first-install-reminder  Remind of mandatory first-time configuration steps.
    236      1.1      tron     name=value              Specify an installation parameter".
    237      1.1      tron 
    238      1.1      tron # Process command-line options and parameter settings. Work around
    239      1.1      tron # brain damaged shells. "IFS=value command" should not make the
    240      1.1      tron # IFS=value setting permanent. But some broken standard allows it.
    241      1.1      tron 
    242      1.1      tron create=; set_perms=; upgrade_perms=; upgrade_conf=; first_install_reminder=
    243      1.1      tron obsolete=; keep_list=;
    244      1.1      tron 
    245      1.1      tron for arg
    246      1.1      tron do
    247      1.1      tron     case $arg in
    248      1.2  christos 	*[" 	"]*) echo $0: "Error: argument contains whitespace: '$arg'"
    249      1.2  christos 		     exit 1;;
    250      1.1      tron                 *=*) IFS= eval $arg; IFS="$BACKUP_IFS";;
    251      1.1      tron      create-missing) create=1;;
    252      1.1      tron 	  set-perm*) create=1; set_perms=1;;
    253      1.1      tron       upgrade-perm*) create=1; upgrade_perms=1;;
    254      1.1      tron       upgrade-conf*) upgrade_conf=1;;
    255      1.1      tron      upgrade-source) create=1; upgrade_conf=1; upgrade_perms=1;;
    256      1.1      tron     upgrade-package) create=1; upgrade_conf=1; set_perms=1;;
    257      1.1      tron      first-install*) first_install_reminder=1;;
    258      1.1      tron 		  *) echo "$0: Error: $USAGE" 1>&2; exit 1;;
    259      1.1      tron     esac
    260      1.1      tron     shift
    261      1.1      tron done
    262      1.1      tron 
    263      1.1      tron # Sanity checks.
    264      1.1      tron 
    265      1.1      tron test -n "$create$upgrade_conf$first_install_reminder" || {
    266      1.1      tron     echo "$0: Error: $USAGE" 1>&2
    267      1.1      tron     exit 1
    268      1.1      tron }
    269      1.1      tron 
    270      1.1      tron # Bootstrapping problem.
    271      1.1      tron 
    272      1.1      tron if [ -n "$command_directory" ]
    273      1.1      tron then
    274      1.1      tron     POSTCONF="$command_directory/postconf"
    275      1.1      tron else
    276      1.1      tron     POSTCONF="postconf"
    277      1.1      tron fi
    278      1.1      tron 
    279      1.1      tron $POSTCONF -d mail_version >/dev/null 2>/dev/null || {
    280      1.1      tron     echo $0: Error: no $POSTCONF command found. 1>&2
    281      1.1      tron     echo Re-run this command as $0 command_directory=/some/where. 1>&2
    282      1.1      tron     exit 1
    283      1.1      tron }
    284      1.1      tron 
    285      1.1      tron # Also used to require license etc. files only in the default instance.
    286      1.1      tron 
    287      1.1      tron def_config_directory=`$POSTCONF -d -h config_directory` || exit 1
    288      1.1      tron test -n "$config_directory" ||
    289      1.1      tron     config_directory="$def_config_directory"
    290      1.1      tron 
    291      1.1      tron test -d "$config_directory" || {
    292      1.1      tron     echo $0: Error: $config_directory is not a directory. 1>&2
    293      1.1      tron     exit 1
    294      1.1      tron }
    295      1.1      tron 
    296      1.1      tron # If this is a secondary instance, don't touch shared files.
    297      1.1      tron # XXX Solaris does not have "test -e".
    298      1.1      tron 
    299      1.1      tron instances=`test ! -f $def_config_directory/main.cf || 
    300  1.4.4.1  perseant     $POSTCONF -qc $def_config_directory -h multi_instance_directories | 
    301  1.4.4.1  perseant 	sed 'y/,/ /'` || exit 1
    302      1.1      tron 
    303      1.1      tron update_shared_files=1
    304      1.1      tron for name in $instances
    305      1.1      tron do
    306      1.1      tron     case "$name" in
    307      1.1      tron     "$def_config_directory") ;;
    308      1.1      tron     "$config_directory") update_shared_files=; break;;
    309      1.1      tron     esac
    310      1.1      tron done
    311      1.1      tron 
    312      1.2  christos test -f $meta_directory/postfix-files || {
    313      1.2  christos     echo $0: Error: $meta_directory/postfix-files is not a file. 1>&2
    314      1.1      tron     exit 1
    315      1.1      tron }
    316      1.1      tron 
    317      1.1      tron # SunOS5 fmt(1) truncates lines > 1000 characters.
    318      1.1      tron 
    319      1.1      tron fake_fmt() {
    320      1.1      tron     sed '
    321      1.1      tron     :top
    322      1.1      tron 	/^\(  *\)\([^ ][^ ]*\)  */{
    323      1.1      tron 	    s//\1\2\
    324      1.1      tron \1/
    325      1.1      tron 	    P
    326      1.1      tron 	    D
    327      1.1      tron 	    b top
    328      1.1      tron 	}
    329      1.1      tron     ' | fmt
    330      1.1      tron }
    331      1.1      tron 
    332      1.1      tron case `uname -s` in
    333      1.1      tron HP-UX*) FMT=cat;;
    334      1.1      tron SunOS*) FMT=fake_fmt;;
    335      1.1      tron      *) FMT=fmt;;
    336      1.1      tron esac
    337      1.1      tron 
    338      1.1      tron # If a parameter is not set via the command line or environment,
    339      1.1      tron # try to use settings from installed configuration files.
    340      1.1      tron 
    341      1.1      tron # Extract parameter settings from the obsolete install.cf file, as
    342      1.1      tron # a transitional aid.
    343      1.1      tron 
    344      1.1      tron grep setgid_group $config_directory/main.cf >/dev/null 2>&1 || {
    345      1.1      tron     test -f $config_directory/install.cf  && {
    346      1.1      tron         for name in sendmail_path newaliases_path mailq_path setgid manpages
    347      1.1      tron         do
    348      1.1      tron 	eval junk=\$$name
    349      1.1      tron         case "$junk" in
    350      1.1      tron         "") eval unset $name;;
    351      1.1      tron         esac
    352      1.1      tron 	   eval : \${$name="\`. $config_directory/install.cf; echo \$$name\`"} \
    353      1.1      tron 		|| exit 1
    354      1.1      tron         done
    355      1.1      tron         : ${setgid_group=$setgid}
    356      1.1      tron         : ${manpage_directory=$manpages}
    357      1.1      tron     }
    358      1.1      tron }
    359      1.1      tron 
    360      1.1      tron # Extract parameter settings from the installed main.cf file.
    361      1.1      tron 
    362      1.1      tron test -f $config_directory/main.cf && {
    363      1.1      tron     for name in $MOST_PARAMETERS
    364      1.1      tron     do
    365      1.1      tron 	eval junk=\$$name
    366      1.1      tron         case "$junk" in
    367      1.1      tron         "") eval unset $name;;
    368      1.1      tron         esac
    369  1.4.4.1  perseant         eval : \${$name=\`$POSTCONF -qc $config_directory -h $name\`} || exit 1
    370      1.1      tron     done
    371      1.1      tron }
    372      1.1      tron 
    373      1.1      tron # Sanity checks
    374      1.1      tron 
    375      1.1      tron case $manpage_directory in
    376      1.1      tron  no) echo $0: Error: manpage_directory no longer accepts \"no\" values. 1>&2
    377      1.1      tron      echo Try again with \"$0 manpage_directory=/pathname ...\". 1>&2; exit 1;;
    378      1.1      tron esac
    379      1.1      tron 
    380      1.1      tron case $setgid_group in
    381      1.1      tron  no) echo $0: Error: setgid_group no longer accepts \"no\" values. 1>&2
    382      1.1      tron      echo Try again with \"$0 setgid_group=groupname ...\" 1>&2; exit 1;;
    383      1.1      tron esac
    384      1.1      tron 
    385      1.1      tron for path in "$daemon_directory" "$command_directory" "$queue_directory" \
    386      1.2  christos     "$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory" \
    387      1.2  christos     "$meta_directory"
    388      1.1      tron do
    389      1.1      tron    case "$path" in
    390      1.1      tron    /*) ;;
    391      1.1      tron     *) echo $0: Error: \"$path\" should be an absolute path name. 1>&2; exit 1;;
    392      1.1      tron    esac
    393      1.1      tron done
    394      1.1      tron 
    395      1.2  christos for path in "$html_directory" "$readme_directory" "$shlib_directory"
    396      1.1      tron do
    397      1.1      tron    case "$path" in
    398      1.1      tron    /*) ;;
    399      1.1      tron    no) ;;
    400      1.1      tron     *) echo $0: Error: \"$path\" should be \"no\" or an absolute path name. 1>&2; exit 1;;
    401      1.1      tron    esac
    402      1.1      tron done
    403      1.1      tron 
    404      1.1      tron # Find out what parameters were not specified via command line,
    405      1.1      tron # via environment, or via installed configuration files.
    406      1.1      tron 
    407      1.1      tron missing=
    408      1.1      tron for name in $MOST_PARAMETERS
    409      1.1      tron do
    410      1.1      tron     eval test -n \"\$$name\" || missing="$missing $name"
    411      1.1      tron done
    412      1.1      tron 
    413      1.1      tron # All parameters must be specified at this point.
    414      1.1      tron 
    415      1.1      tron test -n "$non_interactive" -a -n "$missing" && {
    416      1.1      tron     cat <<EOF | ${FMT} 1>&2
    417      1.1      tron $0: Error: some required installation parameters are not defined.
    418      1.1      tron 
    419      1.1      tron - Either the parameters need to be given in the $config_directory/main.cf
    420      1.1      tron file from a recent Postfix installation,
    421      1.1      tron 
    422      1.1      tron - Or the parameters need to be specified through the process
    423      1.1      tron environment.
    424      1.1      tron 
    425      1.1      tron - Or the parameters need to be specified as name=value arguments
    426      1.1      tron on the $0 command line,
    427      1.1      tron 
    428      1.1      tron The following parameters were missing:
    429      1.1      tron 
    430      1.1      tron     $missing
    431      1.1      tron 
    432      1.1      tron EOF
    433      1.1      tron     exit 1
    434      1.1      tron }
    435      1.1      tron 
    436      1.1      tron POSTCONF="$command_directory/postconf"
    437      1.1      tron 
    438      1.1      tron # Save settings, allowing command line/environment override.
    439      1.1      tron 
    440      1.2  christos # Undo MAIL_VERSION expansion at the end of a parameter value. If
    441      1.2  christos # someone really wants the expanded mail version in main.cf, then
    442      1.2  christos # we're sorry.
    443      1.2  christos 
    444      1.2  christos # Confine side effects from mail_version unexpansion within a subshell.
    445      1.2  christos 
    446      1.2  christos (case "$mail_version" in
    447      1.2  christos "") mail_version="`$POSTCONF -dhx mail_version`" || exit 1
    448      1.2  christos esac
    449      1.2  christos 
    450      1.2  christos for name in $MOST_PARAMETERS
    451      1.2  christos do
    452      1.2  christos     eval junk=\$$name
    453      1.2  christos     case "$junk" in
    454      1.2  christos     *"$mail_version"*) 
    455      1.2  christos 	case "$pattern" in
    456      1.2  christos 	"") pattern=`echo "$mail_version" | sed 's/\./\\\\./g'` || exit 1
    457      1.2  christos 	esac
    458      1.2  christos 	val=`echo "$junk" | sed "s/$pattern"'$/${mail_version}/g'` || exit 1
    459      1.2  christos 	eval ${name}='"$val"'
    460      1.2  christos     esac
    461      1.2  christos done
    462      1.2  christos 
    463      1.2  christos # XXX Maybe update main.cf only with first install, upgrade, set
    464      1.2  christos # permissions, and what else? Should there be a warning otherwise?
    465      1.2  christos 
    466      1.1      tron override=
    467      1.1      tron for name in $MOST_PARAMETERS
    468      1.1      tron do
    469      1.2  christos     eval junk=\"\$$name\"
    470  1.4.4.1  perseant     test "$junk" = "`$POSTCONF -qc $config_directory -h $name`" || {
    471      1.1      tron 	override=1
    472      1.1      tron 	break
    473      1.1      tron     }
    474      1.1      tron done
    475      1.1      tron 
    476      1.1      tron test -n "$override" && {
    477  1.4.4.1  perseant     $POSTCONF -qc $config_directory -e \
    478      1.1      tron 	"daemon_directory = $daemon_directory" \
    479      1.1      tron 	"command_directory = $command_directory" \
    480      1.1      tron 	"queue_directory = $queue_directory" \
    481      1.1      tron 	"data_directory = $data_directory" \
    482      1.1      tron 	"mail_owner = $mail_owner" \
    483      1.1      tron 	"setgid_group = $setgid_group" \
    484      1.1      tron 	"sendmail_path = $sendmail_path" \
    485      1.1      tron 	"mailq_path = $mailq_path" \
    486      1.1      tron 	"newaliases_path = $newaliases_path" \
    487      1.1      tron 	"html_directory = $html_directory" \
    488      1.1      tron 	"manpage_directory = $manpage_directory" \
    489      1.1      tron 	"sample_directory = $sample_directory" \
    490      1.1      tron 	"readme_directory = $readme_directory" \
    491      1.2  christos 	"shlib_directory = $shlib_directory" \
    492      1.2  christos 	"meta_directory = $meta_directory" \
    493      1.1      tron     || exit 1
    494      1.2  christos } || exit 0) || exit 1
    495      1.1      tron 
    496      1.2  christos # Use file/directory status information in $meta_directory/postfix-files.
    497      1.1      tron 
    498      1.1      tron test -n "$create" && {
    499      1.2  christos     postfix_files_d=$meta_directory/postfix-files.d
    500      1.2  christos     for postfix_file in $meta_directory/postfix-files \
    501      1.2  christos 	`test -d $postfix_files_d && { find $postfix_files_d -type f | sort; }`
    502      1.1      tron     do
    503      1.2  christos 	exec <$postfix_file || exit 1
    504      1.2  christos 	while IFS=: read path type owner group mode flags junk
    505      1.1      tron 	do
    506      1.2  christos 	    IFS="$BACKUP_IFS"
    507      1.2  christos 	    set_permission=
    508      1.2  christos 	    # Skip comments. Skip shared files, if updating a secondary instance.
    509      1.2  christos 	    case $path in
    510      1.2  christos 	    [$]*) case "$update_shared_files" in
    511      1.2  christos 		  1) $debug keep non-shared or shared $path;;
    512      1.2  christos 		  *) non_shared=
    513      1.2  christos 		     for name in $NON_SHARED
    514      1.2  christos 		     do
    515      1.2  christos 			 case $path in
    516      1.2  christos 			 "\$$name"*) non_shared=1; break;;
    517      1.2  christos 			 esac
    518      1.2  christos 		     done
    519      1.2  christos 		     case "$non_shared" in
    520      1.2  christos 		      1) $debug keep non-shared $path;;
    521      1.2  christos 		      *) $debug skip shared $path; continue;;
    522      1.2  christos 		     esac;;
    523      1.2  christos 		  esac;;
    524      1.2  christos 	       *) continue;;
    525      1.1      tron 	    esac
    526      1.2  christos 	    # Skip hard links and symbolic links.
    527      1.2  christos 	    case $type in
    528      1.2  christos 	    [hl]) continue;;
    529      1.2  christos 	    [df]) ;;
    530      1.2  christos 	       *) echo unknown type $type for $path in $postfix_file 1>&2; exit 1;;
    531      1.2  christos 	    esac
    532      1.2  christos 	    # Expand $name, and canonicalize null fields.
    533      1.2  christos 	    for name in path owner group flags
    534      1.2  christos 	    do
    535      1.2  christos 		eval junk=\${$name}
    536      1.2  christos 		case $junk in
    537      1.2  christos 		[$]*) eval $name=$junk;;
    538      1.2  christos 		   -) eval $name=;;
    539      1.2  christos 		   *) ;;
    540      1.2  christos 		esac
    541      1.2  christos 	    done
    542      1.2  christos 	    # Skip uninstalled files.
    543      1.2  christos 	    case $path in
    544      1.2  christos 	    no|no/*) continue;;
    545      1.2  christos 	    esac
    546      1.2  christos 	    # Pick up the flags.
    547      1.2  christos 	    case $flags in *u*) upgrade_flag=1;; *) upgrade_flag=;; esac
    548      1.2  christos 	    case $flags in *c*) create_flag=1;; *) create_flag=;; esac
    549      1.2  christos 	    case $flags in *r*) recursive="-R";; *) recursive=;; esac
    550      1.2  christos 	    case $flags in *o*) obsolete_flag=1;; *) obsolete_flag=;; esac
    551      1.2  christos 	    case $flags in *[1i]*) test ! -r "$path" -a "$config_directory" != \
    552      1.2  christos 				    "$def_config_directory" && continue;; esac
    553      1.2  christos 	    # Flag obsolete objects. XXX Solaris 2..9 does not have "test -e".
    554      1.2  christos 	    if [ -n "$obsolete_flag" ]
    555      1.1      tron 	    then
    556      1.2  christos 		test -r $path -a "$type" != "d" && obsolete="$obsolete $path"
    557      1.2  christos 		continue;
    558      1.1      tron 	    else
    559      1.2  christos 		keep_list="$keep_list $path"
    560      1.2  christos 	    fi
    561      1.2  christos 	    # Create missing directories with proper owner/group/mode settings.
    562      1.2  christos 	    if [ -n "$create" -a "$type" = "d" -a -n "$create_flag" -a ! -d "$path" ]
    563      1.2  christos 	    then
    564      1.2  christos 		mkdir $path || exit 1
    565      1.2  christos 		set_permission=1
    566      1.2  christos 	    # Update all owner/group/mode settings.
    567      1.2  christos 	    elif [ -n "$set_perms" ]
    568      1.2  christos 	    then
    569      1.2  christos 		set_permission=1
    570      1.2  christos 	    # Update obsolete owner/group/mode settings.
    571      1.2  christos 	    elif [ -n "$upgrade_perms" -a -n "$upgrade_flag" ]
    572      1.2  christos 	    then
    573      1.2  christos 		set_permission=1
    574      1.2  christos 	    fi
    575      1.2  christos 	    test -n "$set_permission" && {
    576      1.2  christos 		chown $recursive $owner $path || exit 1
    577      1.2  christos 		test -z "$group" || chgrp $recursive $group $path || exit 1
    578      1.2  christos 		# Don't "chmod -R"; queue file status is encoded in mode bits.
    579      1.2  christos 		if [ "$type" = "d" -a -n "$recursive" ]
    580      1.2  christos 		then
    581      1.2  christos 		    find $path -type d -exec chmod $mode "{}" ";"
    582      1.2  christos 		else
    583      1.2  christos 		    chmod $mode $path
    584      1.2  christos 		fi || exit 1
    585      1.2  christos 	    }
    586      1.2  christos 	done
    587      1.2  christos 	IFS="$BACKUP_IFS"
    588      1.1      tron     done
    589      1.1      tron }
    590      1.1      tron 
    591      1.1      tron # Upgrade existing Postfix configuration files if necessary.
    592      1.1      tron 
    593      1.1      tron test -n "$upgrade_conf" && {
    594      1.1      tron 
    595      1.1      tron     # Postfix 2.0.
    596      1.1      tron     # Add missing relay service to master.cf.
    597      1.1      tron 
    598      1.1      tron     grep '^relay' $config_directory/master.cf >/dev/null || {
    599      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for relay service
    600      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    601      1.1      tron relay	  unix	-	-	n	-	-	smtp
    602      1.1      tron EOF
    603      1.1      tron     }
    604      1.1      tron 
    605      1.1      tron     # Postfix 1.1.
    606      1.1      tron     # Add missing flush service to master.cf.
    607      1.1      tron 
    608      1.1      tron     grep '^flush.*flush' $config_directory/master.cf >/dev/null || {
    609      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for flush service
    610      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    611      1.1      tron flush     unix  -       -       n       1000?   0       flush
    612      1.1      tron EOF
    613      1.1      tron     }
    614      1.1      tron 
    615      1.1      tron     # Postfix 2.1.
    616      1.1      tron     # Add missing trace service to master.cf.
    617      1.1      tron 
    618      1.1      tron     grep 'trace.*bounce' $config_directory/master.cf >/dev/null || {
    619      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for trace service
    620      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    621      1.1      tron trace	  unix	-	-	n	-	0	bounce
    622      1.1      tron EOF
    623      1.1      tron     }
    624      1.1      tron 
    625      1.1      tron     # Postfix 2.1.
    626      1.1      tron     # Add missing verify service to master.cf.
    627      1.1      tron 
    628      1.1      tron     grep '^verify.*verify' $config_directory/master.cf >/dev/null || {
    629      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for verify service
    630      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    631      1.1      tron verify	  unix	-	-	n	-	1	verify
    632      1.1      tron EOF
    633      1.1      tron     }
    634      1.1      tron 
    635      1.1      tron     # Postfix 2.1.
    636      1.1      tron     # Fix verify service process limit.
    637      1.1      tron 
    638      1.1      tron     grep '^verify.*[ 	]0[ 	]*verify' \
    639      1.1      tron 	$config_directory/master.cf >/dev/null && {
    640      1.1      tron 	    echo Editing $config_directory/master.cf, setting verify process limit to 1
    641      1.1      tron 	    ed $config_directory/master.cf <<EOF || exit 1
    642      1.1      tron /^verify.*[ 	]0[ 	]*verify/
    643      1.1      tron s/\([ 	]\)0\([ 	]\)/\11\2/
    644      1.1      tron p
    645      1.1      tron w
    646      1.1      tron q
    647      1.1      tron EOF
    648      1.1      tron     }
    649      1.1      tron 
    650      1.1      tron     # Postfix 1.1.
    651      1.1      tron     # Change privileged pickup service into unprivileged.
    652      1.1      tron 
    653      1.1      tron     grep "^pickup[ 	]*fifo[ 	]*n[ 	]*n" \
    654      1.1      tron 	$config_directory/master.cf >/dev/null && {
    655      1.1      tron 	    echo Editing $config_directory/master.cf, making the pickup service unprivileged
    656      1.1      tron 	    ed $config_directory/master.cf <<EOF || exit 1
    657      1.1      tron /^pickup[ 	]*fifo[ 	]*n[ 	]*n/
    658      1.1      tron s/\(n[ 	]*\)n/\1-/
    659      1.1      tron p
    660      1.1      tron w
    661      1.1      tron q
    662      1.1      tron EOF
    663      1.1      tron     }
    664      1.1      tron 
    665      1.1      tron     # Postfix 1.1.
    666      1.1      tron     # Change private cleanup and flush services into public.
    667      1.1      tron 
    668      1.1      tron     for name in cleanup flush
    669      1.1      tron     do
    670      1.1      tron 	grep "^$name[ 	]*unix[ 	]*[-y]" \
    671      1.1      tron 	    $config_directory/master.cf >/dev/null && {
    672      1.1      tron 		echo Editing $config_directory/master.cf, making the $name service public
    673      1.1      tron 	    ed $config_directory/master.cf <<EOF || exit 1
    674      1.1      tron /^$name[ 	]*unix[ 	]*[-y]/
    675      1.1      tron s/[-y]/n/
    676      1.1      tron p
    677      1.1      tron w
    678      1.1      tron q
    679      1.1      tron EOF
    680      1.1      tron 	}
    681      1.1      tron     done
    682      1.1      tron 
    683      1.1      tron     # Postfix 2.2.
    684      1.1      tron     # File systems have improved since Postfix came out, and all we
    685      1.1      tron     # require now is that defer and deferred are hashed because those
    686      1.1      tron     # can contain lots of files.
    687      1.1      tron 
    688  1.4.4.1  perseant     found=`$POSTCONF -qc $config_directory -h hash_queue_names`
    689      1.1      tron     missing=
    690      1.1      tron     (echo "$found" | grep defer >/dev/null)  || missing="$missing defer"
    691      1.1      tron     (echo "$found" | grep deferred>/dev/null)|| missing="$missing deferred"
    692      1.1      tron     test -n "$missing" && {
    693      1.1      tron 	echo fixing main.cf hash_queue_names for missing $missing
    694  1.4.4.1  perseant 	$POSTCONF -qc $config_directory -e hash_queue_names="$found$missing" ||
    695      1.1      tron 	    exit 1
    696      1.1      tron     }
    697      1.1      tron 
    698      1.1      tron     # Turn on safety nets for new features that could bounce mail that
    699      1.1      tron     # would be accepted by a previous Postfix version.
    700      1.1      tron 
    701      1.1      tron     # [The "unknown_local_recipient_reject_code = 450" safety net,
    702      1.1      tron     # introduced with Postfix 2.0 and deleted after Postfix 2.3.]
    703      1.1      tron 
    704      1.1      tron     # Postfix 2.0.
    705      1.1      tron     # Add missing proxymap service to master.cf.
    706      1.1      tron 
    707      1.1      tron     grep '^proxymap.*proxymap' $config_directory/master.cf >/dev/null || {
    708      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for proxymap service
    709      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    710      1.1      tron proxymap  unix	-	-	n	-	-	proxymap
    711      1.1      tron EOF
    712      1.1      tron     }
    713      1.1      tron 
    714      1.1      tron     # Postfix 2.1.
    715      1.1      tron     # Add missing anvil service to master.cf.
    716      1.1      tron 
    717      1.1      tron     grep '^anvil.*anvil' $config_directory/master.cf >/dev/null || {
    718      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for anvil service
    719      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    720      1.1      tron anvil	  unix	-	-	n	-	1	anvil
    721      1.1      tron EOF
    722      1.1      tron     }
    723      1.1      tron 
    724      1.1      tron     # Postfix 2.2.
    725      1.1      tron     # Add missing scache service to master.cf.
    726      1.1      tron 
    727      1.1      tron     grep '^scache.*scache' $config_directory/master.cf >/dev/null || {
    728      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for scache service
    729      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    730      1.1      tron scache	  unix	-	-	n	-	1	scache
    731      1.1      tron EOF
    732      1.1      tron     }
    733      1.1      tron 
    734      1.1      tron     # Postfix 2.2.
    735      1.1      tron     # Add missing discard service to master.cf.
    736      1.1      tron 
    737      1.1      tron     grep '^discard.*discard' $config_directory/master.cf >/dev/null || {
    738      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for discard service
    739      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    740      1.1      tron discard	  unix	-	-	n	-	-	discard
    741      1.1      tron EOF
    742      1.1      tron     }
    743      1.1      tron 
    744      1.1      tron     # Postfix 2.2.
    745      1.1      tron     # Update the tlsmgr fifo->unix service.
    746      1.1      tron 
    747      1.1      tron     grep "^tlsmgr[ 	]*fifo[ 	]" \
    748      1.1      tron 	$config_directory/master.cf >/dev/null && {
    749      1.1      tron 	    echo Editing $config_directory/master.cf, updating the tlsmgr from fifo to unix service
    750      1.1      tron 	    ed $config_directory/master.cf <<EOF || exit 1
    751      1.1      tron /^tlsmgr[ 	]*fifo[ 	]/
    752      1.1      tron s/fifo/unix/
    753      1.1      tron s/[0-9][0-9]*/&?/
    754      1.1      tron p
    755      1.1      tron w
    756      1.1      tron q
    757      1.1      tron EOF
    758      1.1      tron     }
    759      1.1      tron 
    760      1.1      tron     # Postfix 2.2.
    761      1.1      tron     # Add missing tlsmgr service to master.cf.
    762      1.1      tron 
    763      1.1      tron     grep '^tlsmgr.*tlsmgr' $config_directory/master.cf >/dev/null || {
    764      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for tlsmgr service
    765      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    766      1.1      tron tlsmgr    unix  -       -       n       1000?   1       tlsmgr
    767      1.1      tron EOF
    768      1.1      tron     }
    769      1.1      tron 
    770      1.1      tron     # Postfix 2.2.
    771      1.1      tron     # Add missing retry service to master.cf.
    772      1.1      tron 
    773      1.1      tron     grep '^retry.*error' $config_directory/master.cf >/dev/null || {
    774      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for retry service
    775      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    776      1.1      tron retry     unix  -       -       n       -       -       error
    777      1.1      tron EOF
    778      1.1      tron     }
    779      1.1      tron 
    780      1.1      tron     # Postfix 2.5.
    781      1.1      tron     # Add missing proxywrite service to master.cf.
    782      1.1      tron 
    783      1.1      tron     grep '^proxywrite.*proxymap' $config_directory/master.cf >/dev/null || {
    784      1.1      tron 	echo Editing $config_directory/master.cf, adding missing entry for proxywrite service
    785      1.1      tron 	cat >>$config_directory/master.cf <<EOF || exit 1
    786      1.1      tron proxywrite unix -       -       n       -       1       proxymap
    787      1.1      tron EOF
    788      1.1      tron     }
    789      1.1      tron 
    790      1.1      tron     # Postfix 2.5.
    791      1.1      tron     # Fix a typo in the default master.cf proxywrite entry.
    792      1.1      tron 
    793      1.1      tron     grep '^proxywrite.*-[ 	]*proxymap' $config_directory/master.cf >/dev/null && {
    794      1.1      tron 	echo Editing $config_directory/master.cf, setting proxywrite process limit to 1
    795      1.1      tron 	    ed $config_directory/master.cf <<EOF || exit 1
    796      1.1      tron /^proxywrite.*-[ 	]*proxymap/
    797      1.1      tron s/-\([ 	]*proxymap\)/1\1/
    798      1.1      tron p
    799      1.1      tron w
    800      1.1      tron q
    801      1.1      tron EOF
    802      1.1      tron     }
    803      1.1      tron 
    804      1.2  christos     # Postfix 2.8.
    805      1.2  christos     # Add missing postscreen service to master.cf.
    806      1.2  christos 
    807      1.2  christos     grep '^#*smtp.*postscreen' $config_directory/master.cf >/dev/null || {
    808      1.2  christos 	echo Editing $config_directory/master.cf, adding missing entry for postscreen TCP service
    809      1.2  christos 	cat >>$config_directory/master.cf <<EOF || exit 1
    810      1.2  christos #smtp      inet  n       -       n       -       1       postscreen
    811      1.2  christos EOF
    812      1.2  christos     }
    813      1.2  christos 
    814      1.2  christos     # Postfix 2.8.
    815      1.2  christos     # Add missing smtpd (unix-domain) service to master.cf.
    816      1.2  christos 
    817      1.2  christos     grep '^#*smtpd.*smtpd' $config_directory/master.cf >/dev/null || {
    818      1.2  christos 	echo Editing $config_directory/master.cf, adding missing entry for smtpd unix-domain service
    819      1.2  christos 	cat >>$config_directory/master.cf <<EOF || exit 1
    820      1.2  christos #smtpd     pass  -       -       n       -       -       smtpd
    821      1.2  christos EOF
    822      1.2  christos     }
    823      1.2  christos 
    824      1.2  christos     # Postfix 2.8.
    825      1.2  christos     # Add temporary dnsblog (unix-domain) service to master.cf.
    826      1.2  christos 
    827      1.2  christos     grep '^#*dnsblog.*dnsblog' $config_directory/master.cf >/dev/null || {
    828      1.2  christos 	echo Editing $config_directory/master.cf, adding missing entry for dnsblog unix-domain service
    829      1.2  christos 	cat >>$config_directory/master.cf <<EOF || exit 1
    830      1.2  christos #dnsblog   unix  -       -       n       -       0       dnsblog
    831      1.2  christos EOF
    832      1.2  christos     }
    833      1.2  christos 
    834      1.2  christos     # Postfix 2.8.
    835      1.2  christos     # Add tlsproxy (unix-domain) service to master.cf.
    836      1.2  christos 
    837      1.2  christos     grep '^#*tlsproxy.*tlsproxy' $config_directory/master.cf >/dev/null || {
    838      1.2  christos 	echo Editing $config_directory/master.cf, adding missing entry for tlsproxy unix-domain service
    839      1.2  christos 	cat >>$config_directory/master.cf <<EOF || exit 1
    840      1.2  christos #tlsproxy  unix  -       -       n       -       0       tlsproxy
    841      1.2  christos EOF
    842      1.2  christos     }
    843      1.2  christos 
    844      1.1      tron     # Report (but do not remove) obsolete files.
    845      1.1      tron 
    846      1.1      tron     test -n "$obsolete" && {
    847      1.1      tron 	cat <<EOF | ${FMT}
    848      1.1      tron 
    849      1.1      tron     Note: the following files or directories still exist but are
    850      1.1      tron     no longer part of Postfix:
    851      1.1      tron 
    852      1.1      tron     $obsolete
    853      1.1      tron 
    854      1.1      tron EOF
    855      1.1      tron     }
    856      1.1      tron 
    857      1.2  christos     # Postfix 2.9.
    858      1.2  christos     # Safety net for incompatible changes in IPv6 defaults.
    859      1.2  christos     # PLEASE DO NOT REMOVE THIS CODE. ITS PURPOSE IS TO AVOID AN
    860      1.2  christos     # UNEXPECTED DROP IN PERFORMANCE AFTER UPGRADING FROM POSTFIX
    861      1.2  christos     # BEFORE 2.9.
    862      1.2  christos     # This code assumes that the default is "inet_protocols = ipv4"
    863      1.2  christos     # when IPv6 support is not compiled in. See util/sys_defs.h.
    864      1.2  christos 
    865      1.2  christos     test "`$POSTCONF -dh inet_protocols`" = "ipv4" ||
    866  1.4.4.1  perseant 	test -n "`$POSTCONF -qc $config_directory -n inet_protocols`" || {
    867      1.2  christos 	cat <<EOF | ${FMT}
    868      1.2  christos     COMPATIBILITY: editing $config_directory/main.cf, setting
    869      1.2  christos     inet_protocols=ipv4.  Specify inet_protocols explicitly if you
    870      1.2  christos     want to enable IPv6.
    871      1.2  christos     In a future release IPv6 will be enabled by default.
    872      1.2  christos EOF
    873  1.4.4.1  perseant 	$POSTCONF -qc $config_directory inet_protocols=ipv4 || exit 1
    874      1.2  christos     }
    875      1.2  christos 
    876      1.2  christos # Disabled because unhelpful down-stream maintainers disable the safety net.
    877      1.2  christos #    # Postfix 2.10.
    878      1.2  christos #    # Safety net for incompatible changes due to the introduction
    879      1.2  christos #    # of the smtpd_relay_restrictions feature to separate the
    880      1.2  christos #    # mail relay policy from the spam blocking policy.
    881      1.2  christos #    # PLEASE DO NOT REMOVE THIS CODE. ITS PURPOSE IS TO PREVENT
    882      1.2  christos #    # INBOUND MAIL FROM UNEXPECTEDLY BOUNCING AFTER UPGRADING FROM
    883      1.2  christos #    # POSTFIX BEFORE 2.10.
    884  1.4.4.1  perseant #    test -n "`$POSTCONF -qc $config_directory -n smtpd_relay_restrictions`" || {
    885      1.2  christos #	cat <<EOF | ${FMT}
    886      1.2  christos #    COMPATIBILITY: editing $config_directory/main.cf, overriding
    887      1.2  christos #    smtpd_relay_restrictions to prevent inbound mail from
    888      1.2  christos #    unexpectedly bouncing.
    889      1.2  christos #    Specify an empty smtpd_relay_restrictions value to keep using 
    890      1.2  christos #    smtpd_recipient_restrictions as before.
    891      1.2  christos #EOF
    892  1.4.4.1  perseant #	$POSTCONF -qc $config_directory "smtpd_relay_restrictions = \
    893      1.2  christos #	    permit_mynetworks permit_sasl_authenticated \
    894      1.2  christos #	    defer_unauth_destination" || exit 1
    895      1.2  christos #    }
    896      1.3  christos 
    897      1.3  christos     # Postfix 3.4
    898      1.3  christos     # Add a postlog service entry.
    899      1.3  christos 
    900      1.3  christos     grep '^postlog' $config_directory/master.cf >/dev/null || {
    901      1.3  christos 	echo Editing $config_directory/master.cf, adding missing entry for postlog unix-domain datagram service
    902      1.3  christos 	cat >>$config_directory/master.cf <<EOF || exit 1
    903      1.3  christos postlog   unix-dgram n  -       n       -       1       postlogd
    904      1.3  christos EOF
    905      1.3  christos     }
    906      1.1      tron }
    907      1.1      tron 
    908      1.1      tron # A reminder if this is the first time Postfix is being installed.
    909      1.1      tron 
    910      1.1      tron test -n "$first_install_reminder" && {
    911      1.1      tron 
    912  1.4.4.1  perseant     ALIASES=`$POSTCONF -qc $config_directory -h alias_database | sed 's/^[^:]*://'`
    913  1.4.4.1  perseant     NEWALIASES_PATH=`$POSTCONF -qc $config_directory -h newaliases_path`
    914      1.1      tron     cat <<EOF | ${FMT}
    915      1.1      tron 
    916      1.1      tron     Warning: you still need to edit myorigin/mydestination/mynetworks
    917      1.1      tron     parameter settings in $config_directory/main.cf.
    918      1.1      tron 
    919  1.4.4.1  perseant     See also https://www.postfix.org/STANDARD_CONFIGURATION_README.html
    920      1.1      tron     for information about dialup sites or about sites inside a
    921      1.1      tron     firewalled network.
    922      1.1      tron 
    923      1.1      tron     BTW: Check your $ALIASES file and be sure to set up aliases
    924      1.1      tron     that send mail for root and postmaster to a real person, then
    925      1.1      tron     run $NEWALIASES_PATH.
    926      1.1      tron 
    927      1.1      tron EOF
    928      1.1      tron 
    929      1.1      tron }
    930      1.1      tron 
    931      1.1      tron exit 0
    932