]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - etc/rc.sendmail
Define OPENSSL_DES_LIBDES_COMPATIBILITY so that Heimdal will build with
[FreeBSD/FreeBSD.git] / etc / rc.sendmail
1 #!/bin/sh
2
3 #
4 # Copyright (c) 2002  Gregory Neil Shapiro.  All Rights Reserved.
5 # Copyright (c) 2000, 2002  The FreeBSD Project
6 # All rights reserved.
7 #
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.
16 #
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.
28 #
29 # $FreeBSD$
30 #
31
32 # This script is used by /etc/rc at boot time to start sendmail.  It
33 # is meant to be sendmail specific and not a generic script for all
34 # MTAs.  It is only called by /etc/rc if the rc.conf mta_start_script is
35 # set to /etc/rc.sendmail.  This provides the opportunity for other MTAs
36 # to provide their own startup script.
37
38 # The script is also used by /etc/mail/Makefile to enable the
39 # start/stop/restart targets.
40
41 # The source for the script can be found in src/etc/sendmail/rc.sendmail.
42
43 if [ -r /etc/defaults/rc.conf ]; then
44         . /etc/defaults/rc.conf
45         source_rc_confs
46 elif [ -r /etc/rc.conf ]; then
47         . /etc/rc.conf
48 fi
49
50 # The sendmail binary
51 sendmail_program=${sendmail_program:-/usr/sbin/sendmail}
52
53 # The pid is used to stop and restart the running daemon(s).
54 sendmail_pidfile=${sendmail_pidfile:-/var/run/sendmail.pid}
55 sendmail_mspq_pidfile=${sendmail_mspq_pidfile:-/var/spool/clientmqueue/sm-client.pid}
56
57 start_mta()
58 {
59         case ${sendmail_enable} in
60         [Nn][Oo][Nn][Ee])
61                 ;;
62         [Yy][Ee][Ss])
63                 echo -n ' sendmail'
64                 ${sendmail_program} ${sendmail_flags}
65                 ;;
66         *)
67                 case ${sendmail_submit_enable} in
68                 [Yy][Ee][Ss])
69                         echo -n ' sendmail-submit'
70                         ${sendmail_program} ${sendmail_submit_flags}
71                         ;;
72                 *)
73                         case ${sendmail_outbound_enable} in
74                         [Yy][Ee][Ss])
75                                 echo -n ' sendmail-outbound'
76                                 ${sendmail_program} ${sendmail_outbound_flags}
77                                 ;;
78                         esac
79                         ;;
80                 esac
81                 ;;
82         esac
83 }
84
85 stop_mta()
86 {
87         if [ -r ${sendmail_pidfile} ]; then
88                 echo -n ' sendmail'
89                 kill -TERM `head -1 ${sendmail_pidfile}`
90         else
91                 echo "$0: stop-mta: ${sendmail_pidfile} not found"
92         fi
93 }
94
95 restart_mta()
96 {
97         if [ -r ${sendmail_pidfile} ]; then
98                 echo -n ' sendmail'
99                 kill -HUP `head -1 ${sendmail_pidfile}`
100         else
101                 echo "$0: restart-mta: ${sendmail_pidfile} not found"
102         fi
103 }
104
105 start_mspq()
106 {
107         case ${sendmail_enable} in
108         [Nn][Oo][Nn][Ee])
109                 ;;
110         *)
111                 if [ -r /etc/mail/submit.cf ]; then
112                         case ${sendmail_msp_queue_enable} in
113                         [Yy][Ee][Ss])
114                                 echo -n ' sendmail-clientmqueue'
115                                 ${sendmail_program} ${sendmail_msp_queue_flags}
116                                 ;;
117                         esac
118                 fi
119                 ;;
120         esac
121 }
122
123 stop_mspq()
124 {
125         if [ -r ${sendmail_mspq_pidfile} ]; then
126                 echo -n ' sendmail-clientmqueue'
127                 kill -TERM `head -1 ${sendmail_mspq_pidfile}`
128         else
129                 echo "$0: stop-mspq: ${sendmail_mspq_pidfile} not found"
130         fi
131 }
132
133 restart_mspq()
134 {
135         if [ -r ${sendmail_mspq_pidfile} ]; then
136                 echo -n ' sendmail-clientmqueue'
137                 kill -HUP `head -1 ${sendmail_mspq_pidfile}`
138         else
139                 echo "$0: restart-mspq: ${sendmail_mspq_pidfile} not found"
140         fi
141 }
142
143 # If no argument is given, assume we are being called at boot time.
144 _action=${1:-start}
145
146 case ${_action} in
147 start)
148         start_mta
149         start_mspq
150         ;;
151
152 stop)
153         stop_mta
154         stop_mspq
155         ;;
156
157 restart)
158         restart_mta
159         restart_mspq
160         ;;
161
162 start-mta)
163         start_mta
164         ;;
165
166 stop-mta)
167         stop_mta
168         ;;
169
170 restart-mta)
171         restart_mta
172         ;;
173
174 start-mspq)
175         start_mspq
176         ;;
177
178 stop-mspq)
179         stop_mspq
180         ;;
181
182 restart-mspq)
183         restart_mspq
184         ;;
185
186 *)
187         echo "usage: `basename $0` {start|stop|restart}" >&2
188         echo "       `basename $0` {start-mta|stop-mta|restart-mta}" >&2
189         echo "       `basename $0` {start-mspq|stop-mspq|restart-mspq}" >&2
190         exit 64
191         ;;
192
193 esac
194 exit 0