xref: /dragonfly/etc/rc.d/sendmail (revision ce0e08e2)
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# $DragonFly: src/etc/rc.d/sendmail,v 1.4 2005/11/19 21:47:32 swildner Exp $
6#
7
8# PROVIDE: mail
9# REQUIRE: LOGIN
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"
21command=${sendmail_program:-/usr/sbin/sendmail}
22pidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
23load_rc_config $name
24case ${sendmail_enable} in
25[Nn][Oo][Nn][Ee])
26	sendmail_enable="NO"
27	sendmail_submit_enable="NO"
28	sendmail_outbound_enable="NO"
29	sendmail_msp_queue_enable="NO"
30	;;
31esac
32
33sendmail_precmd()
34{
35	# Die if there's pre-8.10 custom configuration file.  This check is
36	# mandatory for smooth upgrade.  See NetBSD PR 10100 for details.
37	#
38	if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then
39		if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
40			warn \
41    "${name} was not started; you have multiple copies of sendmail.cf."
42			return 1
43		fi
44	fi
45
46	# check modifications on /etc/mail/aliases
47	if [ -f "/etc/mail/aliases.db" ]; then
48		if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
49			echo \
50	    "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
51			/usr/bin/newaliases
52		fi
53	else
54		echo \
55	    "${name}: /etc/mail/aliases.db not present, generating"
56			/usr/bin/newaliases
57	fi
58
59	# check couple of common db files, too
60	for f in genericstable virtusertable domaintable mailertable; do
61		if [ -r "/etc/mail/$f" -a \
62		    "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then
63			echo \
64    "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating"
65			/usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f
66		fi
67	done
68}
69
70run_rc_command "$1"
71
72required_files=
73if ! checkyesno sendmail_enable; then
74	name="sendmail_submit"
75	rcvar=`set_rcvar`
76	start_cmd="${command} ${sendmail_submit_flags}"
77	run_rc_command "$1"
78fi
79if ! checkyesno sendmail_outbound_enable; then
80	name="sendmail_outbound"
81	rcvar=`set_rcvar`
82	start_cmd="${command} ${sendmail_outbound_flags}"
83	run_rc_command "$1"
84fi
85name="sendmail_clientmqueue"
86rcvar="sendmail_msp_queue_enable"
87start_cmd="${command} ${sendmail_msp_queue_flags}"
88pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
89required_files="/etc/mail/submit.cf"
90run_rc_command "$1"
91