19c600e7dSMatthew Dillon#!/bin/sh 29c600e7dSMatthew Dillon# 39c600e7dSMatthew Dillon# $NetBSD: sendmail,v 1.14 2002/02/12 01:26:36 lukem Exp $ 49c600e7dSMatthew Dillon# $FreeBSD: src/etc/rc.d/sendmail,v 1.7 2002/10/12 10:31:31 schweikh Exp $ 59c600e7dSMatthew Dillon# 69c600e7dSMatthew Dillon 79c600e7dSMatthew Dillon# PROVIDE: mail 89c600e7dSMatthew Dillon# REQUIRE: LOGIN 99c600e7dSMatthew Dillon# we make mail start late, so that things like .forward's are not 109c600e7dSMatthew Dillon# processed until the system is fully operational 119c600e7dSMatthew Dillon 129c600e7dSMatthew Dillon# XXX - Get together with sendmail mantainer to figure out how to 139c600e7dSMatthew Dillon# better handle SENDMAIL_ENABLE and 3rd party MTAs. 149c600e7dSMatthew Dillon# 159c600e7dSMatthew Dillon. /etc/rc.subr 169c600e7dSMatthew Dillon 179c600e7dSMatthew Dillonname="sendmail" 189c600e7dSMatthew Dillonrcvar=`set_rcvar` 199c600e7dSMatthew Dillonrequired_files="/etc/mail/${name}.cf" 2003e2a3c5SSascha Wildnerstart_precmd="sendmail_precmd" 219c600e7dSMatthew Dilloncommand=${sendmail_program:-/usr/sbin/sendmail} 229c600e7dSMatthew Dillonpidfile=${sendmail_pidfile:-/var/run/sendmail.pid} 23*e54c8dc8SAaron LI 249c600e7dSMatthew Dillonload_rc_config $name 25*e54c8dc8SAaron LI 269c600e7dSMatthew Dilloncase ${sendmail_enable} in 279c600e7dSMatthew Dillon[Nn][Oo][Nn][Ee]) 289c600e7dSMatthew Dillon sendmail_enable="NO" 299c600e7dSMatthew Dillon sendmail_submit_enable="NO" 309c600e7dSMatthew Dillon sendmail_outbound_enable="NO" 319c600e7dSMatthew Dillon sendmail_msp_queue_enable="NO" 329c600e7dSMatthew Dillon ;; 339c600e7dSMatthew Dillonesac 349c600e7dSMatthew Dillon 359c600e7dSMatthew Dillonsendmail_precmd() 369c600e7dSMatthew Dillon{ 379c600e7dSMatthew Dillon # Die if there's pre-8.10 custom configuration file. This check is 389c600e7dSMatthew Dillon # mandatory for smooth upgrade. See NetBSD PR 10100 for details. 399c600e7dSMatthew Dillon # 409c600e7dSMatthew Dillon if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then 419c600e7dSMatthew Dillon if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then 42*e54c8dc8SAaron LI warn "${name} was not started; " \ 43*e54c8dc8SAaron LI "you have multiple copies of sendmail.cf." 449c600e7dSMatthew Dillon return 1 459c600e7dSMatthew Dillon fi 469c600e7dSMatthew Dillon fi 479c600e7dSMatthew Dillon 489c600e7dSMatthew Dillon # check modifications on /etc/mail/aliases 4903e2a3c5SSascha Wildner if checkyesno sendmail_rebuild_aliases; then 50*e54c8dc8SAaron LI if [ ! -f "/etc/mail/aliases.db" ]; then 51*e54c8dc8SAaron LI echo "${name}: /etc/mail/aliases.db not present, " \ 52*e54c8dc8SAaron LI "generating" 539c600e7dSMatthew Dillon /usr/bin/newaliases 54*e54c8dc8SAaron LI elif [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then 55*e54c8dc8SAaron LI echo "${name}: /etc/mail/aliases newer than " \ 56*e54c8dc8SAaron LI "/etc/mail/aliases.db, regenerating" 579c600e7dSMatthew Dillon /usr/bin/newaliases 589c600e7dSMatthew Dillon fi 5903e2a3c5SSascha Wildner fi 609c600e7dSMatthew Dillon 619c600e7dSMatthew Dillon # check couple of common db files, too 629c600e7dSMatthew Dillon for f in genericstable virtusertable domaintable mailertable; do 63*e54c8dc8SAaron LI if [ -r "/etc/mail/$f" ] && \ 64*e54c8dc8SAaron LI [ "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then 65*e54c8dc8SAaron LI echo "${name}: /etc/mail/$f newer than " \ 66*e54c8dc8SAaron LI "/etc/mail/$f.db, regenerating" 679c600e7dSMatthew Dillon /usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f 689c600e7dSMatthew Dillon fi 699c600e7dSMatthew Dillon done 709c600e7dSMatthew Dillon} 719c600e7dSMatthew Dillon 729c600e7dSMatthew Dillonrun_rc_command "$1" 739c600e7dSMatthew Dillon 749c600e7dSMatthew Dillonrequired_files= 759c600e7dSMatthew Dillonif ! checkyesno sendmail_enable; then 769c600e7dSMatthew Dillon name="sendmail_submit" 779c600e7dSMatthew Dillon rcvar=`set_rcvar` 789c600e7dSMatthew Dillon start_cmd="${command} ${sendmail_submit_flags}" 799c600e7dSMatthew Dillon run_rc_command "$1" 809c600e7dSMatthew Dillonfi 819c600e7dSMatthew Dillonif ! checkyesno sendmail_outbound_enable; then 829c600e7dSMatthew Dillon name="sendmail_outbound" 839c600e7dSMatthew Dillon rcvar=`set_rcvar` 849c600e7dSMatthew Dillon start_cmd="${command} ${sendmail_outbound_flags}" 859c600e7dSMatthew Dillon run_rc_command "$1" 869c600e7dSMatthew Dillonfi 87*e54c8dc8SAaron LI 889c600e7dSMatthew Dillonname="sendmail_clientmqueue" 899c600e7dSMatthew Dillonrcvar="sendmail_msp_queue_enable" 909c600e7dSMatthew Dillonstart_cmd="${command} ${sendmail_msp_queue_flags}" 919c600e7dSMatthew Dillonpidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}" 929c600e7dSMatthew Dillonrequired_files="/etc/mail/submit.cf" 939c600e7dSMatthew Dillonrun_rc_command "$1" 94