Remove obsolete dev_mkdb(8)
[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 #
6
7 # PROVIDE: mail
8 # REQUIRE: LOGIN
9 #       we make mail start late, so that things like .forward's are not
10 #       processed until the system is fully operational
11
12 # XXX - Get together with sendmail mantainer to figure out how to
13 #       better handle SENDMAIL_ENABLE and 3rd party MTAs.
14 #
15 . /etc/rc.subr
16
17 name="sendmail"
18 rcvar=`set_rcvar`
19 required_files="/etc/mail/${name}.cf"
20 start_precmd="sendmail_precmd"
21 command=${sendmail_program:-/usr/sbin/sendmail}
22 pidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
23 load_rc_config $name
24 case ${sendmail_enable} in
25 [Nn][Oo][Nn][Ee])
26         sendmail_enable="NO"
27         sendmail_submit_enable="NO"
28         sendmail_outbound_enable="NO"
29         sendmail_msp_queue_enable="NO"
30         ;;
31 esac
32
33 sendmail_precmd()
34 {
35         # Die if there's pre-8.10 custom configuration file.  This check is
36         # mandatory for smooth upgrade.  See NetBSD PR 10100 for details.
37         #
38         if checkyesno ${rcvar} && [ -f "/etc/${name}.cf" ]; then
39                 if ! cmp -s "/etc/mail/${name}.cf" "/etc/${name}.cf"; then
40                         warn \
41     "${name} was not started; you have multiple copies of sendmail.cf."
42                         return 1
43                 fi
44         fi
45
46         # check modifications on /etc/mail/aliases
47         if checkyesno sendmail_rebuild_aliases; then
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         fi
60
61         # check couple of common db files, too
62         for f in genericstable virtusertable domaintable mailertable; do
63                 if [ -r "/etc/mail/$f" -a \
64                     "/etc/mail/$f" -nt "/etc/mail/$f.db" ]; then
65                         echo \
66     "${name}: /etc/mail/$f newer than /etc/mail/$f.db, regenerating"
67                         /usr/sbin/makemap hash /etc/mail/$f < /etc/mail/$f
68                 fi
69         done
70 }
71
72 run_rc_command "$1"
73
74 required_files=
75 if ! checkyesno sendmail_enable; then
76         name="sendmail_submit"
77         rcvar=`set_rcvar`
78         start_cmd="${command} ${sendmail_submit_flags}"
79         run_rc_command "$1"
80 fi
81 if ! checkyesno sendmail_outbound_enable; then
82         name="sendmail_outbound"
83         rcvar=`set_rcvar`
84         start_cmd="${command} ${sendmail_outbound_flags}"
85         run_rc_command "$1"
86 fi
87 name="sendmail_clientmqueue"
88 rcvar="sendmail_msp_queue_enable"
89 start_cmd="${command} ${sendmail_msp_queue_flags}"
90 pidfile="${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}"
91 required_files="/etc/mail/submit.cf"
92 run_rc_command "$1"