sendmail revision 127896
1#!/bin/sh
2#
3# $NetBSD: sendmail,v 1.14 2002/02/12 01:26:36 lukem Exp $
4# $FreeBSD: head/etc/rc.d/sendmail 127896 2004-04-05 16:26:22Z fjoe $
5#
6
7# PROVIDE: mail
8# REQUIRE: LOGIN
9# KEYWORD: FreeBSD
10#	we make mail start late, so that things like .forward's are not
11#	processed until the system is fully operational
12
13# XXX - Get together with sendmail mantainer to figure out how to
14#	better handle SENDMAIL_ENABLE and 3rd party MTAs.
15#
16. /etc/rc.subr
17
18name="sendmail"
19rcvar=`set_rcvar`
20required_files="/etc/mail/${name}.cf"
21
22load_rc_config $name
23command=${sendmail_program:-/usr/sbin/sendmail}
24pidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
25procname=${sendmail_procname:-/usr/sbin/sendmail}
26
27case ${sendmail_enable} in
28[Nn][Oo][Nn][Ee])
29	sendmail_enable="NO"
30	sendmail_submit_enable="NO"
31	sendmail_outbound_enable="NO"
32	sendmail_msp_queue_enable="NO"
33	;;
34esac
35
36sendmail_precmd()
37{
38	# Die if there's pre-8.10 custom configuration file.  This check is
39	# mandatory for smooth upgrade.  See NetBSD PR 10100 for details.
40	#
41	if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then
42		if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
43			warn \
44    "${name} was not started; you have multiple copies of sendmail.cf."
45			return 1
46		fi
47	fi
48
49	# check modifications on /etc/mail/aliases
50	if [ -f "/etc/mail/aliases.db" ]; then
51		if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
52			echo \
53	    "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
54			/usr/bin/newaliases
55		fi
56	else
57		echo \
58	    "${name}: /etc/mail/aliases.db not present, generating"
59			/usr/bin/newaliases
60	fi
61
62	# check couple of common db files, too
63	for f in genericstable virtusertable domaintable mailertable; do
64		if [ -r "/etc/mail/$f" -a \
65		    "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then
66			echo \
67    "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating"
68			/usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f
69		fi
70	done
71}
72
73run_rc_command "$1"
74
75required_files=
76
77if ! checkyesno sendmail_submit_enable; then
78	name="sendmail_submit"
79	rcvar=`set_rcvar`
80	start_cmd="${command} ${sendmail_submit_flags}"
81	run_rc_command "$1"
82fi
83
84if ! checkyesno sendmail_outbound_enable; then
85	name="sendmail_outbound"
86	rcvar=`set_rcvar`
87	start_cmd="${command} ${sendmail_outbound_flags}"
88	run_rc_command "$1"
89fi
90
91name="sendmail_clientmqueue"
92rcvar="sendmail_msp_queue_enable"
93start_cmd="${command} ${sendmail_msp_queue_flags}"
94pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
95required_files="/etc/mail/submit.cf"
96run_rc_command "$1"
97