xref: /illumos-gate/usr/src/cmd/nscd/svc-nscd (revision f18d8787)
17c478bd9Sstevel@tonic-gate#!/sbin/sh
27c478bd9Sstevel@tonic-gate#
345916cd2Sjpk#
47c478bd9Sstevel@tonic-gate# CDDL HEADER START
57c478bd9Sstevel@tonic-gate#
67c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
745916cd2Sjpk# Common Development and Distribution License (the "License").
845916cd2Sjpk# You may not use this file except in compliance with the License.
97c478bd9Sstevel@tonic-gate#
107c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
117c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
127c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
137c478bd9Sstevel@tonic-gate# and limitations under the License.
147c478bd9Sstevel@tonic-gate#
157c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
167c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
177c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
187c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
197c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate# CDDL HEADER END
227c478bd9Sstevel@tonic-gate#
23cb5caa98Sdjl#
24bf1e3beeSmichen# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate# Use is subject to license terms.
26*f18d8787SJerry Jelinek# Copyright 2012 Joyent, Inc.  All rights reserved.
277c478bd9Sstevel@tonic-gate#
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate. /lib/svc/share/smf_include.sh
307c478bd9Sstevel@tonic-gate
3145916cd2Sjpk# Trusted Extensions non-global zones need special handling
3245916cd2Sjpk
3345916cd2Sjpkif (smf_is_system_labeled); then
3445916cd2Sjpk	if (smf_is_nonglobalzone); then
35bf1e3beeSmichen		if [ ! -f /var/tsol/doors/nscd_per_label ]; then
3645916cd2Sjpk
37*f18d8787SJerry Jelinek			# If needed create a door to the global zone daemon.
38*f18d8787SJerry Jelinek			if [ -r /var/run/name_service_door ]; then
39bf1e3beeSmichen				rm /var/run/name_service_door
40*f18d8787SJerry Jelinek			fi
41*f18d8787SJerry Jelinek			ln -s /var/tsol/doors/name_service_door  \
42bf1e3beeSmichen				/var/run || exit $SMF_EXIT_ERR_FATAL
4345916cd2Sjpk
44*f18d8787SJerry Jelinek			# If current service duration is not "transient",
45*f18d8787SJerry Jelinek			# create a dummy background process to preserve
46bf1e3beeSmichen			# contract lifetime.
47*f18d8787SJerry Jelinek			duration=""
48*f18d8787SJerry Jelinek			if /bin/svcprop -q -c -p startd/duration $SMF_FMRI
49bf1e3beeSmichen			    then
50*f18d8787SJerry Jelinek				duration=`/bin/svcprop -c -p startd/duration  \
51bf1e3beeSmichen					$SMF_FMRI`
52*f18d8787SJerry Jelinek			fi
53*f18d8787SJerry Jelinek			if [ "$duration" != "transient" ]; then
54*f18d8787SJerry Jelinek				[ -n "$SMF_EXIT_NODAEMON" ] && \
55*f18d8787SJerry Jelinek				    exit $SMF_EXIT_NODAEMON
56*f18d8787SJerry Jelinek				(while true ; do sleep 3600 ; done) &
57*f18d8787SJerry Jelinek			fi
5845916cd2Sjpk
59*f18d8787SJerry Jelinek			# The real daemon is not started in non-global zones,
60bf1e3beeSmichen			# so exit now.
61*f18d8787SJerry Jelinek			exit $SMF_EXIT_OK
62bf1e3beeSmichen		else
63*f18d8787SJerry Jelinek			# remove the door to the global zone daemon
64*f18d8787SJerry Jelinek			if [ -L /var/run/name_service_door ]; then
65*f18d8787SJerry Jelinek				rm /var/run/name_service_door
66*f18d8787SJerry Jelinek			fi
67bf1e3beeSmichen		fi
6845916cd2Sjpk	fi
6945916cd2Sjpkfi
7045916cd2Sjpk
717c478bd9Sstevel@tonic-gateif [ -f /etc/nscd.conf -a -f /usr/sbin/nscd ]; then
72cb5caa98Sdjl	/usr/sbin/nscd < /dev/null > /dev/msglog 2>&1 &
737c478bd9Sstevel@tonic-gateelse
747c478bd9Sstevel@tonic-gate	echo "No /etc/nscd.conf or no /usr/sbin/nscd"
757c478bd9Sstevel@tonic-gate	exit $SMF_EXIT_ERR_CONFIG
767c478bd9Sstevel@tonic-gatefi
77