xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.lib/slpd/slp (revision 1573:7338e65f2666)
10Sstevel@tonic-gate#!/sbin/sh
20Sstevel@tonic-gate#
30Sstevel@tonic-gate# CDDL HEADER START
40Sstevel@tonic-gate#
50Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*1573Sdp# Common Development and Distribution License (the "License").
7*1573Sdp# You may not use this file except in compliance with the License.
80Sstevel@tonic-gate#
90Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate# See the License for the specific language governing permissions
120Sstevel@tonic-gate# and limitations under the License.
130Sstevel@tonic-gate#
140Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate#
200Sstevel@tonic-gate# CDDL HEADER END
210Sstevel@tonic-gate#
220Sstevel@tonic-gate#
23*1573Sdp# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate# Use is subject to license terms.
250Sstevel@tonic-gate#
260Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
270Sstevel@tonic-gate#
280Sstevel@tonic-gate# Service Method Support Script for the SLP service
290Sstevel@tonic-gate#
300Sstevel@tonic-gate# - operates a proxy for slpd which brings up the JVM to run slpd
310Sstevel@tonic-gate#   when required by a client; this prevents keeping JVM's alive
320Sstevel@tonic-gate#   when the service is not in use.
330Sstevel@tonic-gate#
340Sstevel@tonic-gate
350Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
360Sstevel@tonic-gate
370Sstevel@tonic-gateCONF=/etc/inet/slp.conf
380Sstevel@tonic-gateJAVA_BIN=/usr/j2se/bin/java
390Sstevel@tonic-gateCLASSPATH=/usr/share/lib/slp/slpd.jar
400Sstevel@tonic-gateMAIN_CLASS=com.sun.slp.slpd
410Sstevel@tonic-gateSLPD_HOME=/usr/lib/inet
420Sstevel@tonic-gateSLPD=slpd
430Sstevel@tonic-gateSLPD_BIN=$SLPD_HOME/$SLPD
440Sstevel@tonic-gate
450Sstevel@tonic-gatecase "$1" in
460Sstevel@tonic-gate'start')
470Sstevel@tonic-gate	# Start slpd proxy (as a fragile dependency, conf file must exist)
480Sstevel@tonic-gate	$SLPD_BIN -f $CONF >/dev/msglog 2>&1 &
490Sstevel@tonic-gate	;;
500Sstevel@tonic-gate
510Sstevel@tonic-gate'stop')
520Sstevel@tonic-gate	# Kill the slpd proxy.
53*1573Sdp	/usr/bin/pkill -x -u 0 -P 1 -z `smf_zonename` $SLPD
540Sstevel@tonic-gate
550Sstevel@tonic-gate	# If a configuration file exists signal a shutdown to the real slpd.
560Sstevel@tonic-gate	[ -f $CONF  ] && {
570Sstevel@tonic-gate		$JAVA_BIN -classpath $CLASSPATH \
580Sstevel@tonic-gate       		    $MAIN_CLASS stop -f $CONF >/dev/msglog 2>&1 &
590Sstevel@tonic-gate
600Sstevel@tonic-gate	       	# Give the above slpd instance a chance to signal
610Sstevel@tonic-gate	       	# a shutdown to the real slpd instance. If after
620Sstevel@tonic-gate	       	# this time it has hung kill it.
630Sstevel@tonic-gate	       	sleep 5
640Sstevel@tonic-gate
650Sstevel@tonic-gate	       	# The pattern must not exceed 80 chars!
66*1573Sdp	       	/usr/bin/pkill -x -f -u 0 -P 1,$$  -z `smf_zonename` \
670Sstevel@tonic-gate	       	    "${JAVA_BIN}.*-classpath ${CLASSPATH} .*"
680Sstevel@tonic-gate	}
690Sstevel@tonic-gate
700Sstevel@tonic-gate	# Kill the slpd proxy service contract
710Sstevel@tonic-gate	smf_kill_contract $2 TERM 1
720Sstevel@tonic-gate	[ $? -ne 0 ] && exit 1
730Sstevel@tonic-gate	;;
740Sstevel@tonic-gate*)
750Sstevel@tonic-gate	echo "Usage: $0 { start | stop }"
760Sstevel@tonic-gate	exit 1
770Sstevel@tonic-gate	;;
780Sstevel@tonic-gateesac
790Sstevel@tonic-gateexit 0
80