xref: /illumos-gate/usr/src/cmd/fs.d/nfs/svc/nlockmgr (revision c5bab7026b8e0ac44b25ee08507ea360f177d844)
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# Copyright (c) 2015 by Delphix. All rights reserved.
25# Use is subject to license terms.
26#
27
28#
29# Start the lockd service; we are serving NFS and we need to verify
30# that rpcbind is accepting traffic from the network.
31#
32
33BIND_FMRI=svc:/network/rpc/bind
34do_change=false
35if set -- `svcprop -t -p config/local_only $BIND_FMRI`; then
36	if [ "$2" != boolean ]; then
37		echo "$0: config/local_only property for $BIND_FMRI has wrong "\
38		    "type" 1>&2
39	elif [ "$#" -ne 3 ]; then
40		echo "$0: config/local_only property for $BIND_FMRI has wrong "\
41		    "number of values" 1>&2
42	elif [ "$3" = true ]; then
43		do_change=true
44	fi
45else
46	# If the property is not found, we just set it.
47	do_change=true
48fi
49
50if $do_change
51then
52	# These will generate errors in the log.
53	svccfg -s $BIND_FMRI setprop config/local_only = boolean: false
54	if [ $? != 0 ]; then
55		echo "$0: WARNING setprop failed" 1>&2
56	fi
57
58	svcadm refresh $BIND_FMRI
59	if [ $? != 0 ]; then
60		echo "$0: WARNING svcadm refresh failed" 1>&2
61	fi
62fi
63
64#
65# We have to wait for statd to finish starting up before lockd can
66# start running. If statd hangs after service startup (so SMF thinks
67# it's done) but before it registers an rpc address, we can end up
68# failing in the kernel when we attempt to contact it.
69#
70until /usr/bin/rpcinfo -T tcp 127.0.0.1 status >/dev/null 2>&1
71do
72	sleep 1
73done
74
75exec /usr/lib/nfs/lockd
76