sendmail revision 128366
178344Sobrien#!/bin/sh
278344Sobrien#
398184Sgordon# $NetBSD: sendmail,v 1.14 2002/02/12 01:26:36 lukem Exp $
498184Sgordon# $FreeBSD: head/etc/rc.d/sendmail 128366 2004-04-17 19:09:09Z fjoe $
578344Sobrien#
678344Sobrien
778344Sobrien# PROVIDE: mail
878344Sobrien# REQUIRE: LOGIN
9124616Smtm# KEYWORD: FreeBSD
1098184Sgordon#	we make mail start late, so that things like .forward's are not
1198184Sgordon#	processed until the system is fully operational
1278344Sobrien
1398184Sgordon# XXX - Get together with sendmail mantainer to figure out how to
1498184Sgordon#	better handle SENDMAIL_ENABLE and 3rd party MTAs.
1598184Sgordon#
1678344Sobrien. /etc/rc.subr
1778344Sobrien
1878344Sobrienname="sendmail"
1998184Sgordonrcvar=`set_rcvar`
2078344Sobrienrequired_files="/etc/mail/${name}.cf"
21127896Sfjoe
22127896Sfjoeload_rc_config $name
23124622Smtmcommand=${sendmail_program:-/usr/sbin/sendmail}
24124622Smtmpidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
25127896Sfjoeprocname=${sendmail_procname:-/usr/sbin/sendmail}
2678344Sobrien
27124622Smtmcase ${sendmail_enable} in
28124622Smtm[Nn][Oo][Nn][Ee])
29124622Smtm	sendmail_enable="NO"
30124622Smtm	sendmail_submit_enable="NO"
31124622Smtm	sendmail_outbound_enable="NO"
32124622Smtm	sendmail_msp_queue_enable="NO"
33102864Sgordon	;;
34102864Sgordonesac
35102864Sgordon
3678344Sobriensendmail_precmd()
3778344Sobrien{
3878344Sobrien	# Die if there's pre-8.10 custom configuration file.  This check is
3978344Sobrien	# mandatory for smooth upgrade.  See NetBSD PR 10100 for details.
4078344Sobrien	#
4198184Sgordon	if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then
4278344Sobrien		if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
4378344Sobrien			warn \
4478344Sobrien    "${name} was not started; you have multiple copies of sendmail.cf."
4578344Sobrien			return 1
4678344Sobrien		fi
4778344Sobrien	fi
4878344Sobrien
4978344Sobrien	# check modifications on /etc/mail/aliases
5078344Sobrien	if [ -f "/etc/mail/aliases.db" ]; then
5178344Sobrien		if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
5278344Sobrien			echo \
5378344Sobrien	    "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
5478344Sobrien			/usr/bin/newaliases
5578344Sobrien		fi
5678344Sobrien	else
5778344Sobrien		echo \
5878344Sobrien	    "${name}: /etc/mail/aliases.db not present, generating"
5978344Sobrien			/usr/bin/newaliases
6078344Sobrien	fi
6178344Sobrien
6278344Sobrien	# check couple of common db files, too
6378344Sobrien	for f in genericstable virtusertable domaintable mailertable; do
6498184Sgordon		if [ -r "/etc/mail/$f" -a \
6598184Sgordon		    "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then
6678344Sobrien			echo \
6778344Sobrien    "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating"
6878344Sobrien			/usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f
6978344Sobrien		fi
7078344Sobrien	done
7178344Sobrien}
7278344Sobrien
7378344Sobrienrun_rc_command "$1"
7498184Sgordon
75124622Smtmrequired_files=
76104980Sschweikh
77128366Sfjoeif checkyesno sendmail_submit_enable; then
78124622Smtm	name="sendmail_submit"
79124622Smtm	rcvar=`set_rcvar`
80124622Smtm	start_cmd="${command} ${sendmail_submit_flags}"
81124622Smtm	run_rc_command "$1"
82124622Smtmfi
8398184Sgordon
84128366Sfjoeif checkyesno sendmail_outbound_enable; then
85124622Smtm	name="sendmail_outbound"
86124622Smtm	rcvar=`set_rcvar`
87124622Smtm	start_cmd="${command} ${sendmail_outbound_flags}"
88124622Smtm	run_rc_command "$1"
89124622Smtmfi
9098184Sgordon
91124622Smtmname="sendmail_clientmqueue"
92124622Smtmrcvar="sendmail_msp_queue_enable"
93124622Smtmstart_cmd="${command} ${sendmail_msp_queue_flags}"
94124622Smtmpidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
95124622Smtmrequired_files="/etc/mail/submit.cf"
96124622Smtmrun_rc_command "$1"
97