xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.lib/slpd/slp (revision 689b9301078f0c35c7f198fcee8032a0d30eff3a)
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#
23# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26#
27# Service Method Support Script for the SLP service
28#
29# - operates a proxy for slpd which brings up the JVM to run slpd
30#   when required by a client; this prevents keeping JVM's alive
31#   when the service is not in use.
32#
33
34. /lib/svc/share/smf_include.sh
35
36CONF=/etc/inet/slp.conf
37JAVA_BIN=/usr/java/bin/java
38CLASSPATH=/usr/share/lib/slp/slpd.jar
39MAIN_CLASS=com.sun.slp.slpd
40SLPD_HOME=/usr/lib/inet
41SLPD=slpd
42SLPD_BIN=$SLPD_HOME/$SLPD
43
44case "$1" in
45'start')
46	# Start slpd proxy (as a fragile dependency, conf file must exist)
47	$SLPD_BIN -f $CONF >/dev/msglog 2>&1 &
48	;;
49
50'stop')
51	# Kill the slpd proxy.
52	/usr/bin/pkill -x -u 0 -P 1 -z `smf_zonename` $SLPD
53
54	# If a configuration file exists signal a shutdown to the real slpd.
55	[ -f $CONF  ] && {
56		$JAVA_BIN -classpath $CLASSPATH \
57       		    $MAIN_CLASS stop -f $CONF >/dev/msglog 2>&1 &
58
59	       	# Give the above slpd instance a chance to signal
60	       	# a shutdown to the real slpd instance. If after
61	       	# this time it has hung kill it.
62	       	sleep 5
63
64	       	# The pattern must not exceed 80 chars!
65	       	/usr/bin/pkill -x -f -u 0 -P 1,$$  -z `smf_zonename` \
66	       	    "${JAVA_BIN}.*-classpath ${CLASSPATH} .*"
67	}
68
69	# Kill the slpd proxy service contract
70	smf_kill_contract $2 TERM 1
71	[ $? -ne 0 ] && exit 1
72	;;
73*)
74	echo "Usage: $0 { start | stop }"
75	exit 1
76	;;
77esac
78exit 0
79