178344Sobrien#!/bin/sh 278344Sobrien# 398184Sgordon# $FreeBSD$ 478344Sobrien# 578344Sobrien 678344Sobrien# PROVIDE: mail 7242153Sobrien# REQUIRE: LOGIN FILESYSTEMS 898184Sgordon# we make mail start late, so that things like .forward's are not 998184Sgordon# processed until the system is fully operational 10180564Sdougb# KEYWORD: shutdown 1178344Sobrien 1298184Sgordon# XXX - Get together with sendmail mantainer to figure out how to 1398184Sgordon# better handle SENDMAIL_ENABLE and 3rd party MTAs. 1498184Sgordon# 1578344Sobrien. /etc/rc.subr 1678344Sobrien 1778344Sobrienname="sendmail" 18231653Sdougbrcvar="sendmail_enable" 1978344Sobrienrequired_files="/etc/mail/${name}.cf" 20149606Sgshapirostart_precmd="sendmail_precmd" 21127896Sfjoe 22127896Sfjoeload_rc_config $name 23151809Syarcommand=${sendmail_program:-/usr/sbin/${name}} 24151809Syarpidfile=${sendmail_pidfile:-/var/run/${name}.pid} 25151809Syarprocname=${sendmail_procname:-/usr/sbin/${name}} 2678344Sobrien 27124622Smtmcase ${sendmail_enable} in 28124622Smtm[Nn][Oo][Nn][Ee]) 29124622Smtm sendmail_enable="NO" 30124622Smtm sendmail_submit_enable="NO" 31124622Smtm sendmail_outbound_enable="NO" 32124622Smtm sendmail_msp_queue_enable="NO" 33102864Sgordon ;; 34102864Sgordonesac 35102864Sgordon 36133150Sgshapiro# If sendmail_enable=yes, don't need submit or outbound daemon 37133150Sgshapiroif checkyesno sendmail_enable; then 38133150Sgshapiro sendmail_submit_enable="NO" 39133150Sgshapiro sendmail_outbound_enable="NO" 40133150Sgshapirofi 41133150Sgshapiro 42133150Sgshapiro# If sendmail_submit_enable=yes, don't need outbound daemon 43133150Sgshapiroif checkyesno sendmail_submit_enable; then 44133150Sgshapiro sendmail_outbound_enable="NO" 45133150Sgshapirofi 46133150Sgshapiro 4778344Sobriensendmail_precmd() 4878344Sobrien{ 4978344Sobrien # Die if there's pre-8.10 custom configuration file. This check is 5078344Sobrien # mandatory for smooth upgrade. See NetBSD PR 10100 for details. 5178344Sobrien # 5298184Sgordon if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then 5378344Sobrien if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then 5478344Sobrien warn \ 5578344Sobrien "${name} was not started; you have multiple copies of sendmail.cf." 5678344Sobrien return 1 5778344Sobrien fi 5878344Sobrien fi 5978344Sobrien 6078344Sobrien # check modifications on /etc/mail/aliases 61170618Sgshapiro if checkyesno sendmail_rebuild_aliases; then 62170618Sgshapiro if [ -f "/etc/mail/aliases.db" ]; then 63170618Sgshapiro if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then 64170618Sgshapiro echo \ 65170618Sgshapiro "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating" 66170618Sgshapiro /usr/bin/newaliases 67170618Sgshapiro fi 68170618Sgshapiro else 6978344Sobrien echo \ 70170618Sgshapiro "${name}: /etc/mail/aliases.db not present, generating" 71170618Sgshapiro /usr/bin/newaliases 7278344Sobrien fi 7378344Sobrien fi 7478344Sobrien} 7578344Sobrien 7678344Sobrienrun_rc_command "$1" 7798184Sgordon 78124622Smtmrequired_files= 79104980Sschweikh 80128366Sfjoeif checkyesno sendmail_submit_enable; then 81124622Smtm name="sendmail_submit" 82231653Sdougb rcvar="sendmail_submit_enable" 83124622Smtm start_cmd="${command} ${sendmail_submit_flags}" 84124622Smtm run_rc_command "$1" 85124622Smtmfi 8698184Sgordon 87128366Sfjoeif checkyesno sendmail_outbound_enable; then 88124622Smtm name="sendmail_outbound" 89231653Sdougb rcvar="sendmail_outbound_enable" 90124622Smtm start_cmd="${command} ${sendmail_outbound_flags}" 91124622Smtm run_rc_command "$1" 92124622Smtmfi 9398184Sgordon 94124622Smtmname="sendmail_clientmqueue" 95124622Smtmrcvar="sendmail_msp_queue_enable" 96124622Smtmstart_cmd="${command} ${sendmail_msp_queue_flags}" 97124622Smtmpidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}" 98124622Smtmrequired_files="/etc/mail/submit.cf" 99124622Smtmrun_rc_command "$1" 100