Fix locations of PF helpers.
[dragonfly.git] / etc / rc.d / sendmail
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.3 2004/01/27 00:55:43 rob Exp $
6 #
7
8 # PROVIDE: mail
9 # REQUIRE: LOGIN
10 # KEYWORD: DragonFly
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
19 name="sendmail"
20 rcvar=`set_rcvar`
21 required_files="/etc/mail/${name}.cf"
22 command=${sendmail_program:-/usr/sbin/sendmail}
23 pidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
24 load_rc_config $name
25 case ${sendmail_enable} in
26 [Nn][Oo][Nn][Ee])
27         sendmail_enable="NO"
28         sendmail_submit_enable="NO"
29         sendmail_outbound_enable="NO"
30         sendmail_msp_queue_enable="NO"
31         ;;
32 esac
33
34 sendmail_precmd()
35 {
36         # Die if there's pre-8.10 custom configuration file.  This check is
37         # mandatory for smooth upgrade.  See NetBSD PR 10100 for details.
38         #
39         if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then
40                 if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
41                         warn \
42     "${name} was not started; you have multiple copies of sendmail.cf."
43                         return 1
44                 fi
45         fi
46
47         # check modifications on /etc/mail/aliases
48         if [ -f "/etc/mail/aliases.db" ]; then
49                 if [ "/etc/mail/aliases" -nt "/etc/mail/aliases.db" ]; then
50                         echo \
51             "${name}: /etc/mail/aliases newer than /etc/mail/aliases.db, regenerating"
52                         /usr/bin/newaliases
53                 fi
54         else
55                 echo \
56             "${name}: /etc/mail/aliases.db not present, generating"
57                         /usr/bin/newaliases
58         fi
59
60         # check couple of common db files, too
61         for f in genericstable virtusertable domaintable mailertable; do
62                 if [ -r "/etc/mail/$f" -a \
63                     "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then
64                         echo \
65     "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating"
66                         /usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f
67                 fi
68         done
69 }
70
71 run_rc_command "$1"
72
73 required_files=
74 if ! checkyesno sendmail_enable; then
75         name="sendmail_submit"
76         rcvar=`set_rcvar`
77         start_cmd="${command} ${sendmail_submit_flags}"
78         run_rc_command "$1"
79 fi
80 if ! checkyesno sendmail_outbound_enable; then
81         name="sendmail_outbound"
82         rcvar=`set_rcvar`
83         start_cmd="${command} ${sendmail_outbound_flags}"
84         run_rc_command "$1"
85 fi
86 name="sendmail_clientmqueue"
87 rcvar="sendmail_msp_queue_enable"
88 start_cmd="${command} ${sendmail_msp_queue_flags}"
89 pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
90 required_files="/etc/mail/submit.cf"
91 run_rc_command "$1"