xref: /titanic_44/usr/src/cmd/sendmail/lib/sendmail-client (revision 5819f75e225cf93d9c11f52e04ee71c2dcd0eca9)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
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.
8#
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.
13#
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]
19#
20# CDDL HEADER END
21#
22# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24
25. /lib/svc/share/smf_include.sh
26. /lib/svc/share/sendmail_include.sh
27
28CLIENT_PID_FILE="/var/spool/clientmqueue/sm-client.pid"
29SUBMIT_CF="/etc/mail/submit.cf"
30
31case "$1" in
32'refresh')
33        [ -f $CLIENT_PID_FILE ] && kill -1 `head -1 $CLIENT_PID_FILE`
34        ;;
35
36'start')
37	exist_or_exit $SENDMAIL
38	[ -f $DEFAULT_FILE ] && . $DEFAULT_FILE
39	#
40	# * CLIENTQUEUEINTERVAL should be set to some legal value;
41	#   sanity checks are done below.
42	# * CLIENTOPTIONS are catch-alls; set with care.
43	#
44	check_queue_interval_syntax $CLIENTQUEUEINTERVAL
45	CLIENTQUEUEINTERVAL=$answer
46
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"
50	fi
51	exist_or_exit "$SUBMIT_CF"
52
53	$SENDMAIL -Ac -q$CLIENTQUEUEINTERVAL $CLIENTOPTIONS &
54	;;
55
56'stop')
57	if [ -f $CLIENT_PID_FILE ]; then
58		check_and_kill $CLIENT_PID_FILE
59		rm -f $CLIENT_PID_FILE
60	fi
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
66
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
72	fi
73	;;
74
75*)
76	echo "Usage: $0 { start | stop | refresh }"
77	exit 1
78	;;
79esac
80exit 0
81