# SUMMARY
# Postfix post-installation script
# SYNOPSIS
-# postfix post-install [name=value] command ...
+# post-install [name=value] command ...
# DESCRIPTION
# The post-install script performs the finishing touch of a Postfix
# installation, after the executable programs and configuration
# copy the configuration files from the primary Postfix instance to
# a secondary configuration directory and execute:
#
-# postfix post-install config_directory=secondary-config-directory \e
+# post-install config_directory=secondary-config-directory \e
# .in +4
# queue_directory=secondary-queue-directory \e
# .br
# To upgrade a secondary Postfix installation on the same machine,
# execute:
#
-# postfix post-install config_directory=secondary-config-directory \e
+# post-install config_directory=secondary-config-directory \e
# .in +4
# upgrade-permissions upgrade-configuration
# INSTALLATION PARAMETER INPUT METHODS
# .IP command_directory
# The directory for Postfix administrative commands. This
# directory should be in the command search path of adminstrative users.
-# .IP data_directory
-# The directory for Postfix writable data files (caches, etc.).
# .IP queue_directory
# The directory for Postfix queues.
+# .IP data_directory
+# The directory for Postfix writable data files (caches, etc.).
# .IP sendmail_path
# The full pathname for the Postfix sendmail command.
# This is the Sendmail-compatible mail posting interface.
# The directory for the Postfix on-line manual pages.
# .IP sample_directory
# The directory for the Postfix sample configuration files.
+# This feature is obsolete as of Postfix 2.1.
# .IP readme_directory
# The directory for the Postfix README files.
# SEE ALSO
USAGE="Usage: $0 [name=value] command
create-missing Create missing queue directories.
- set-permissions Update file permission and ownership.
- upgrade-configuration Update configuration files.
upgrade-source When installing or upgrading from source code.
upgrade-package When installing or upgrading from pre-built package.
first-install-reminder Remind of mandatory first-time configuration steps.
exit 1
}
-for name in config_directory $MOST_PARAMETERS
-do
- eval test -n \"\${$name}\" || {
- echo "$0: Error: do not invoke this command directly" 1>&2
- echo Re-run this command as: postfix $0 ... 1>&2
- exit 1
- }
-done
+# Bootstrapping problem.
-POSTCONF="$command_directory/postconf"
+if [ -n "$command_directory" ]
+then
+ POSTCONF="$command_directory/postconf"
+else
+ POSTCONF="postconf"
+fi
$POSTCONF -d mail_version >/dev/null 2>/dev/null || {
echo $0: Error: no $POSTCONF command found. 1>&2
- echo Re-run this command as: postfix $0 command_directory=/some/where. 1>&2
+ echo Re-run this command as $0 command_directory=/some/where. 1>&2
exit 1
}
*) FMT=fmt;;
esac
+# If a parameter is not set via the command line or environment,
+# try to use settings from installed configuration files.
+
+# Extract parameter settings from the obsolete install.cf file, as
+# a transitional aid.
+
+grep setgid_group $config_directory/main.cf >/dev/null 2>&1 || {
+ test -f $config_directory/install.cf && {
+ for name in sendmail_path newaliases_path mailq_path setgid manpages
+ do
+ eval junk=\$$name
+ case "$junk" in
+ "") eval unset $name;;
+ esac
+ eval : \${$name="\`. $config_directory/install.cf; echo \$$name\`"} \
+ || exit 1
+ done
+ : ${setgid_group=$setgid}
+ : ${manpage_directory=$manpages}
+ }
+}
+
+# Extract parameter settings from the installed main.cf file.
+
+test -f $config_directory/main.cf && {
+ for name in $MOST_PARAMETERS
+ do
+ eval junk=\$$name
+ case "$junk" in
+ "") eval unset $name;;
+ esac
+ eval : \${$name=\`$POSTCONF -c $config_directory -h $name\`} || exit 1
+ done
+}
+
# Sanity checks
case $manpage_directory in
no) echo $0: Error: manpage_directory no longer accepts \"no\" values. 1>&2
- echo Try again with \"postfix $0 manpage_directory=/pathname ...\". 1>&2
- exit 1;;
+ echo Try again with \"$0 manpage_directory=/pathname ...\". 1>&2; exit 1;;
esac
case $setgid_group in
no) echo $0: Error: setgid_group no longer accepts \"no\" values. 1>&2
- echo Try again with \"postfix $0 setgid_group=groupname ...\" 1>&2
- exit 1;;
+ echo Try again with \"$0 setgid_group=groupname ...\" 1>&2; exit 1;;
esac
for path in "$daemon_directory" "$command_directory" "$queue_directory" \
case "$path" in
/*) ;;
no) ;;
- *) echo $0: Error: \"$path\" should be \"no\" or an absolute path name. 1>&2
- exit 1;;
+ *) echo $0: Error: \"$path\" should be \"no\" or an absolute path name. 1>&2; exit 1;;
esac
done
+# Find out what parameters were not specified via command line,
+# via environment, or via installed configuration files.
+
+missing=
+for name in $MOST_PARAMETERS
+do
+ eval test -n \"\$$name\" || missing="$missing $name"
+done
+
+# All parameters must be specified at this point.
+
+test -n "$non_interactive" -a -n "$missing" && {
+ cat <<EOF | ${FMT} 1>&2
+$0: Error: some required installation parameters are not defined.
+
+- Either the parameters need to be given in the $config_directory/main.cf
+file from a recent Postfix installation,
+
+- Or the parameters need to be specified through the process
+environment.
+
+- Or the parameters need to be specified as name=value arguments
+on the $0 command line,
+
+The following parameters were missing:
+
+ $missing
+
+EOF
+ exit 1
+}
+
+POSTCONF="$command_directory/postconf"
+
# Save settings, allowing command line/environment override.
-# Optimization: don't update main.cf if nothing has changed.
-# Caution: "`command`" removes the last newline character.
-test "`for name in $MOST_PARAMETERS; do eval echo \\\${\$name}; done`" = \
- "`$POSTCONF -h $MOST_PARAMETERS`" || {
+override=
+for name in $MOST_PARAMETERS
+do
+ eval test \"\$$name\" = \"`$POSTCONF -c $config_directory -h $name`\" || {
+ override=1
+ break
+ }
+done
+
+test -n "$override" && {
$POSTCONF -c $config_directory -e \
"daemon_directory = $daemon_directory" \
"command_directory = $command_directory" \
- "data_directory = $data_directory" \
"queue_directory = $queue_directory" \
+ "data_directory = $data_directory" \
"mail_owner = $mail_owner" \
"setgid_group = $setgid_group" \
"sendmail_path = $sendmail_path" \
# Postfix 2.2.
# File systems have improved since Postfix came out, and all we
- # require now that defer and deferred are hashed because those
+ # require now is that defer and deferred are hashed because those
# can contain lots of files.
found=`$POSTCONF -c $config_directory -h hash_queue_names`
EOF
}
+ # Postfix 2.5.
+ # Fix a typo in the default master.cf proxywrite entry.
+
+ grep '^proxywrite.*-[ ]*proxymap' $config_directory/master.cf >/dev/null && {
+ echo Editing $config_directory/master.cf, setting proxywrite process limit to 1
+ ed $config_directory/master.cf <<EOF || exit 1
+/^proxywrite.*-[ ]*proxymap/
+s/-\([ ]*proxymap\)/1\1/
+p
+w
+q
+EOF
+ }
+
# Report (but do not remove) obsolete files.
test -n "$obsolete" && {