components/sendmail/files/sendmail-client
author Swaroop M S <swaroop.sadare@oracle.com>
Sat, 15 Oct 2016 10:57:06 +0530
changeset 7122 630f5a510c0a
parent 3649 4006eaaa7d29
permissions -rw-r--r--
24824548 ghostscript package breakup breaks graphviz/libspectre
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3649
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     1
#!/usr/sbin/sh
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     2
#
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     3
# CDDL HEADER START
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     4
#
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     8
#
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    12
# and limitations under the License.
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    13
#
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    19
#
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    20
# CDDL HEADER END
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    21
#
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    22
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    23
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    24
. /lib/svc/share/smf_include.sh
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    25
. /lib/svc/share/sendmail_include.sh
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    26
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    27
CLIENT_PID_FILE="/var/spool/clientmqueue/sm-client.pid"
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    28
SUBMIT_CF="/etc/mail/submit.cf"
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    29
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    30
case "$1" in 
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    31
'refresh')
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    32
        [ -f $CLIENT_PID_FILE ] && kill -1 `head -1 $CLIENT_PID_FILE`
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    33
        ;;
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    34
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    35
'start')
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    36
	exist_or_exit $SENDMAIL
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    37
	[ -f $DEFAULT_FILE ] && . $DEFAULT_FILE
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    38
	#
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    39
	# * CLIENTQUEUEINTERVAL should be set to some legal value;
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    40
	#   sanity checks are done below.
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    41
	# * CLIENTOPTIONS are catch-alls; set with care.
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    42
	#
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    43
	check_queue_interval_syntax $CLIENTQUEUEINTERVAL
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    44
	CLIENTQUEUEINTERVAL=$answer
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    45
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    46
	submit_path=`svcprop -p config/path_to_submit_mc $SMF_FMRI 2>/dev/null`
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    47
	if [ $? -eq 0 -a -n "$submit_path" ]; then
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    48
		turn_m4_crank "$SUBMIT_CF" "$submit_path"
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    49
	fi
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    50
	exist_or_exit "$SUBMIT_CF"
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    51
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    52
	$SENDMAIL -Ac -q$CLIENTQUEUEINTERVAL $CLIENTOPTIONS &
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    53
	;;
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    54
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    55
'stop')
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    56
	if [ -f $CLIENT_PID_FILE ]; then
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    57
		check_and_kill $CLIENT_PID_FILE
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    58
		rm -f $CLIENT_PID_FILE
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    59
	fi
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    60
	# Need to kill the entire service contract to kill all sendmail related
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    61
	# processes
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    62
	smf_kill_contract $2 TERM 1 30
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    63
	ret=$?
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    64
	[ $ret -eq 1 ] && exit 1
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    65
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    66
	# Sendmail can take its time responding to SIGTERM, as it waits for
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    67
	# things like child processes and SMTP connections to clean up.  If
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    68
	# the contract did not empty after TERM, move on to KILL.
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    69
	if [ $ret -eq 2 ] ; then
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    70
		smf_kill_contract $2 KILL 1
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    71
	fi
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    72
	;;
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    73
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    74
*)
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    75
	echo "Usage: $0 { start | stop | refresh }"
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    76
	exit 1
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    77
	;;
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    78
esac
4006eaaa7d29 20355401 add sendmail to Userland
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    79
exit 0