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