8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sendmail / lib / sendmail-client
blob5324e831696935e15132210d8c76aef88519d21c
1 #!/sbin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
22 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
25 . /lib/svc/share/smf_include.sh
26 . /lib/svc/share/sendmail_include.sh
28 CLIENT_PID_FILE="/var/spool/clientmqueue/sm-client.pid"
29 SUBMIT_CF="/etc/mail/submit.cf"
31 case "$1" in
32 'refresh')
33 [ -f $CLIENT_PID_FILE ] && kill -1 `head -1 $CLIENT_PID_FILE`
36 'start')
37 exist_or_exit $SENDMAIL
38 [ -f $DEFAULT_FILE ] && . $DEFAULT_FILE
40 # * CLIENTQUEUEINTERVAL should be set to some legal value;
41 # sanity checks are done below.
42 # * CLIENTOPTIONS are catch-alls; set with care.
44 check_queue_interval_syntax $CLIENTQUEUEINTERVAL
45 CLIENTQUEUEINTERVAL=$answer
47 submit_path=`svcprop -p config/path_to_submit_mc $SMF_FMRI 2>/dev/null`
48 if [ $? -eq 0 -a -n "$submit_path" ]; then
49 turn_m4_crank "$SUBMIT_CF" "$submit_path"
51 exist_or_exit "$SUBMIT_CF"
53 $SENDMAIL -Ac -q$CLIENTQUEUEINTERVAL $CLIENTOPTIONS &
56 'stop')
57 if [ -f $CLIENT_PID_FILE ]; then
58 check_and_kill $CLIENT_PID_FILE
59 rm -f $CLIENT_PID_FILE
61 # Need to kill the entire service contract to kill all sendmail related
62 # processes
63 smf_kill_contract $2 TERM 1 30
64 ret=$?
65 [ $ret -eq 1 ] && exit 1
67 # Sendmail can take its time responding to SIGTERM, as it waits for
68 # things like child processes and SMTP connections to clean up. If
69 # the contract did not empty after TERM, move on to KILL.
70 if [ $ret -eq 2 ] ; then
71 smf_kill_contract $2 KILL 1
76 echo "Usage: $0 { start | stop | refresh }"
77 exit 1
79 esac
80 exit 0