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