- convert to critical sections
[dragonfly/netmp.git] / etc / rc.sendmail
blobadbc3386eb3cedd6f2b2f3ce0016d58e762a473e
1 #!/bin/sh
4 # Copyright (c) 2002 Gregory Neil Shapiro. All Rights Reserved.
5 # Copyright (c) 2000, 2002 The FreeBSD Project
6 # All rights reserved.
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
10 # are met:
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 # SUCH DAMAGE.
29 # $FreeBSD: src/etc/rc.sendmail,v 1.3.2.1 2002/04/24 17:28:08 gshapiro Exp $
30 # $DragonFly: src/etc/rc.sendmail,v 1.2 2003/06/17 04:24:45 dillon Exp $
33 # This script is used by /etc/rc at boot time to start sendmail. It
34 # is meant to be sendmail specific and not a generic script for all
35 # MTAs. It is only called by /etc/rc if the rc.conf mta_start_script is
36 # set to /etc/rc.sendmail. This provides the opportunity for other MTAs
37 # to provide their own startup script.
39 # The script is also used by /etc/mail/Makefile to enable the
40 # start/stop/restart targets.
42 # The source for the script can be found in src/etc/sendmail/rc.sendmail.
44 if [ -r /etc/defaults/rc.conf ]; then
45 . /etc/defaults/rc.conf
46 source_rc_confs
47 elif [ -r /etc/rc.conf ]; then
48 . /etc/rc.conf
51 # The sendmail binary
52 sendmail_program=${sendmail_program:-/usr/sbin/sendmail}
54 # The pid is used to stop and restart the running daemon(s).
55 sendmail_pidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
56 sendmail_mspq_pidfile=${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}
58 start_mta()
60 case ${sendmail_enable} in
61 [Nn][Oo][Nn][Ee])
63 [Yy][Ee][Ss])
64 echo -n ' sendmail'
65 ${sendmail_program} ${sendmail_flags}
68 case ${sendmail_submit_enable} in
69 [Yy][Ee][Ss])
70 echo -n ' sendmail-submit'
71 ${sendmail_program} ${sendmail_submit_flags}
74 case ${sendmail_outbound_enable} in
75 [Yy][Ee][Ss])
76 echo -n ' sendmail-outbound'
77 ${sendmail_program} ${sendmail_outbound_flags}
79 esac
81 esac
83 esac
86 stop_mta()
88 if [ -r ${sendmail_pidfile} ]; then
89 echo -n ' sendmail'
90 kill -TERM `head -1 ${sendmail_pidfile}`
91 else
92 echo "$0: stop-mta: ${sendmail_pidfile} not found"
96 restart_mta()
98 if [ -r ${sendmail_pidfile} ]; then
99 echo -n ' sendmail'
100 kill -HUP `head -1 ${sendmail_pidfile}`
101 else
102 echo "$0: restart-mta: ${sendmail_pidfile} not found"
106 start_mspq()
108 case ${sendmail_enable} in
109 [Nn][Oo][Nn][Ee])
112 if [ -r /etc/mail/submit.cf ]; then
113 case ${sendmail_msp_queue_enable} in
114 [Yy][Ee][Ss])
115 echo -n ' sendmail-clientmqueue'
116 ${sendmail_program} ${sendmail_msp_queue_flags}
118 esac
121 esac
124 stop_mspq()
126 if [ -r ${sendmail_mspq_pidfile} ]; then
127 echo -n ' sendmail-clientmqueue'
128 kill -TERM `head -1 ${sendmail_mspq_pidfile}`
129 else
130 echo "$0: stop-mspq: ${sendmail_mspq_pidfile} not found"
134 restart_mspq()
136 if [ -r ${sendmail_mspq_pidfile} ]; then
137 echo -n ' sendmail-clientmqueue'
138 kill -HUP `head -1 ${sendmail_mspq_pidfile}`
139 else
140 echo "$0: restart-mspq: ${sendmail_mspq_pidfile} not found"
144 # If no argument is given, assume we are being called at boot time.
145 _action=${1:-start}
147 case ${_action} in
148 start)
149 start_mta
150 start_mspq
153 stop)
154 stop_mta
155 stop_mspq
158 restart)
159 restart_mta
160 restart_mspq
163 start-mta)
164 start_mta
167 stop-mta)
168 stop_mta
171 restart-mta)
172 restart_mta
175 start-mspq)
176 start_mspq
179 stop-mspq)
180 stop_mspq
183 restart-mspq)
184 restart_mspq
188 echo "Usage: `basename $0` {start|stop|restart}" >&2
189 echo " `basename $0` {start-mta|stop-mta|restart-mta}" >&2
190 echo " `basename $0` {start-mspq|stop-mspq|restart-mspq}" >&2
191 exit 64
194 esac
195 exit 0