sendmail revision 104980
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 104980 2002-10-12 10:31:31Z schweikh $ 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` 2078344Sobrienrequired_files="/etc/mail/${name}.cf" 2178344Sobrien 22103019Sgordoncase ${OSTYPE} in 23102864SgordonFreeBSD) 24102864Sgordon command=${sendmail_program:-/usr/sbin/sendmail} 25102864Sgordon pidfile=${sendmail_pidfile:-/var/run/sendmail.pid} 26102864Sgordon 27102864Sgordon load_rc_config $name 28102864Sgordon 29102864Sgordon case ${sendmail_enable} in 30102864Sgordon [Nn][Oo][Nn][Ee]) 31102864Sgordon sendmail_enable="NO" 32102864Sgordon sendmail_submit_enable="NO" 33102864Sgordon sendmail_outbound_enable="NO" 34102864Sgordon sendmail_msp_queue_enable="NO" 35102864Sgordon ;; 36102864Sgordon esac 37102864Sgordon ;; 38102864SgordonNetBSD) 39102864Sgordon command="/usr/sbin/${name}" 40102864Sgordon pidfile="/var/run/${name}.pid" 41102864Sgordon start_precmd="sendmail_precmd" 42102864Sgordon 43102864Sgordon load_rc_config $name 44102864Sgordon ;; 45102864Sgordonesac 46102864Sgordon 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 6178344Sobrien if [ -f "/etc/mail/aliases.db" ]; then 6278344Sobrien if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then 6378344Sobrien echo \ 6478344Sobrien "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating" 6578344Sobrien /usr/bin/newaliases 6678344Sobrien fi 6778344Sobrien else 6878344Sobrien echo \ 6978344Sobrien "${name}: /etc/mail/aliases.db not present, generating" 7078344Sobrien /usr/bin/newaliases 7178344Sobrien fi 7278344Sobrien 7378344Sobrien # check couple of common db files, too 7478344Sobrien for f in genericstable virtusertable domaintable mailertable; do 7598184Sgordon if [ -r "/etc/mail/$f" -a \ 7698184Sgordon "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then 7778344Sobrien echo \ 7878344Sobrien "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating" 7978344Sobrien /usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f 8078344Sobrien fi 8178344Sobrien done 8278344Sobrien} 8378344Sobrien 8478344Sobrienrun_rc_command "$1" 8598184Sgordon 86103019Sgordoncase ${OSTYPE} in 8798184SgordonFreeBSD) 88102864Sgordon required_files= 89104980Sschweikh 90103264Sgordon if ! checkyesno sendmail_enable; then 91102864Sgordon name="sendmail_submit" 92102864Sgordon rcvar=`set_rcvar` 93102864Sgordon start_cmd="${command} ${sendmail_submit_flags}" 94102864Sgordon run_rc_command "$1" 95103264Sgordon fi 9698184Sgordon 97102864Sgordon if ! checkyesno sendmail_outbound_enable; then 98102864Sgordon name="sendmail_outbound" 99102864Sgordon rcvar=`set_rcvar` 100102864Sgordon start_cmd="${command} ${sendmail_outbound_flags}" 101102864Sgordon run_rc_command "$1" 102102864Sgordon fi 10398184Sgordon 10498184Sgordon name="sendmail_clientmqueue" 10598184Sgordon rcvar="sendmail_msp_queue_enable" 106102864Sgordon start_cmd="${command} ${sendmail_msp_queue_flags}" 107102864Sgordon pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}" 10898184Sgordon required_files="/etc/mail/submit.cf" 10998184Sgordon run_rc_command "$1" 11098184Sgordon ;; 11198184Sgordonesac 112