sendmail revision 149606
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 149606 2005-08-30 03:41:59Z gshapiro $
578344Sobrien#
678344Sobrien
778344Sobrien# PROVIDE: mail
8140339Sobrien# REQUIRE: LOGIN cleanvar
998184Sgordon#	we make mail start late, so that things like .forward's are not
1098184Sgordon#	processed until the system is fully operational
1178344Sobrien
1298184Sgordon# XXX - Get together with sendmail mantainer to figure out how to
1398184Sgordon#	better handle SENDMAIL_ENABLE and 3rd party MTAs.
1498184Sgordon#
1578344Sobrien. /etc/rc.subr
1678344Sobrien
1778344Sobrienname="sendmail"
1898184Sgordonrcvar=`set_rcvar`
1978344Sobrienrequired_files="/etc/mail/${name}.cf"
20149606Sgshapirostart_precmd="sendmail_precmd"
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
36133150Sgshapiro# If sendmail_enable=yes, don't need submit or outbound daemon
37133150Sgshapiroif checkyesno sendmail_enable; then
38133150Sgshapiro	sendmail_submit_enable="NO"
39133150Sgshapiro	sendmail_outbound_enable="NO"
40133150Sgshapirofi
41133150Sgshapiro
42133150Sgshapiro# If sendmail_submit_enable=yes, don't need outbound daemon
43133150Sgshapiroif checkyesno sendmail_submit_enable; then
44133150Sgshapiro	sendmail_outbound_enable="NO"
45133150Sgshapirofi
46133150Sgshapiro
4778344Sobriensendmail_precmd()
4878344Sobrien{
4978344Sobrien	# Die if there's pre-8.10 custom configuration file.  This check is
5078344Sobrien	# mandatory for smooth upgrade.  See NetBSD PR 10100 for details.
5178344Sobrien	#
5298184Sgordon	if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then
5378344Sobrien		if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
5478344Sobrien			warn \
5578344Sobrien    "${name} was not started; you have multiple copies of sendmail.cf."
5678344Sobrien			return 1
5778344Sobrien		fi
5878344Sobrien	fi
5978344Sobrien
6078344Sobrien	# check modifications on /etc/mail/aliases
6178344Sobrien	if [ -f "/etc/mail/aliases.db" ]; then
6278344Sobrien		if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
6378344Sobrien			echo \
6478344Sobrien	    "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
6578344Sobrien			/usr/bin/newaliases
6678344Sobrien		fi
6778344Sobrien	else
6878344Sobrien		echo \
6978344Sobrien	    "${name}: /etc/mail/aliases.db not present, generating"
7078344Sobrien			/usr/bin/newaliases
7178344Sobrien	fi
7278344Sobrien}
7378344Sobrien
7478344Sobrienrun_rc_command "$1"
7598184Sgordon
76124622Smtmrequired_files=
77104980Sschweikh
78128366Sfjoeif checkyesno sendmail_submit_enable; then
79124622Smtm	name="sendmail_submit"
80124622Smtm	rcvar=`set_rcvar`
81124622Smtm	start_cmd="${command} ${sendmail_submit_flags}"
82124622Smtm	run_rc_command "$1"
83124622Smtmfi
8498184Sgordon
85128366Sfjoeif checkyesno sendmail_outbound_enable; then
86124622Smtm	name="sendmail_outbound"
87124622Smtm	rcvar=`set_rcvar`
88124622Smtm	start_cmd="${command} ${sendmail_outbound_flags}"
89124622Smtm	run_rc_command "$1"
90124622Smtmfi
9198184Sgordon
92124622Smtmname="sendmail_clientmqueue"
93124622Smtmrcvar="sendmail_msp_queue_enable"
94124622Smtmstart_cmd="${command} ${sendmail_msp_queue_flags}"
95124622Smtmpidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
96124622Smtmrequired_files="/etc/mail/submit.cf"
97124622Smtmrun_rc_command "$1"
98