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.1 2003/07/24 06:35:37 dillon Exp $ 6# 7 8# PROVIDE: mail 9# REQUIRE: LOGIN 10# KEYWORD: DragonFly FreeBSD NetBSD 11# we make mail start late, so that things like .forward's are not 12# processed until the system is fully operational 13 14# XXX - Get together with sendmail mantainer to figure out how to 15# better handle SENDMAIL_ENABLE and 3rd party MTAs. 16# 17. /etc/rc.subr 18 19name="sendmail" 20rcvar=`set_rcvar` 21required_files="/etc/mail/${name}.cf" 22 23case ${OSTYPE} in 24DragonFly) 25 command=${sendmail_program:-/usr/sbin/sendmail} 26 pidfile=${sendmail_pidfile:-/var/run/sendmail.pid} 27 load_rc_config $name 28 case ${sendmail_enable} in 29 [Nn][Oo][Nn][Ee]) 30 sendmail_enable="NO" 31 sendmail_submit_enable="NO" 32 sendmail_outbound_enable="NO" 33 sendmail_msp_queue_enable="NO" 34 ;; 35 esac 36 ;; 37 38FreeBSD) 39 command=${sendmail_program:-/usr/sbin/sendmail} 40 pidfile=${sendmail_pidfile:-/var/run/sendmail.pid} 41 42 load_rc_config $name 43 44 case ${sendmail_enable} in 45 [Nn][Oo][Nn][Ee]) 46 sendmail_enable="NO" 47 sendmail_submit_enable="NO" 48 sendmail_outbound_enable="NO" 49 sendmail_msp_queue_enable="NO" 50 ;; 51 esac 52 ;; 53NetBSD) 54 command="/usr/sbin/${name}" 55 pidfile="/var/run/${name}.pid" 56 start_precmd="sendmail_precmd" 57 58 load_rc_config $name 59 ;; 60esac 61 62sendmail_precmd() 63{ 64 # Die if there's pre-8.10 custom configuration file. This check is 65 # mandatory for smooth upgrade. See NetBSD PR 10100 for details. 66 # 67 if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then 68 if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then 69 warn \ 70 "${name} was not started; you have multiple copies of sendmail.cf." 71 return 1 72 fi 73 fi 74 75 # check modifications on /etc/mail/aliases 76 if [ -f "/etc/mail/aliases.db" ]; then 77 if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then 78 echo \ 79 "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating" 80 /usr/bin/newaliases 81 fi 82 else 83 echo \ 84 "${name}: /etc/mail/aliases.db not present, generating" 85 /usr/bin/newaliases 86 fi 87 88 # check couple of common db files, too 89 for f in genericstable virtusertable domaintable mailertable; do 90 if [ -r "/etc/mail/$f" -a \ 91 "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then 92 echo \ 93 "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating" 94 /usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f 95 fi 96 done 97} 98 99run_rc_command "$1" 100 101case ${OSTYPE} in 102DragonFly) 103 required_files= 104 if ! checkyesno sendmail_enable; then 105 name="sendmail_submit" 106 rcvar=`set_rcvar` 107 start_cmd="${command} ${sendmail_submit_flags}" 108 run_rc_command "$1" 109 fi 110 if ! checkyesno sendmail_outbound_enable; then 111 name="sendmail_outbound" 112 rcvar=`set_rcvar` 113 start_cmd="${command} ${sendmail_outbound_flags}" 114 run_rc_command "$1" 115 fi 116 name="sendmail_clientmqueue" 117 rcvar="sendmail_msp_queue_enable" 118 start_cmd="${command} ${sendmail_msp_queue_flags}" 119 pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}" 120 required_files="/etc/mail/submit.cf" 121 run_rc_command "$1" 122 ;; 123FreeBSD) 124 required_files= 125 126 if ! checkyesno sendmail_enable; then 127 name="sendmail_submit" 128 rcvar=`set_rcvar` 129 start_cmd="${command} ${sendmail_submit_flags}" 130 run_rc_command "$1" 131 fi 132 133 if ! checkyesno sendmail_outbound_enable; then 134 name="sendmail_outbound" 135 rcvar=`set_rcvar` 136 start_cmd="${command} ${sendmail_outbound_flags}" 137 run_rc_command "$1" 138 fi 139 140 name="sendmail_clientmqueue" 141 rcvar="sendmail_msp_queue_enable" 142 start_cmd="${command} ${sendmail_msp_queue_flags}" 143 pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}" 144 required_files="/etc/mail/submit.cf" 145 run_rc_command "$1" 146 ;; 147esac 148