[BACK]Return to postfix CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc / rc.d

File: [cvs.NetBSD.org] / src / etc / rc.d / postfix (download)

Revision 1.16, Wed Apr 15 22:11:32 2009 UTC (14 years, 11 months ago) by perry
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-premerge-20091211, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, khorben-n900, jym-xensuspend-nbase, jym-xensuspend-base, cherry-xenmp-base, cherry-xenmp, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Changes since 1.15: +2 -2 lines

un-uppercase pseudodependency for the moment so as not to break pkgsrc

#!/bin/sh
#
# $NetBSD: postfix,v 1.16 2009/04/15 22:11:32 perry Exp $
#

# PROVIDE: mail
# REQUIRE: LOGIN
#	we make mail start late, so that things like .forward's are not
#	processed until the system is fully operational

$_rc_subr_loaded . /etc/rc.subr

name="postfix"
rcvar=$name
postfix_command="/usr/sbin/${name}"
required_files="/etc/${name}/main.cf"
start_precmd="postfix_precmd"
start_cmd="postfix_op"
stop_cmd="postfix_op"
reload_cmd="postfix_op"
extra_commands="reload"
spooletcdir="/var/spool/${name}/etc"
postconf="/usr/sbin/postconf"
required_dirs=$spooletcdir

_rebuild() {
	echo "${name}: rebuilding ${1} ($2 ${1}.db)"
	$($postconf -h newaliases_path)
}

postfix_precmd()
{
	# As this is called after the is_running and required_dir checks
	# are made in run_rc_command(), we can safely assume ${spooletcdir}
	# exists and postfix isn't running at this point (unless forcestart
	# is used).
	#

	for f in localtime resolv.conf services; do
		if [ -f /etc/$f ]; then
			cmp -s /etc/$f ${spooletcdir}/$f || \
			    cp -p /etc/$f ${spooletcdir}/$f
		fi
	done

	for f in $($postconf -h alias_database); do
		OIFS="${IFS}"
		IFS="${IFS}:"
		set -- $f
		IFS="${OIFS}"
		case "$1" in
		hash)
			if [ -f "$2.db" ]; then
				if [ ! "$2" -ot "$2.db" ]; then
					_rebuild "$2" "out of date"
				fi
			else
				_rebuild "$2" "missing"
			fi
			;;
		*)
			;;
		esac
	done
}

postfix_op()
{
	${postfix_command} ${rc_arg}
}

check_use_postfix()
{
	_mta_path=$(awk '/^sendmail[ \t]/{print$2}' /etc/mailer.conf)
	_postfix_path="/usr/libexec/postfix/sendmail"
	_sendmail_path="/usr/libexec/sendmail/sendmail"

	if [ "${postfix}" != "check" ]; then
	    echo "${postfix}"
	elif [ "${_mta_path}" = "${_postfix_path}" ]; then
	    echo YES
	else
	    echo "WARNING: default postfix not used as not selected in mailer.conf" >&2
	    if [ "${_mta_path}" = "${_sendmail_path}" -a \
		! -x "${_mta_path}" ]; then
		echo "WARNING: mailer.conf points to the removed sendmail" >&2
		echo "update /etc/mailer.conf to get a working mailer configuration" >&2
	    fi
	    echo NO
	fi
}

# force re-evaluation of /etc/rc.conf and resetting of $sendmail
_rc_conf_loaded=false
_rc_d_postfix=check
load_rc_config $name
unset _rc_d_postfix
postfix=$(check_use_postfix)
run_rc_command "$1"