xref: /onnv-gate/usr/src/cmd/hotplugd/svc-hotplug (revision 10923:df470fd79c3c)
1*10923SEvan.Yan@Sun.COM#!/sbin/sh
2*10923SEvan.Yan@Sun.COM#
3*10923SEvan.Yan@Sun.COM# CDDL HEADER START
4*10923SEvan.Yan@Sun.COM#
5*10923SEvan.Yan@Sun.COM# The contents of this file are subject to the terms of the
6*10923SEvan.Yan@Sun.COM# Common Development and Distribution License (the "License").
7*10923SEvan.Yan@Sun.COM# You may not use this file except in compliance with the License.
8*10923SEvan.Yan@Sun.COM#
9*10923SEvan.Yan@Sun.COM# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*10923SEvan.Yan@Sun.COM# or http://www.opensolaris.org/os/licensing.
11*10923SEvan.Yan@Sun.COM# See the License for the specific language governing permissions
12*10923SEvan.Yan@Sun.COM# and limitations under the License.
13*10923SEvan.Yan@Sun.COM#
14*10923SEvan.Yan@Sun.COM# When distributing Covered Code, include this CDDL HEADER in each
15*10923SEvan.Yan@Sun.COM# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*10923SEvan.Yan@Sun.COM# If applicable, add the following below this CDDL HEADER, with the
17*10923SEvan.Yan@Sun.COM# fields enclosed by brackets "[]" replaced with your own identifying
18*10923SEvan.Yan@Sun.COM# information: Portions Copyright [yyyy] [name of copyright owner]
19*10923SEvan.Yan@Sun.COM#
20*10923SEvan.Yan@Sun.COM# CDDL HEADER END
21*10923SEvan.Yan@Sun.COM#
22*10923SEvan.Yan@Sun.COM
23*10923SEvan.Yan@Sun.COM#
24*10923SEvan.Yan@Sun.COM# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25*10923SEvan.Yan@Sun.COM# Use is subject to license terms.
26*10923SEvan.Yan@Sun.COM#
27*10923SEvan.Yan@Sun.COM
28*10923SEvan.Yan@Sun.COM#
29*10923SEvan.Yan@Sun.COM# Startup script for the hotplugd(1M) daemon.
30*10923SEvan.Yan@Sun.COM#
31*10923SEvan.Yan@Sun.COM
32*10923SEvan.Yan@Sun.COM. /lib/svc/share/smf_include.sh
33*10923SEvan.Yan@Sun.COM
34*10923SEvan.Yan@Sun.COMHOTPLUGD_DOOR=/var/run/hotplugd_door
35*10923SEvan.Yan@Sun.COM
36*10923SEvan.Yan@Sun.COM# The hotplug service is only supported in the global zone.
37*10923SEvan.Yan@Sun.COMif smf_is_nonglobalzone; then
38*10923SEvan.Yan@Sun.COM	/usr/sbin/svcadm disable $SMF_FMRI
39*10923SEvan.Yan@Sun.COM	echo "$SMF_FMRI is not supported in a local zone"
40*10923SEvan.Yan@Sun.COM	sleep 5 &
41*10923SEvan.Yan@Sun.COM	exit $SMF_EXIT_OK
42*10923SEvan.Yan@Sun.COMfi
43*10923SEvan.Yan@Sun.COM
44*10923SEvan.Yan@Sun.COM# If a hotplug door exists, check for a hotplugd process and exit
45*10923SEvan.Yan@Sun.COM# if the daemon is already running.
46*10923SEvan.Yan@Sun.COMif [ -f $HOTPLUGD_DOOR ]; then
47*10923SEvan.Yan@Sun.COM	if /usr/bin/pgrep -x -u 0 hotplugd >/dev/null 2>&1; then
48*10923SEvan.Yan@Sun.COM		echo "$0: hotplugd is already running"
49*10923SEvan.Yan@Sun.COM		exit 1
50*10923SEvan.Yan@Sun.COM	fi
51*10923SEvan.Yan@Sun.COMfi
52*10923SEvan.Yan@Sun.COM
53*10923SEvan.Yan@Sun.COMrm -f $HOTPLUGD_DOOR
54*10923SEvan.Yan@Sun.COMexec /usr/lib/hotplugd
55