sendmail revision 104980
113044Sasami#!/bin/sh 2116111Sphk# 313044Sasami# $NetBSD: sendmail,v 1.14 2002/02/12 01:26:36 lukem Exp $ 413044Sasami# $FreeBSD: head/etc/rc.d/sendmail 104980 2002-10-12 10:31:31Z schweikh $ 513044Sasami# 613044Sasami 713044Sasami# PROVIDE: mail 813044Sasami# REQUIRE: LOGIN 913044Sasami# KEYWORD: FreeBSD NetBSD 1013044Sasami# we make mail start late, so that things like .forward's are not 1113044Sasami# processed until the system is fully operational 1213044Sasami 1313044Sasami# XXX - Get together with sendmail mantainer to figure out how to 1413044Sasami# better handle SENDMAIL_ENABLE and 3rd party MTAs. 1513044Sasami# 1613044Sasami. /etc/rc.subr 1713044Sasami 1813044Sasaminame="sendmail" 1913044Sasamircvar=`set_rcvar` 2013044Sasamirequired_files="/etc/mail/${name}.cf" 2113044Sasami 2213044Sasamicase ${OSTYPE} in 2313044SasamiFreeBSD) 2413044Sasami command=${sendmail_program:-/usr/sbin/sendmail} 2513044Sasami pidfile=${sendmail_pidfile:-/var/run/sendmail.pid} 2613044Sasami 2713044Sasami load_rc_config $name 2813044Sasami 2913044Sasami case ${sendmail_enable} in 3013044Sasami [Nn][Oo][Nn][Ee]) 3113044Sasami sendmail_enable="NO" 3213044Sasami sendmail_submit_enable="NO" 3313044Sasami sendmail_outbound_enable="NO" 34114589Sobrien sendmail_msp_queue_enable="NO" 35114589Sobrien ;; 3636628Scharnier esac 3713044Sasami ;; 3848568SbillfNetBSD) 3945329Speter command="/usr/sbin/${name}" 4013044Sasami pidfile="/var/run/${name}.pid" 4113044Sasami start_precmd="sendmail_precmd" 4213044Sasami 4313044Sasami load_rc_config $name 4469793Sobrien ;; 4513044Sasamiesac 4613044Sasami 4713044Sasamisendmail_precmd() 4813044Sasami{ 49115730Sphk # Die if there's pre-8.10 custom configuration file. This check is 5013044Sasami # mandatory for smooth upgrade. See NetBSD PR 10100 for details. 51116111Sphk # 52116111Sphk if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then 5313044Sasami if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then 5413044Sasami warn \ 5513044Sasami "${name} was not started; you have multiple copies of sendmail.cf." 5613044Sasami return 1 5713044Sasami fi 58109417Sphk fi 5913044Sasami 6013044Sasami # check modifications on /etc/mail/aliases 61109417Sphk if [ -f "/etc/mail/aliases.db" ]; then 62116111Sphk if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then 6313044Sasami echo \ 6413044Sasami "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating" 65116111Sphk /usr/bin/newaliases 6613762Sasami fi 67116111Sphk else 68116111Sphk echo \ 6913044Sasami "${name}: /etc/mail/aliases.db not present, generating" 7013044Sasami /usr/bin/newaliases 7113044Sasami fi 7213044Sasami 7313044Sasami # check couple of common db files, too 7413044Sasami for f in genericstable virtusertable domaintable mailertable; do 7513044Sasami if [ -r "/etc/mail/$f" -a \ 7613044Sasami "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then 7713044Sasami echo \ 7892539Simp "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating" 7992539Simp /usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f 8092539Simp fi 8192539Simp done 82109417Sphk} 8392539Simp 8413044Sasamirun_rc_command "$1" 8513044Sasami 8692539Simpcase ${OSTYPE} in 8713044SasamiFreeBSD) 8813044Sasami required_files= 8913044Sasami 9083329Sru if ! checkyesno sendmail_enable; then 9113044Sasami name="sendmail_submit" 9213044Sasami rcvar=`set_rcvar` 9313044Sasami start_cmd="${command} ${sendmail_submit_flags}" 9413044Sasami run_rc_command "$1" 9513044Sasami fi 9613044Sasami 9713044Sasami if ! checkyesno sendmail_outbound_enable; then 9813044Sasami name="sendmail_outbound" 9913044Sasami rcvar=`set_rcvar` 10013044Sasami start_cmd="${command} ${sendmail_outbound_flags}" 10113044Sasami run_rc_command "$1" 10213044Sasami fi 10313044Sasami 10413044Sasami name="sendmail_clientmqueue" 10513044Sasami rcvar="sendmail_msp_queue_enable" 10613044Sasami start_cmd="${command} ${sendmail_msp_queue_flags}" 10713044Sasami pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}" 10813044Sasami required_files="/etc/mail/submit.cf" 10913044Sasami run_rc_command "$1" 11013044Sasami ;; 11113044Sasamiesac 11213044Sasami