141fbaed0Stron#!/bin/sh
2*fb52cf35Schristos#	$NetBSD: post-install,v 1.4 2022/10/08 16:12:43 christos Exp $
341fbaed0Stron#
441fbaed0Stron
541fbaed0Stron# To view the formatted manual page of this file, type:
641fbaed0Stron#	POSTFIXSOURCE/mantools/srctoman - post-install | nroff -man
741fbaed0Stron
841fbaed0Stron#++
941fbaed0Stron# NAME
1041fbaed0Stron#	post-install
1141fbaed0Stron# SUMMARY
1241fbaed0Stron#	Postfix post-installation script
1341fbaed0Stron# SYNOPSIS
1441fbaed0Stron#	postfix post-install [name=value] command ...
1541fbaed0Stron# DESCRIPTION
1641fbaed0Stron#	The post-install script performs the finishing touch of a Postfix
1741fbaed0Stron#	installation, after the executable programs and configuration
1841fbaed0Stron#	files are installed. Usage is one of the following:
1941fbaed0Stron# .IP o
2041fbaed0Stron#	While installing Postfix from source code on the local machine, the
2141fbaed0Stron#	script is run by the postfix-install script to update selected file
2241fbaed0Stron#	or directory permissions and to update Postfix configuration files.
2341fbaed0Stron# .IP o
2441fbaed0Stron#	While installing Postfix from a pre-built package, the script is run
2541fbaed0Stron#	by the package management procedure to set all file or directory
2641fbaed0Stron#	permissions and to update Postfix configuration files.
2741fbaed0Stron# .IP o
2841fbaed0Stron#	The script can be used to change installation parameter settings such
2941fbaed0Stron#	as mail_owner or setgid_group after Postfix is already installed.
3041fbaed0Stron# .IP o
3141fbaed0Stron#	The script can be used to upgrade configuration files and to upgrade
3241fbaed0Stron#	file/directory permissions of a secondary Postfix instance.
3341fbaed0Stron# .IP o
3441fbaed0Stron#	At Postfix start-up time, the script is run from "postfix check" to
3541fbaed0Stron#	create missing queue directories.
3641fbaed0Stron# .PP
3741fbaed0Stron#	The post-install script is controlled by installation parameters.
3841fbaed0Stron#	Specific parameters are described at the end of this document.
3941fbaed0Stron#	All installation parameters must be specified ahead of time via
4041fbaed0Stron#	one of the methods described below.
4141fbaed0Stron#
4241fbaed0Stron#	Arguments
4341fbaed0Stron# .IP create-missing
4441fbaed0Stron#	Create missing queue directories with ownerships and permissions
45837e7c1aSchristos#	according to the contents of $meta_directory/postfix-files
46837e7c1aSchristos#	and optionally in $meta_directory/postfix-files.d/*, using
472e5cb688Stron#	the mail_owner and setgid_group parameter settings from the
482e5cb688Stron#	command line, process environment or from the installed
492e5cb688Stron#	main.cf file.
5041fbaed0Stron#
5141fbaed0Stron#	This is required at Postfix start-up time.
5241fbaed0Stron# .IP set-permissions
5341fbaed0Stron#	Set all file/directory ownerships and permissions according to the
54837e7c1aSchristos#	contents of $meta_directory/postfix-files and optionally
55837e7c1aSchristos#	in $meta_directory/postfix-files.d/*, using the mail_owner
562e5cb688Stron#	and setgid_group parameter settings from the command line,
572e5cb688Stron#	process environment or from the installed main.cf file.
582e5cb688Stron#	Implies create-missing.
5941fbaed0Stron#
6041fbaed0Stron#	This is required when installing Postfix from a pre-built package,
6141fbaed0Stron#	or when changing the mail_owner or setgid_group installation parameter
6241fbaed0Stron#	settings after Postfix is already installed.
6341fbaed0Stron# .IP upgrade-permissions
6441fbaed0Stron#	Update ownership and permission of existing files/directories as
65837e7c1aSchristos#	specified in $meta_directory/postfix-files and optionally
66837e7c1aSchristos#	in $meta_directory/postfix-files.d/*, using the mail_owner
672e5cb688Stron#	and setgid_group parameter settings from the command line,
682e5cb688Stron#	process environment or from the installed main.cf file.
692e5cb688Stron#	Implies create-missing.
7041fbaed0Stron#
7141fbaed0Stron#	This is required when upgrading an existing Postfix instance.
7241fbaed0Stron# .IP upgrade-configuration
7341fbaed0Stron#	Edit the installed main.cf and master.cf files, in order to account
7441fbaed0Stron#	for missing services and to fix deprecated parameter settings.
7541fbaed0Stron#
7641fbaed0Stron#	This is required when upgrading an existing Postfix instance.
7741fbaed0Stron# .IP upgrade-source
7841fbaed0Stron#	Short-hand for: upgrade-permissions upgrade-configuration.
7941fbaed0Stron#
8041fbaed0Stron#	This is recommended when upgrading Postfix from source code.
8141fbaed0Stron# .IP upgrade-package
8241fbaed0Stron#	Short-hand for: set-permissions upgrade-configuration.
8341fbaed0Stron#
8441fbaed0Stron#	This is recommended when upgrading Postfix from a pre-built package.
8541fbaed0Stron# .IP first-install-reminder
8641fbaed0Stron#	Remind the user that they still need to configure main.cf and the
8741fbaed0Stron#	aliases file, and that newaliases still needs to be run.
8841fbaed0Stron#
8941fbaed0Stron#	This is recommended when Postfix is installed for the first time.
9041fbaed0Stron# MULTIPLE POSTFIX INSTANCES
9141fbaed0Stron# .ad
9241fbaed0Stron# .fi
9341fbaed0Stron#	Multiple Postfix instances on the same machine can share command and
9441fbaed0Stron#	daemon program files but must have separate configuration and queue
9541fbaed0Stron#	directories.
9641fbaed0Stron#
9741fbaed0Stron#	To create a secondary Postfix installation on the same machine,
9841fbaed0Stron#	copy the configuration files from the primary Postfix instance to
9941fbaed0Stron#	a secondary configuration directory and execute:
10041fbaed0Stron#
10141fbaed0Stron#	postfix post-install config_directory=secondary-config-directory \e
10241fbaed0Stron# .in +4
10341fbaed0Stron#		queue_directory=secondary-queue-directory \e
10441fbaed0Stron# .br
10541fbaed0Stron#		create-missing
10641fbaed0Stron# .PP
10741fbaed0Stron#	This creates secondary Postfix queue directories, sets their access
10841fbaed0Stron#	permissions, and saves the specified installation parameters to the
10941fbaed0Stron#	secondary main.cf file.
11041fbaed0Stron#
11141fbaed0Stron#	Be sure to list the secondary configuration directory in the
11241fbaed0Stron#	alternate_config_directories parameter in the primary main.cf file.
11341fbaed0Stron#
11441fbaed0Stron#	To upgrade a secondary Postfix installation on the same machine,
11541fbaed0Stron#	execute:
11641fbaed0Stron#
11741fbaed0Stron#	postfix post-install config_directory=secondary-config-directory \e
11841fbaed0Stron# .in +4
11941fbaed0Stron#		upgrade-permissions upgrade-configuration
12041fbaed0Stron# INSTALLATION PARAMETER INPUT METHODS
12141fbaed0Stron# .ad
12241fbaed0Stron# .fi
12341fbaed0Stron#	Parameter settings can be specified through a variety of
12441fbaed0Stron#	mechanisms.  In order of decreasing precedence these are:
12541fbaed0Stron# .IP "command line"
12641fbaed0Stron#	Parameter settings can be given as name=value arguments on
12741fbaed0Stron#	the post-install command line. These have the highest precedence.
12841fbaed0Stron#	Settings that override the installed main.cf file are saved.
12941fbaed0Stron# .IP "process environment"
13041fbaed0Stron#	Parameter settings can be given as name=value environment
13141fbaed0Stron#	variables.
13241fbaed0Stron#	Settings that override the installed main.cf file are saved.
13341fbaed0Stron# .IP "installed configuration files"
13441fbaed0Stron#	If a parameter is not specified via the command line or via the
13541fbaed0Stron#	process environment, post-install will attempt to extract its
13641fbaed0Stron#	value from the already installed Postfix main.cf configuration file.
13741fbaed0Stron#	These settings have the lowest precedence.
13841fbaed0Stron# INSTALLATION PARAMETER DESCRIPTION
13941fbaed0Stron# .ad
14041fbaed0Stron# .fi
14141fbaed0Stron#	The description of installation parameters is as follows:
14241fbaed0Stron# .IP config_directory
14341fbaed0Stron#	The directory for Postfix configuration files.
14441fbaed0Stron# .IP daemon_directory
14541fbaed0Stron#	The directory for Postfix daemon programs. This directory
14641fbaed0Stron#	should not be in the command search path of any users.
14741fbaed0Stron# .IP command_directory
14841fbaed0Stron#	The directory for Postfix administrative commands. This
149*fb52cf35Schristos#	directory should be in the command search path of administrative users.
15041fbaed0Stron# .IP queue_directory
15141fbaed0Stron#	The directory for Postfix queues.
15241fbaed0Stron# .IP data_directory
15341fbaed0Stron#	The directory for Postfix writable data files (caches, etc.).
15441fbaed0Stron# .IP sendmail_path
15541fbaed0Stron#	The full pathname for the Postfix sendmail command.
15641fbaed0Stron#	This is the Sendmail-compatible mail posting interface.
15741fbaed0Stron# .IP newaliases_path
15841fbaed0Stron#	The full pathname for the Postfix newaliases command.
15941fbaed0Stron#	This is the Sendmail-compatible command to build alias databases
16041fbaed0Stron#	for the Postfix local delivery agent.
16141fbaed0Stron# .IP mailq_path
16241fbaed0Stron#	The full pathname for the Postfix mailq command.
16341fbaed0Stron#	This is the Sendmail-compatible command to list the mail queue.
16441fbaed0Stron# .IP mail_owner
16541fbaed0Stron#	The owner of the Postfix queue. Its numerical user ID and group ID
16641fbaed0Stron#	must not be used by any other accounts on the system.
16741fbaed0Stron# .IP setgid_group
16841fbaed0Stron#	The group for mail submission and for queue management commands.
16941fbaed0Stron#	Its numerical group ID must not be used by any other accounts on the
17041fbaed0Stron#	system, not even by the mail_owner account.
17141fbaed0Stron# .IP html_directory
17241fbaed0Stron#	The directory for the Postfix HTML files.
17341fbaed0Stron# .IP manpage_directory
17441fbaed0Stron#	The directory for the Postfix on-line manual pages.
17541fbaed0Stron# .IP sample_directory
17641fbaed0Stron#	The directory for the Postfix sample configuration files.
17741fbaed0Stron#	This feature is obsolete as of Postfix 2.1.
17841fbaed0Stron# .IP readme_directory
17941fbaed0Stron#	The directory for the Postfix README files.
180837e7c1aSchristos# .IP shlib_directory
181837e7c1aSchristos#	The directory for the Postfix shared-library files, and for
182837e7c1aSchristos#	the Postfix dabatase plugin files with a relative pathname
183837e7c1aSchristos#	in the file dynamicmaps.cf.
184837e7c1aSchristos# .IP meta_directory
185837e7c1aSchristos#	The directory for non-executable files that are shared
186837e7c1aSchristos#	among multiple Postfix instances, such as postfix-files,
187837e7c1aSchristos#	dynamicmaps.cf, as well as the multi-instance template files
188837e7c1aSchristos#	main.cf.proto and master.cf.proto.
18941fbaed0Stron# SEE ALSO
19041fbaed0Stron#	postfix-install(1) Postfix primary installation script.
19141fbaed0Stron# FILES
19241fbaed0Stron#	$config_directory/main.cf, Postfix installation parameters.
193837e7c1aSchristos#	$meta_directory/postfix-files, installation control file.
194837e7c1aSchristos#	$meta_directory/postfix-files.d/*, optional control files.
19541fbaed0Stron#	$config_directory/install.cf, obsolete configuration file.
19641fbaed0Stron# LICENSE
19741fbaed0Stron# .ad
19841fbaed0Stron# .fi
19941fbaed0Stron#	The Secure Mailer license must be distributed with this software.
20041fbaed0Stron# AUTHOR(S)
20141fbaed0Stron#	Wietse Venema
20241fbaed0Stron#	IBM T.J. Watson Research
20341fbaed0Stron#	P.O. Box 704
20441fbaed0Stron#	Yorktown Heights, NY 10598, USA
2053c275423Schristos#
2063c275423Schristos#	Wietse Venema
2073c275423Schristos#	Google, Inc.
2083c275423Schristos#	111 8th Avenue
2093c275423Schristos#	New York, NY 10011, USA
21041fbaed0Stron#--
21141fbaed0Stron
21241fbaed0Stronumask 022
21341fbaed0Stron
21441fbaed0StronPATH=/bin:/usr/bin:/usr/sbin:/usr/etc:/sbin:/etc:/usr/contrib/bin:/usr/gnu/bin:/usr/ucb:/usr/bsd
21541fbaed0StronSHELL=/bin/sh
21641fbaed0StronIFS="
21741fbaed0Stron"
21841fbaed0StronBACKUP_IFS="$IFS"
21941fbaed0Strondebug=:
22041fbaed0Stron#debug=echo
22141fbaed0StronMOST_PARAMETERS="command_directory daemon_directory data_directory
22241fbaed0Stron    html_directory mail_owner mailq_path manpage_directory
22341fbaed0Stron    newaliases_path queue_directory readme_directory sample_directory
224837e7c1aSchristos    sendmail_path setgid_group shlib_directory meta_directory"
22541fbaed0StronNON_SHARED="config_directory queue_directory data_directory"
22641fbaed0Stron
22741fbaed0StronUSAGE="Usage: $0 [name=value] command
22841fbaed0Stron    create-missing          Create missing queue directories.
22941fbaed0Stron    upgrade-source          When installing or upgrading from source code.
23041fbaed0Stron    upgrade-package         When installing or upgrading from pre-built package.
23141fbaed0Stron    first-install-reminder  Remind of mandatory first-time configuration steps.
23241fbaed0Stron    name=value              Specify an installation parameter".
23341fbaed0Stron
23441fbaed0Stron# Process command-line options and parameter settings. Work around
23541fbaed0Stron# brain damaged shells. "IFS=value command" should not make the
23641fbaed0Stron# IFS=value setting permanent. But some broken standard allows it.
23741fbaed0Stron
23841fbaed0Stroncreate=; set_perms=; upgrade_perms=; upgrade_conf=; first_install_reminder=
23941fbaed0Stronobsolete=; keep_list=;
24041fbaed0Stron
24141fbaed0Stronfor arg
24241fbaed0Strondo
24341fbaed0Stron    case $arg in
244837e7c1aSchristos	*[" 	"]*) echo $0: "Error: argument contains whitespace: '$arg'"
245837e7c1aSchristos		     exit 1;;
24641fbaed0Stron                *=*) IFS= eval $arg; IFS="$BACKUP_IFS";;
24741fbaed0Stron     create-missing) create=1;;
24841fbaed0Stron	  set-perm*) create=1; set_perms=1;;
24941fbaed0Stron      upgrade-perm*) create=1; upgrade_perms=1;;
25041fbaed0Stron      upgrade-conf*) upgrade_conf=1;;
25141fbaed0Stron     upgrade-source) create=1; upgrade_conf=1; upgrade_perms=1;;
25241fbaed0Stron    upgrade-package) create=1; upgrade_conf=1; set_perms=1;;
25341fbaed0Stron     first-install*) first_install_reminder=1;;
25441fbaed0Stron		  *) echo "$0: Error: $USAGE" 1>&2; exit 1;;
25541fbaed0Stron    esac
25641fbaed0Stron    shift
25741fbaed0Strondone
25841fbaed0Stron
25941fbaed0Stron# Sanity checks.
26041fbaed0Stron
26141fbaed0Strontest -n "$create$upgrade_conf$first_install_reminder" || {
26241fbaed0Stron    echo "$0: Error: $USAGE" 1>&2
26341fbaed0Stron    exit 1
26441fbaed0Stron}
26541fbaed0Stron
26641fbaed0Stron# Bootstrapping problem.
26741fbaed0Stron
26841fbaed0Stronif [ -n "$command_directory" ]
26941fbaed0Stronthen
27041fbaed0Stron    POSTCONF="$command_directory/postconf"
27141fbaed0Stronelse
27241fbaed0Stron    POSTCONF="postconf"
27341fbaed0Stronfi
27441fbaed0Stron
27541fbaed0Stron$POSTCONF -d mail_version >/dev/null 2>/dev/null || {
27641fbaed0Stron    echo $0: Error: no $POSTCONF command found. 1>&2
27741fbaed0Stron    echo Re-run this command as $0 command_directory=/some/where. 1>&2
27841fbaed0Stron    exit 1
27941fbaed0Stron}
28041fbaed0Stron
28141fbaed0Stron# Also used to require license etc. files only in the default instance.
28241fbaed0Stron
28341fbaed0Strondef_config_directory=`$POSTCONF -d -h config_directory` || exit 1
28441fbaed0Strontest -n "$config_directory" ||
28541fbaed0Stron    config_directory="$def_config_directory"
28641fbaed0Stron
28741fbaed0Strontest -d "$config_directory" || {
28841fbaed0Stron    echo $0: Error: $config_directory is not a directory. 1>&2
28941fbaed0Stron    exit 1
29041fbaed0Stron}
29141fbaed0Stron
29241fbaed0Stron# If this is a secondary instance, don't touch shared files.
29341fbaed0Stron# XXX Solaris does not have "test -e".
29441fbaed0Stron
29541fbaed0Stroninstances=`test ! -f $def_config_directory/main.cf ||
29641fbaed0Stron    $POSTCONF -c $def_config_directory -h multi_instance_directories |
29741fbaed0Stron	sed 's/,/ /'` || exit 1
29841fbaed0Stron
29941fbaed0Stronupdate_shared_files=1
30041fbaed0Stronfor name in $instances
30141fbaed0Strondo
30241fbaed0Stron    case "$name" in
30341fbaed0Stron    "$def_config_directory") ;;
30441fbaed0Stron    "$config_directory") update_shared_files=; break;;
30541fbaed0Stron    esac
30641fbaed0Strondone
30741fbaed0Stron
308837e7c1aSchristostest -f $meta_directory/postfix-files || {
309837e7c1aSchristos    echo $0: Error: $meta_directory/postfix-files is not a file. 1>&2
31041fbaed0Stron    exit 1
31141fbaed0Stron}
31241fbaed0Stron
31341fbaed0Stron# SunOS5 fmt(1) truncates lines > 1000 characters.
31441fbaed0Stron
31541fbaed0Stronfake_fmt() {
31641fbaed0Stron    sed '
31741fbaed0Stron    :top
31841fbaed0Stron	/^\(  *\)\([^ ][^ ]*\)  */{
31941fbaed0Stron	    s//\1\2\
32041fbaed0Stron\1/
32141fbaed0Stron	    P
32241fbaed0Stron	    D
32341fbaed0Stron	    b top
32441fbaed0Stron	}
32541fbaed0Stron    ' | fmt
32641fbaed0Stron}
32741fbaed0Stron
32841fbaed0Stroncase `uname -s` in
32941fbaed0StronHP-UX*) FMT=cat;;
33041fbaed0StronSunOS*) FMT=fake_fmt;;
33141fbaed0Stron     *) FMT=fmt;;
33241fbaed0Stronesac
33341fbaed0Stron
33441fbaed0Stron# If a parameter is not set via the command line or environment,
33541fbaed0Stron# try to use settings from installed configuration files.
33641fbaed0Stron
33741fbaed0Stron# Extract parameter settings from the obsolete install.cf file, as
33841fbaed0Stron# a transitional aid.
33941fbaed0Stron
34041fbaed0Strongrep setgid_group $config_directory/main.cf >/dev/null 2>&1 || {
34141fbaed0Stron    test -f $config_directory/install.cf  && {
34241fbaed0Stron        for name in sendmail_path newaliases_path mailq_path setgid manpages
34341fbaed0Stron        do
34441fbaed0Stron	eval junk=\$$name
34541fbaed0Stron        case "$junk" in
34641fbaed0Stron        "") eval unset $name;;
34741fbaed0Stron        esac
34841fbaed0Stron	   eval : \${$name="\`. $config_directory/install.cf; echo \$$name\`"} \
34941fbaed0Stron		|| exit 1
35041fbaed0Stron        done
35141fbaed0Stron        : ${setgid_group=$setgid}
35241fbaed0Stron        : ${manpage_directory=$manpages}
35341fbaed0Stron    }
35441fbaed0Stron}
35541fbaed0Stron
35641fbaed0Stron# Extract parameter settings from the installed main.cf file.
35741fbaed0Stron
35841fbaed0Strontest -f $config_directory/main.cf && {
35941fbaed0Stron    for name in $MOST_PARAMETERS
36041fbaed0Stron    do
36141fbaed0Stron	eval junk=\$$name
36241fbaed0Stron        case "$junk" in
36341fbaed0Stron        "") eval unset $name;;
36441fbaed0Stron        esac
36541fbaed0Stron        eval : \${$name=\`$POSTCONF -c $config_directory -h $name\`} || exit 1
36641fbaed0Stron    done
36741fbaed0Stron}
36841fbaed0Stron
36941fbaed0Stron# Sanity checks
37041fbaed0Stron
37141fbaed0Stroncase $manpage_directory in
37241fbaed0Stron no) echo $0: Error: manpage_directory no longer accepts \"no\" values. 1>&2
37341fbaed0Stron     echo Try again with \"$0 manpage_directory=/pathname ...\". 1>&2; exit 1;;
37441fbaed0Stronesac
37541fbaed0Stron
37641fbaed0Stroncase $setgid_group in
37741fbaed0Stron no) echo $0: Error: setgid_group no longer accepts \"no\" values. 1>&2
37841fbaed0Stron     echo Try again with \"$0 setgid_group=groupname ...\" 1>&2; exit 1;;
37941fbaed0Stronesac
38041fbaed0Stron
38141fbaed0Stronfor path in "$daemon_directory" "$command_directory" "$queue_directory" \
382837e7c1aSchristos    "$sendmail_path" "$newaliases_path" "$mailq_path" "$manpage_directory" \
383837e7c1aSchristos    "$meta_directory"
38441fbaed0Strondo
38541fbaed0Stron   case "$path" in
38641fbaed0Stron   /*) ;;
38741fbaed0Stron    *) echo $0: Error: \"$path\" should be an absolute path name. 1>&2; exit 1;;
38841fbaed0Stron   esac
38941fbaed0Strondone
39041fbaed0Stron
391837e7c1aSchristosfor path in "$html_directory" "$readme_directory" "$shlib_directory"
39241fbaed0Strondo
39341fbaed0Stron   case "$path" in
39441fbaed0Stron   /*) ;;
39541fbaed0Stron   no) ;;
39641fbaed0Stron    *) echo $0: Error: \"$path\" should be \"no\" or an absolute path name. 1>&2; exit 1;;
39741fbaed0Stron   esac
39841fbaed0Strondone
39941fbaed0Stron
40041fbaed0Stron# Find out what parameters were not specified via command line,
40141fbaed0Stron# via environment, or via installed configuration files.
40241fbaed0Stron
40341fbaed0Stronmissing=
40441fbaed0Stronfor name in $MOST_PARAMETERS
40541fbaed0Strondo
40641fbaed0Stron    eval test -n \"\$$name\" || missing="$missing $name"
40741fbaed0Strondone
40841fbaed0Stron
40941fbaed0Stron# All parameters must be specified at this point.
41041fbaed0Stron
41141fbaed0Strontest -n "$non_interactive" -a -n "$missing" && {
41241fbaed0Stron    cat <<EOF | ${FMT} 1>&2
41341fbaed0Stron$0: Error: some required installation parameters are not defined.
41441fbaed0Stron
41541fbaed0Stron- Either the parameters need to be given in the $config_directory/main.cf
41641fbaed0Stronfile from a recent Postfix installation,
41741fbaed0Stron
41841fbaed0Stron- Or the parameters need to be specified through the process
41941fbaed0Stronenvironment.
42041fbaed0Stron
42141fbaed0Stron- Or the parameters need to be specified as name=value arguments
42241fbaed0Stronon the $0 command line,
42341fbaed0Stron
42441fbaed0StronThe following parameters were missing:
42541fbaed0Stron
42641fbaed0Stron    $missing
42741fbaed0Stron
42841fbaed0StronEOF
42941fbaed0Stron    exit 1
43041fbaed0Stron}
43141fbaed0Stron
43241fbaed0StronPOSTCONF="$command_directory/postconf"
43341fbaed0Stron
43441fbaed0Stron# Save settings, allowing command line/environment override.
43541fbaed0Stron
436837e7c1aSchristos# Undo MAIL_VERSION expansion at the end of a parameter value. If
437837e7c1aSchristos# someone really wants the expanded mail version in main.cf, then
438837e7c1aSchristos# we're sorry.
439837e7c1aSchristos
440837e7c1aSchristos# Confine side effects from mail_version unexpansion within a subshell.
441837e7c1aSchristos
442837e7c1aSchristos(case "$mail_version" in
443837e7c1aSchristos"") mail_version="`$POSTCONF -dhx mail_version`" || exit 1
444837e7c1aSchristosesac
445837e7c1aSchristos
446837e7c1aSchristosfor name in $MOST_PARAMETERS
447837e7c1aSchristosdo
448837e7c1aSchristos    eval junk=\$$name
449837e7c1aSchristos    case "$junk" in
450837e7c1aSchristos    *"$mail_version"*)
451837e7c1aSchristos	case "$pattern" in
452837e7c1aSchristos	"") pattern=`echo "$mail_version" | sed 's/\./\\\\./g'` || exit 1
453837e7c1aSchristos	esac
454837e7c1aSchristos	val=`echo "$junk" | sed "s/$pattern"'$/${mail_version}/g'` || exit 1
455837e7c1aSchristos	eval ${name}='"$val"'
456837e7c1aSchristos    esac
457837e7c1aSchristosdone
458837e7c1aSchristos
459837e7c1aSchristos# XXX Maybe update main.cf only with first install, upgrade, set
460837e7c1aSchristos# permissions, and what else? Should there be a warning otherwise?
461837e7c1aSchristos
46241fbaed0Stronoverride=
46341fbaed0Stronfor name in $MOST_PARAMETERS
46441fbaed0Strondo
465837e7c1aSchristos    eval junk=\"\$$name\"
466837e7c1aSchristos    test "$junk" = "`$POSTCONF -c $config_directory -h $name`" || {
46741fbaed0Stron	override=1
46841fbaed0Stron	break
46941fbaed0Stron    }
47041fbaed0Strondone
47141fbaed0Stron
47241fbaed0Strontest -n "$override" && {
47341fbaed0Stron    $POSTCONF -c $config_directory -e \
47441fbaed0Stron	"daemon_directory = $daemon_directory" \
47541fbaed0Stron	"command_directory = $command_directory" \
47641fbaed0Stron	"queue_directory = $queue_directory" \
47741fbaed0Stron	"data_directory = $data_directory" \
47841fbaed0Stron	"mail_owner = $mail_owner" \
47941fbaed0Stron	"setgid_group = $setgid_group" \
48041fbaed0Stron	"sendmail_path = $sendmail_path" \
48141fbaed0Stron	"mailq_path = $mailq_path" \
48241fbaed0Stron	"newaliases_path = $newaliases_path" \
48341fbaed0Stron	"html_directory = $html_directory" \
48441fbaed0Stron	"manpage_directory = $manpage_directory" \
48541fbaed0Stron	"sample_directory = $sample_directory" \
48641fbaed0Stron	"readme_directory = $readme_directory" \
487837e7c1aSchristos	"shlib_directory = $shlib_directory" \
488837e7c1aSchristos	"meta_directory = $meta_directory" \
48941fbaed0Stron    || exit 1
490837e7c1aSchristos} || exit 0) || exit 1
49141fbaed0Stron
492837e7c1aSchristos# Use file/directory status information in $meta_directory/postfix-files.
49341fbaed0Stron
49441fbaed0Strontest -n "$create" && {
495837e7c1aSchristos    postfix_files_d=$meta_directory/postfix-files.d
496837e7c1aSchristos    for postfix_file in $meta_directory/postfix-files \
4972e5cb688Stron	`test -d $postfix_files_d && { find $postfix_files_d -type f | sort; }`
4982e5cb688Stron    do
4992e5cb688Stron	exec <$postfix_file || exit 1
50041fbaed0Stron	while IFS=: read path type owner group mode flags junk
50141fbaed0Stron	do
50241fbaed0Stron	    IFS="$BACKUP_IFS"
50341fbaed0Stron	    set_permission=
50441fbaed0Stron	    # Skip comments. Skip shared files, if updating a secondary instance.
50541fbaed0Stron	    case $path in
50641fbaed0Stron	    [$]*) case "$update_shared_files" in
50741fbaed0Stron		  1) $debug keep non-shared or shared $path;;
50841fbaed0Stron		  *) non_shared=
50941fbaed0Stron		     for name in $NON_SHARED
51041fbaed0Stron		     do
51141fbaed0Stron			 case $path in
51241fbaed0Stron			 "\$$name"*) non_shared=1; break;;
51341fbaed0Stron			 esac
51441fbaed0Stron		     done
51541fbaed0Stron		     case "$non_shared" in
51641fbaed0Stron		      1) $debug keep non-shared $path;;
51741fbaed0Stron		      *) $debug skip shared $path; continue;;
51841fbaed0Stron		     esac;;
51941fbaed0Stron		  esac;;
52041fbaed0Stron	       *) continue;;
52141fbaed0Stron	    esac
52241fbaed0Stron	    # Skip hard links and symbolic links.
52341fbaed0Stron	    case $type in
52441fbaed0Stron	    [hl]) continue;;
52541fbaed0Stron	    [df]) ;;
5262e5cb688Stron	       *) echo unknown type $type for $path in $postfix_file 1>&2; exit 1;;
52741fbaed0Stron	    esac
52841fbaed0Stron	    # Expand $name, and canonicalize null fields.
52941fbaed0Stron	    for name in path owner group flags
53041fbaed0Stron	    do
53141fbaed0Stron		eval junk=\${$name}
53241fbaed0Stron		case $junk in
53341fbaed0Stron		[$]*) eval $name=$junk;;
53441fbaed0Stron		   -) eval $name=;;
53541fbaed0Stron		   *) ;;
53641fbaed0Stron		esac
53741fbaed0Stron	    done
53841fbaed0Stron	    # Skip uninstalled files.
53941fbaed0Stron	    case $path in
54041fbaed0Stron	    no|no/*) continue;;
54141fbaed0Stron	    esac
54241fbaed0Stron	    # Pick up the flags.
54341fbaed0Stron	    case $flags in *u*) upgrade_flag=1;; *) upgrade_flag=;; esac
54441fbaed0Stron	    case $flags in *c*) create_flag=1;; *) create_flag=;; esac
54541fbaed0Stron	    case $flags in *r*) recursive="-R";; *) recursive=;; esac
54641fbaed0Stron	    case $flags in *o*) obsolete_flag=1;; *) obsolete_flag=;; esac
54741fbaed0Stron	    case $flags in *[1i]*) test ! -r "$path" -a "$config_directory" != \
54841fbaed0Stron				    "$def_config_directory" && continue;; esac
54941fbaed0Stron	    # Flag obsolete objects. XXX Solaris 2..9 does not have "test -e".
55041fbaed0Stron	    if [ -n "$obsolete_flag" ]
55141fbaed0Stron	    then
55241fbaed0Stron		test -r $path -a "$type" != "d" && obsolete="$obsolete $path"
55341fbaed0Stron		continue;
55441fbaed0Stron	    else
55541fbaed0Stron		keep_list="$keep_list $path"
55641fbaed0Stron	    fi
55741fbaed0Stron	    # Create missing directories with proper owner/group/mode settings.
55841fbaed0Stron	    if [ -n "$create" -a "$type" = "d" -a -n "$create_flag" -a ! -d "$path" ]
55941fbaed0Stron	    then
56041fbaed0Stron		mkdir $path || exit 1
56141fbaed0Stron		set_permission=1
56241fbaed0Stron	    # Update all owner/group/mode settings.
56341fbaed0Stron	    elif [ -n "$set_perms" ]
56441fbaed0Stron	    then
56541fbaed0Stron		set_permission=1
56641fbaed0Stron	    # Update obsolete owner/group/mode settings.
56741fbaed0Stron	    elif [ -n "$upgrade_perms" -a -n "$upgrade_flag" ]
56841fbaed0Stron	    then
56941fbaed0Stron		set_permission=1
57041fbaed0Stron	    fi
57141fbaed0Stron	    test -n "$set_permission" && {
57241fbaed0Stron		chown $recursive $owner $path || exit 1
57341fbaed0Stron		test -z "$group" || chgrp $recursive $group $path || exit 1
57441fbaed0Stron		# Don't "chmod -R"; queue file status is encoded in mode bits.
57541fbaed0Stron		if [ "$type" = "d" -a -n "$recursive" ]
57641fbaed0Stron		then
57741fbaed0Stron		    find $path -type d -exec chmod $mode "{}" ";"
57841fbaed0Stron		else
57941fbaed0Stron		    chmod $mode $path
58041fbaed0Stron		fi || exit 1
58141fbaed0Stron	    }
58241fbaed0Stron	done
58341fbaed0Stron	IFS="$BACKUP_IFS"
5842e5cb688Stron    done
58541fbaed0Stron}
58641fbaed0Stron
58741fbaed0Stron# Upgrade existing Postfix configuration files if necessary.
58841fbaed0Stron
58941fbaed0Strontest -n "$upgrade_conf" && {
59041fbaed0Stron
59141fbaed0Stron    # Postfix 2.0.
59241fbaed0Stron    # Add missing relay service to master.cf.
59341fbaed0Stron
59441fbaed0Stron    grep '^relay' $config_directory/master.cf >/dev/null || {
59541fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for relay service
59641fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
59741fbaed0Stronrelay	  unix	-	-	n	-	-	smtp
59841fbaed0StronEOF
59941fbaed0Stron    }
60041fbaed0Stron
60141fbaed0Stron    # Postfix 1.1.
60241fbaed0Stron    # Add missing flush service to master.cf.
60341fbaed0Stron
60441fbaed0Stron    grep '^flush.*flush' $config_directory/master.cf >/dev/null || {
60541fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for flush service
60641fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
60741fbaed0Stronflush     unix  -       -       n       1000?   0       flush
60841fbaed0StronEOF
60941fbaed0Stron    }
61041fbaed0Stron
61141fbaed0Stron    # Postfix 2.1.
61241fbaed0Stron    # Add missing trace service to master.cf.
61341fbaed0Stron
61441fbaed0Stron    grep 'trace.*bounce' $config_directory/master.cf >/dev/null || {
61541fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for trace service
61641fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
61741fbaed0Strontrace	  unix	-	-	n	-	0	bounce
61841fbaed0StronEOF
61941fbaed0Stron    }
62041fbaed0Stron
62141fbaed0Stron    # Postfix 2.1.
62241fbaed0Stron    # Add missing verify service to master.cf.
62341fbaed0Stron
62441fbaed0Stron    grep '^verify.*verify' $config_directory/master.cf >/dev/null || {
62541fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for verify service
62641fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
62741fbaed0Stronverify	  unix	-	-	n	-	1	verify
62841fbaed0StronEOF
62941fbaed0Stron    }
63041fbaed0Stron
63141fbaed0Stron    # Postfix 2.1.
63241fbaed0Stron    # Fix verify service process limit.
63341fbaed0Stron
63441fbaed0Stron    grep '^verify.*[ 	]0[ 	]*verify' \
63541fbaed0Stron	$config_directory/master.cf >/dev/null && {
63641fbaed0Stron	    echo Editing $config_directory/master.cf, setting verify process limit to 1
63741fbaed0Stron	    ed $config_directory/master.cf <<EOF || exit 1
63841fbaed0Stron/^verify.*[ 	]0[ 	]*verify/
63941fbaed0Strons/\([ 	]\)0\([ 	]\)/\11\2/
64041fbaed0Stronp
64141fbaed0Stronw
64241fbaed0Stronq
64341fbaed0StronEOF
64441fbaed0Stron    }
64541fbaed0Stron
64641fbaed0Stron    # Postfix 1.1.
64741fbaed0Stron    # Change privileged pickup service into unprivileged.
64841fbaed0Stron
64941fbaed0Stron    grep "^pickup[ 	]*fifo[ 	]*n[ 	]*n" \
65041fbaed0Stron	$config_directory/master.cf >/dev/null && {
65141fbaed0Stron	    echo Editing $config_directory/master.cf, making the pickup service unprivileged
65241fbaed0Stron	    ed $config_directory/master.cf <<EOF || exit 1
65341fbaed0Stron/^pickup[ 	]*fifo[ 	]*n[ 	]*n/
65441fbaed0Strons/\(n[ 	]*\)n/\1-/
65541fbaed0Stronp
65641fbaed0Stronw
65741fbaed0Stronq
65841fbaed0StronEOF
65941fbaed0Stron    }
66041fbaed0Stron
66141fbaed0Stron    # Postfix 1.1.
66241fbaed0Stron    # Change private cleanup and flush services into public.
66341fbaed0Stron
66441fbaed0Stron    for name in cleanup flush
66541fbaed0Stron    do
66641fbaed0Stron	grep "^$name[ 	]*unix[ 	]*[-y]" \
66741fbaed0Stron	    $config_directory/master.cf >/dev/null && {
66841fbaed0Stron		echo Editing $config_directory/master.cf, making the $name service public
66941fbaed0Stron	    ed $config_directory/master.cf <<EOF || exit 1
67041fbaed0Stron/^$name[ 	]*unix[ 	]*[-y]/
67141fbaed0Strons/[-y]/n/
67241fbaed0Stronp
67341fbaed0Stronw
67441fbaed0Stronq
67541fbaed0StronEOF
67641fbaed0Stron	}
67741fbaed0Stron    done
67841fbaed0Stron
67941fbaed0Stron    # Postfix 2.2.
68041fbaed0Stron    # File systems have improved since Postfix came out, and all we
68141fbaed0Stron    # require now is that defer and deferred are hashed because those
68241fbaed0Stron    # can contain lots of files.
68341fbaed0Stron
68441fbaed0Stron    found=`$POSTCONF -c $config_directory -h hash_queue_names`
68541fbaed0Stron    missing=
68641fbaed0Stron    (echo "$found" | grep defer >/dev/null)  || missing="$missing defer"
68741fbaed0Stron    (echo "$found" | grep deferred>/dev/null)|| missing="$missing deferred"
68841fbaed0Stron    test -n "$missing" && {
68941fbaed0Stron	echo fixing main.cf hash_queue_names for missing $missing
69041fbaed0Stron	$POSTCONF -c $config_directory -e hash_queue_names="$found$missing" ||
69141fbaed0Stron	    exit 1
69241fbaed0Stron    }
69341fbaed0Stron
69441fbaed0Stron    # Turn on safety nets for new features that could bounce mail that
69541fbaed0Stron    # would be accepted by a previous Postfix version.
69641fbaed0Stron
69741fbaed0Stron    # [The "unknown_local_recipient_reject_code = 450" safety net,
69841fbaed0Stron    # introduced with Postfix 2.0 and deleted after Postfix 2.3.]
69941fbaed0Stron
70041fbaed0Stron    # Postfix 2.0.
70141fbaed0Stron    # Add missing proxymap service to master.cf.
70241fbaed0Stron
70341fbaed0Stron    grep '^proxymap.*proxymap' $config_directory/master.cf >/dev/null || {
70441fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for proxymap service
70541fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
70641fbaed0Stronproxymap  unix	-	-	n	-	-	proxymap
70741fbaed0StronEOF
70841fbaed0Stron    }
70941fbaed0Stron
71041fbaed0Stron    # Postfix 2.1.
71141fbaed0Stron    # Add missing anvil service to master.cf.
71241fbaed0Stron
71341fbaed0Stron    grep '^anvil.*anvil' $config_directory/master.cf >/dev/null || {
71441fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for anvil service
71541fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
71641fbaed0Stronanvil	  unix	-	-	n	-	1	anvil
71741fbaed0StronEOF
71841fbaed0Stron    }
71941fbaed0Stron
72041fbaed0Stron    # Postfix 2.2.
72141fbaed0Stron    # Add missing scache service to master.cf.
72241fbaed0Stron
72341fbaed0Stron    grep '^scache.*scache' $config_directory/master.cf >/dev/null || {
72441fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for scache service
72541fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
72641fbaed0Stronscache	  unix	-	-	n	-	1	scache
72741fbaed0StronEOF
72841fbaed0Stron    }
72941fbaed0Stron
73041fbaed0Stron    # Postfix 2.2.
73141fbaed0Stron    # Add missing discard service to master.cf.
73241fbaed0Stron
73341fbaed0Stron    grep '^discard.*discard' $config_directory/master.cf >/dev/null || {
73441fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for discard service
73541fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
73641fbaed0Strondiscard	  unix	-	-	n	-	-	discard
73741fbaed0StronEOF
73841fbaed0Stron    }
73941fbaed0Stron
74041fbaed0Stron    # Postfix 2.2.
74141fbaed0Stron    # Update the tlsmgr fifo->unix service.
74241fbaed0Stron
74341fbaed0Stron    grep "^tlsmgr[ 	]*fifo[ 	]" \
74441fbaed0Stron	$config_directory/master.cf >/dev/null && {
74541fbaed0Stron	    echo Editing $config_directory/master.cf, updating the tlsmgr from fifo to unix service
74641fbaed0Stron	    ed $config_directory/master.cf <<EOF || exit 1
74741fbaed0Stron/^tlsmgr[ 	]*fifo[ 	]/
74841fbaed0Strons/fifo/unix/
74941fbaed0Strons/[0-9][0-9]*/&?/
75041fbaed0Stronp
75141fbaed0Stronw
75241fbaed0Stronq
75341fbaed0StronEOF
75441fbaed0Stron    }
75541fbaed0Stron
75641fbaed0Stron    # Postfix 2.2.
75741fbaed0Stron    # Add missing tlsmgr service to master.cf.
75841fbaed0Stron
75941fbaed0Stron    grep '^tlsmgr.*tlsmgr' $config_directory/master.cf >/dev/null || {
76041fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for tlsmgr service
76141fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
76241fbaed0Strontlsmgr    unix  -       -       n       1000?   1       tlsmgr
76341fbaed0StronEOF
76441fbaed0Stron    }
76541fbaed0Stron
76641fbaed0Stron    # Postfix 2.2.
76741fbaed0Stron    # Add missing retry service to master.cf.
76841fbaed0Stron
76941fbaed0Stron    grep '^retry.*error' $config_directory/master.cf >/dev/null || {
77041fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for retry service
77141fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
77241fbaed0Stronretry     unix  -       -       n       -       -       error
77341fbaed0StronEOF
77441fbaed0Stron    }
77541fbaed0Stron
77641fbaed0Stron    # Postfix 2.5.
77741fbaed0Stron    # Add missing proxywrite service to master.cf.
77841fbaed0Stron
77941fbaed0Stron    grep '^proxywrite.*proxymap' $config_directory/master.cf >/dev/null || {
78041fbaed0Stron	echo Editing $config_directory/master.cf, adding missing entry for proxywrite service
78141fbaed0Stron	cat >>$config_directory/master.cf <<EOF || exit 1
78241fbaed0Stronproxywrite unix -       -       n       -       1       proxymap
78341fbaed0StronEOF
78441fbaed0Stron    }
78541fbaed0Stron
78641fbaed0Stron    # Postfix 2.5.
78741fbaed0Stron    # Fix a typo in the default master.cf proxywrite entry.
78841fbaed0Stron
78941fbaed0Stron    grep '^proxywrite.*-[ 	]*proxymap' $config_directory/master.cf >/dev/null && {
79041fbaed0Stron	echo Editing $config_directory/master.cf, setting proxywrite process limit to 1
79141fbaed0Stron	    ed $config_directory/master.cf <<EOF || exit 1
79241fbaed0Stron/^proxywrite.*-[ 	]*proxymap/
79341fbaed0Strons/-\([ 	]*proxymap\)/1\1/
79441fbaed0Stronp
79541fbaed0Stronw
79641fbaed0Stronq
79741fbaed0StronEOF
79841fbaed0Stron    }
79941fbaed0Stron
800e8314800Stron    # Postfix 2.8.
801e8314800Stron    # Add missing postscreen service to master.cf.
802e8314800Stron
803e8314800Stron    grep '^#*smtp.*postscreen' $config_directory/master.cf >/dev/null || {
804e8314800Stron	echo Editing $config_directory/master.cf, adding missing entry for postscreen TCP service
805e8314800Stron	cat >>$config_directory/master.cf <<EOF || exit 1
806e8314800Stron#smtp      inet  n       -       n       -       1       postscreen
807e8314800StronEOF
808e8314800Stron    }
809e8314800Stron
810e8314800Stron    # Postfix 2.8.
811e8314800Stron    # Add missing smtpd (unix-domain) service to master.cf.
812e8314800Stron
813e8314800Stron    grep '^#*smtpd.*smtpd' $config_directory/master.cf >/dev/null || {
814e8314800Stron	echo Editing $config_directory/master.cf, adding missing entry for smtpd unix-domain service
815e8314800Stron	cat >>$config_directory/master.cf <<EOF || exit 1
816e8314800Stron#smtpd     pass  -       -       n       -       -       smtpd
817e8314800StronEOF
818e8314800Stron    }
819e8314800Stron
820e8314800Stron    # Postfix 2.8.
821e8314800Stron    # Add temporary dnsblog (unix-domain) service to master.cf.
822e8314800Stron
823e8314800Stron    grep '^#*dnsblog.*dnsblog' $config_directory/master.cf >/dev/null || {
824e8314800Stron	echo Editing $config_directory/master.cf, adding missing entry for dnsblog unix-domain service
825e8314800Stron	cat >>$config_directory/master.cf <<EOF || exit 1
826e8314800Stron#dnsblog   unix  -       -       n       -       0       dnsblog
827e8314800StronEOF
828e8314800Stron    }
829e8314800Stron
830e8314800Stron    # Postfix 2.8.
831e8314800Stron    # Add tlsproxy (unix-domain) service to master.cf.
832e8314800Stron
833e8314800Stron    grep '^#*tlsproxy.*tlsproxy' $config_directory/master.cf >/dev/null || {
834e8314800Stron	echo Editing $config_directory/master.cf, adding missing entry for tlsproxy unix-domain service
835e8314800Stron	cat >>$config_directory/master.cf <<EOF || exit 1
836e8314800Stron#tlsproxy  unix  -       -       n       -       0       tlsproxy
837e8314800StronEOF
838e8314800Stron    }
839e8314800Stron
84041fbaed0Stron    # Report (but do not remove) obsolete files.
84141fbaed0Stron
84241fbaed0Stron    test -n "$obsolete" && {
84341fbaed0Stron	cat <<EOF | ${FMT}
84441fbaed0Stron
84541fbaed0Stron    Note: the following files or directories still exist but are
84641fbaed0Stron    no longer part of Postfix:
84741fbaed0Stron
84841fbaed0Stron    $obsolete
84941fbaed0Stron
85041fbaed0StronEOF
85141fbaed0Stron    }
85241fbaed0Stron
853e694ac3bStron    # Postfix 2.9.
854e694ac3bStron    # Safety net for incompatible changes in IPv6 defaults.
855e694ac3bStron    # PLEASE DO NOT REMOVE THIS CODE. ITS PURPOSE IS TO AVOID AN
856e694ac3bStron    # UNEXPECTED DROP IN PERFORMANCE AFTER UPGRADING FROM POSTFIX
857e694ac3bStron    # BEFORE 2.9.
858e694ac3bStron    # This code assumes that the default is "inet_protocols = ipv4"
859e694ac3bStron    # when IPv6 support is not compiled in. See util/sys_defs.h.
860e694ac3bStron
861e694ac3bStron    test "`$POSTCONF -dh inet_protocols`" = "ipv4" ||
862b6432918Stron	test -n "`$POSTCONF -c $config_directory -n inet_protocols`" || {
863b6432918Stron	cat <<EOF | ${FMT}
864b6432918Stron    COMPATIBILITY: editing $config_directory/main.cf, setting
865b6432918Stron    inet_protocols=ipv4.  Specify inet_protocols explicitly if you
866b6432918Stron    want to enable IPv6.
867b6432918Stron    In a future release IPv6 will be enabled by default.
868b6432918StronEOF
869e694ac3bStron	$POSTCONF -c $config_directory inet_protocols=ipv4 || exit 1
870e694ac3bStron    }
871b6432918Stron
872b6432918Stron# Disabled because unhelpful down-stream maintainers disable the safety net.
873b6432918Stron#    # Postfix 2.10.
874b6432918Stron#    # Safety net for incompatible changes due to the introduction
875b6432918Stron#    # of the smtpd_relay_restrictions feature to separate the
876b6432918Stron#    # mail relay policy from the spam blocking policy.
877b6432918Stron#    # PLEASE DO NOT REMOVE THIS CODE. ITS PURPOSE IS TO PREVENT
878b6432918Stron#    # INBOUND MAIL FROM UNEXPECTEDLY BOUNCING AFTER UPGRADING FROM
879b6432918Stron#    # POSTFIX BEFORE 2.10.
880b6432918Stron#    test -n "`$POSTCONF -c $config_directory -n smtpd_relay_restrictions`" || {
881b6432918Stron#	cat <<EOF | ${FMT}
882b6432918Stron#    COMPATIBILITY: editing $config_directory/main.cf, overriding
883b6432918Stron#    smtpd_relay_restrictions to prevent inbound mail from
884b6432918Stron#    unexpectedly bouncing.
885b6432918Stron#    Specify an empty smtpd_relay_restrictions value to keep using
886b6432918Stron#    smtpd_recipient_restrictions as before.
887b6432918Stron#EOF
888b6432918Stron#	$POSTCONF -c $config_directory "smtpd_relay_restrictions = \
889b6432918Stron#	    permit_mynetworks permit_sasl_authenticated \
890b6432918Stron#	    defer_unauth_destination" || exit 1
891b6432918Stron#    }
8923c275423Schristos
8933c275423Schristos    # Postfix 3.4
8943c275423Schristos    # Add a postlog service entry.
8953c275423Schristos
8963c275423Schristos    grep '^postlog' $config_directory/master.cf >/dev/null || {
8973c275423Schristos	echo Editing $config_directory/master.cf, adding missing entry for postlog unix-domain datagram service
8983c275423Schristos	cat >>$config_directory/master.cf <<EOF || exit 1
8993c275423Schristospostlog   unix-dgram n  -       n       -       1       postlogd
9003c275423SchristosEOF
9013c275423Schristos    }
90241fbaed0Stron}
90341fbaed0Stron
90441fbaed0Stron# A reminder if this is the first time Postfix is being installed.
90541fbaed0Stron
90641fbaed0Strontest -n "$first_install_reminder" && {
90741fbaed0Stron
90841fbaed0Stron    ALIASES=`$POSTCONF -c $config_directory -h alias_database | sed 's/^[^:]*://'`
90941fbaed0Stron    NEWALIASES_PATH=`$POSTCONF -c $config_directory -h newaliases_path`
91041fbaed0Stron    cat <<EOF | ${FMT}
91141fbaed0Stron
91241fbaed0Stron    Warning: you still need to edit myorigin/mydestination/mynetworks
91341fbaed0Stron    parameter settings in $config_directory/main.cf.
91441fbaed0Stron
91541fbaed0Stron    See also http://www.postfix.org/STANDARD_CONFIGURATION_README.html
91641fbaed0Stron    for information about dialup sites or about sites inside a
91741fbaed0Stron    firewalled network.
91841fbaed0Stron
91941fbaed0Stron    BTW: Check your $ALIASES file and be sure to set up aliases
92041fbaed0Stron    that send mail for root and postmaster to a real person, then
92141fbaed0Stron    run $NEWALIASES_PATH.
92241fbaed0Stron
92341fbaed0StronEOF
92441fbaed0Stron
92541fbaed0Stron}
92641fbaed0Stron
92741fbaed0Stronexit 0
928