#!/bin/sh -e # Debian Postfix preinst # LaMont Jones # Modified to use debconf by Colin Walters # do we have debconf? if [ -f /usr/share/debconf/confmodule ]; then . /usr/share/debconf/confmodule DEBCONF=true else DEBCONF= fi dpkg_vers=$(dpkg --status dpkg | sed -n '/Version: /s/^Version: //p') CONFIG=/etc/postfix/main.cf MASTER=/etc/postfix/master.cf POSTDROP=/usr/sbin/postdrop mydomain_warning() { if [ -n "$DEBCONF" ]; then db_fset postfix/mydomain_warning seen false db_input medium postfix/mydomain_warning || true db_go || true db_get postfix/mydomain_warning if [ "$RET" = "false" ]; then echo "aborting postfix install" exit 1 fi else # no debconf, fall back cat << EOF Postfix version 2.3.3-2 and later require changes in main.cf. Specifically, mydomain must be specified, since hostname(2) is not an FQDN. EOF echo -n "Shall I make the change? " read line case ${line} in [nN]*) echo "aborting postfix install" exit 1 ;; esac fi } retry_warning() { if [ -n "$DEBCONF" ]; then db_fset postfix/retry_upgrade_warning seen false db_input medium postfix/retry_upgrade_warning || true db_go || true db_get postfix/retry_upgrade_warning if [ "$RET" = "false" ]; then echo "aborting postfix install" exit 1 fi else # no debconf, fall back cat << EOF Postfix version 2.4 requires that the retry service be added to master.cf EOF echo -n "Shall I make the change? " read line case ${line} in [nN]*) echo "aborting postfix install" exit 1 ;; esac fi } tlsmgr_warning() { if [ -n "$DEBCONF" ]; then db_fset postfix/tlsmgr_upgrade_warning seen false db_input medium postfix/tlsmgr_upgrade_warning || true db_go || true db_get postfix/tlsmgr_upgrade_warning if [ "$RET" = "false" ]; then echo "aborting postfix install" exit 1 fi else # no debconf, fall back cat << EOF Postfix version 2.2 has changed the invocation of tlsmgr. EOF echo -n "Shall I make the change? " read line case ${line} in [nN]*) echo "aborting postfix install" exit 1 ;; esac fi } kernel_version_warning() { if [ -n "$DEBCONF" ]; then db_fset postfix/kernel_version_warning seen false db_input low postfix/kernel_version_warning || true db_go || true db_get postfix/kernel_version_warning else cat << EOF Postfix uses features that are not found in kernels prior to 2.6. If you proceeed with the installation, Postfix will not run. EOF RET=false fi if [ "$RET" = "false" ]; then echo "Aborting postfix install" exit 1 fi } (umask 022; mkdir -p /var/spool/postfix) case "$1" in install) rm -f /var/spool/postfix/restart /var/spool/postfix/reload # workaround sendmail not unregistering itself... if [ -e /etc/suid.conf ] && [ -x /usr/sbin/suidunregister ]; then if grep -q sendmail /etc/suid.conf; then /usr/sbin/suidunregister -s postfix /usr/sbin/sendmail fi fi if [ -L /etc/postfix/postfix-script ]; then rm -f /etc/postfix/postfix-script fi ;; upgrade) version=$2 if [ -d /var/spool/postfix ] && [ -f /etc/postfix/main.cf ]; then touch /var/spool/postfix/restart fi export LANG=C # for the comparison of mail version... if dpkg --compare-versions "`uname -r`" lt 2.6.0 ; then kernel_version_warning fi if [ -L /etc/postfix/postfix-script ]; then rm -f /etc/postfix/postfix-script fi if grep -q '^tlsmgr[[:space:]]*fifo' $MASTER; then tlsmgr_warning fi if dpkg --compare-versions $version lt 2.3.5-1; then # droping 10hostname.dpatch forces cleanup. if [ -z "$(postconf -n mydomain 2>/dev/null || true)" ]; then myhost=$(hostname 2>/dev/null) if [ "X${myhost%.*}" = "X${myhost}" ]; then mydomain_warning touch /var/spool/postfix/mydomain-upgrade fi fi fi if ! grep -q '^retry[[:space:]]' $MASTER; then retry_warning fi invoke-rc.d --quiet postfix stop || true ;; abort-upgrade) ;; *) echo "preinst called with unknown argument \`$1'" >&2 exit 1 ;; esac if [ install = "$1" -o upgrade = "$1" ]; then # cleanup after past mistakes. rm -f /usr/sbin/postconf.postfix dpkg-divert --package postfix-tls --remove \ --divert /usr/sbin/postconf.postfix \ /usr/sbin/postconf >/dev/null 2>/dev/null fi