sendmail revision 98184
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 98184 2002-06-13 22:14:37Z gordon $
578344Sobrien#
678344Sobrien
778344Sobrien# PROVIDE: mail
878344Sobrien# REQUIRE: LOGIN
998184Sgordon# KEYWORD: FreeBSD NetBSD
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`
2078344Sobriencommand="/usr/sbin/${name}"
2178344Sobrienpidfile="/var/run/${name}.pid"
2278344Sobrienrequired_files="/etc/mail/${name}.cf"
2378344Sobrienstart_precmd="sendmail_precmd"
2478344Sobrien
2578344Sobriensendmail_precmd()
2678344Sobrien{
2778344Sobrien	# Die if there's pre-8.10 custom configuration file.  This check is
2878344Sobrien	# mandatory for smooth upgrade.  See NetBSD PR 10100 for details.
2978344Sobrien	#
3098184Sgordon	if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then
3178344Sobrien		if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
3278344Sobrien			warn \
3378344Sobrien    "${name} was not started; you have multiple copies of sendmail.cf."
3478344Sobrien			return 1
3578344Sobrien		fi
3678344Sobrien	fi
3778344Sobrien
3878344Sobrien	# check modifications on /etc/mail/aliases
3978344Sobrien	if [ -f "/etc/mail/aliases.db" ]; then
4078344Sobrien		if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
4178344Sobrien			echo \
4278344Sobrien	    "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
4378344Sobrien			/usr/bin/newaliases
4478344Sobrien		fi
4578344Sobrien	else
4678344Sobrien		echo \
4778344Sobrien	    "${name}: /etc/mail/aliases.db not present, generating"
4878344Sobrien			/usr/bin/newaliases
4978344Sobrien	fi
5078344Sobrien
5178344Sobrien	# check couple of common db files, too
5278344Sobrien	for f in genericstable virtusertable domaintable mailertable; do
5398184Sgordon		if [ -r "/etc/mail/$f" -a \
5498184Sgordon		    "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then
5578344Sobrien			echo \
5678344Sobrien    "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating"
5778344Sobrien			/usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f
5878344Sobrien		fi
5978344Sobrien	done
6078344Sobrien}
6178344Sobrien
6278344Sobrienload_rc_config $name
6378344Sobrienrun_rc_command "$1"
6498184Sgordon
6598184Sgordoncase `${CMD_OSTYPE}` in
6698184SgordonFreeBSD)
6798184Sgordon	case $SENDMAIL_ENABLE in
6898184Sgordon	NONE)
6998184Sgordon		exit
7098184Sgordon		;;
7198184Sgordon	esac
7298184Sgordon	pid_file=
7398184Sgordon	required_files=
7498184Sgordon	start_precmd=
7598184Sgordon
7698184Sgordon	name="sendmail_outbound"
7798184Sgordon	rcvar=`set_rcvar`
7898184Sgordon	start_cmd="/usr/sbin/sendmail $sendmail_outbound_flags"
7998184Sgordon	#command="/usr/sbin/sendmail"
8098184Sgordon
8198184Sgordon	load_rc_config $name
8298184Sgordon	run_rc_command "$1"
8398184Sgordon
8498184Sgordon	name="sendmail_submit"
8598184Sgordon	rcvar=`set_rcvar`
8698184Sgordon	start_cmd="/usr/sbin/sendmail $sendmail_submit_flags"
8798184Sgordon	#command="/usr/sbin/sendmail"
8898184Sgordon
8998184Sgordon	load_rc_config $name
9098184Sgordon	run_rc_command "$1"
9198184Sgordon
9298184Sgordon	name="sendmail_clientmqueue"
9398184Sgordon	rcvar="sendmail_msp_queue_enable"
9498184Sgordon	start_cmd="/usr/sbin/sendmail $sendmail_msp_queue_flags"
9598184Sgordon	#command="/usr/sbin/sendmail"
9698184Sgordon	#command_args="${sendmail_msp_queue_flags}"
9798184Sgordon	required_files="/etc/mail/submit.cf"
9898184Sgordon
9998184Sgordon	load_rc_config $name
10098184Sgordon	run_rc_command "$1"
10198184Sgordon	;;
10298184Sgordonesac
103