postfix revision 1.10
11.1Sthorpej#!/bin/sh
21.1Sthorpej#
31.10Schristos# $NetBSD: postfix,v 1.10 2006/06/18 14:05:34 christos Exp $
41.1Sthorpej#
51.1Sthorpej
61.1Sthorpej# PROVIDE: mail
71.1Sthorpej# REQUIRE: LOGIN
81.6Slukem#	we make mail start late, so that things like .forward's are not
91.6Slukem#	processed until the system is fully operational
101.1Sthorpej
111.9Smycroft$_rc_subr_loaded . /etc/rc.subr
121.1Sthorpej
131.3Slukemname="postfix"
141.5Slukemrcvar=$name
151.8Slukempostfix_command="/usr/sbin/${name}"
161.3Slukemrequired_files="/etc/${name}/main.cf"
171.6Slukemstart_precmd="postfix_precmd"
181.8Slukemstart_cmd="postfix_op"
191.8Slukemstop_cmd="postfix_op"
201.8Slukemreload_cmd="postfix_op"
211.5Slukemextra_commands="reload"
221.6Slukemspooletcdir="/var/spool/${name}/etc"
231.6Slukemrequired_dirs=$spooletcdir
241.6Slukem
251.6Slukempostfix_precmd()
261.6Slukem{
271.6Slukem	# As this is called after the is_running and required_dir checks
281.6Slukem	# are made in run_rc_command(), we can safely assume ${spooletcdir}
291.6Slukem	# exists and postfix isn't running at this point (unless forcestart
301.6Slukem	# is used).
311.6Slukem	#
321.6Slukem
331.6Slukem	for f in localtime resolv.conf services; do
341.6Slukem		if [ -f /etc/$f ]; then
351.6Slukem			cmp -s /etc/$f ${spooletcdir}/$f || \
361.6Slukem			    cp -p /etc/$f ${spooletcdir}/$f
371.6Slukem		fi
381.6Slukem	done
391.10Schristos
401.10Schristos	# check modifications on /etc/mail/aliases
411.10Schristos	if [ -f "/etc/mail/aliases.db" ]; then
421.10Schristos		if [ ! "/etc/mail/aliases" -ot "/etc/mail/aliases.db" ]; then
431.10Schristos			echo \
441.10Schristos	    "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
451.10Schristos			/usr/bin/newaliases
461.10Schristos		fi
471.10Schristos	else
481.10Schristos		echo \
491.10Schristos	    "${name}: /etc/mail/aliases.db not present, generating"
501.10Schristos			/usr/bin/newaliases
511.10Schristos	fi
521.6Slukem}
531.1Sthorpej
541.8Slukempostfix_op()
551.8Slukem{
561.8Slukem	${postfix_command} ${rc_arg}
571.8Slukem}
581.8Slukem
591.4Slukemload_rc_config $name
601.3Slukemrun_rc_command "$1"
61