xref: /illumos-gate/usr/src/cmd/fs.d/nfs/svc/nlockmgr (revision 7b4e6d92)
1064ed339Sjjj#!/sbin/sh
2064ed339Sjjj#
3064ed339Sjjj# CDDL HEADER START
4064ed339Sjjj#
5064ed339Sjjj# The contents of this file are subject to the terms of the
6064ed339Sjjj# Common Development and Distribution License (the "License").
7064ed339Sjjj# You may not use this file except in compliance with the License.
8064ed339Sjjj#
9064ed339Sjjj# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10064ed339Sjjj# or http://www.opensolaris.org/os/licensing.
11064ed339Sjjj# See the License for the specific language governing permissions
12064ed339Sjjj# and limitations under the License.
13064ed339Sjjj#
14064ed339Sjjj# When distributing Covered Code, include this CDDL HEADER in each
15064ed339Sjjj# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16064ed339Sjjj# If applicable, add the following below this CDDL HEADER, with the
17064ed339Sjjj# fields enclosed by brackets "[]" replaced with your own identifying
18064ed339Sjjj# information: Portions Copyright [yyyy] [name of copyright owner]
19064ed339Sjjj#
20064ed339Sjjj# CDDL HEADER END
21064ed339Sjjj#
22064ed339Sjjj#
23064ed339Sjjj# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*7b4e6d92SPaul Dagnelie# Copyright (c) 2015 by Delphix. All rights reserved.
25064ed339Sjjj# Use is subject to license terms.
26064ed339Sjjj#
27064ed339Sjjj
28064ed339Sjjj#
29064ed339Sjjj# Start the lockd service; we are serving NFS and we need to verify
30064ed339Sjjj# that rpcbind is accepting traffic from the network.
31064ed339Sjjj#
32064ed339Sjjj
33064ed339SjjjBIND_FMRI=svc:/network/rpc/bind
34064ed339Sjjjdo_change=false
35064ed339Sjjjif set -- `svcprop -t -p config/local_only $BIND_FMRI`; then
36064ed339Sjjj	if [ "$2" != boolean ]; then
37064ed339Sjjj		echo "$0: config/local_only property for $BIND_FMRI has wrong "\
38064ed339Sjjj		    "type" 1>&2
39064ed339Sjjj	elif [ "$#" -ne 3 ]; then
40064ed339Sjjj		echo "$0: config/local_only property for $BIND_FMRI has wrong "\
41064ed339Sjjj		    "number of values" 1>&2
42064ed339Sjjj	elif [ "$3" = true ]; then
43064ed339Sjjj		do_change=true
44064ed339Sjjj	fi
45064ed339Sjjjelse
46064ed339Sjjj	# If the property is not found, we just set it.
47064ed339Sjjj	do_change=true
48064ed339Sjjjfi
49064ed339Sjjj
50064ed339Sjjjif $do_change
51064ed339Sjjjthen
52064ed339Sjjj	# These will generate errors in the log.
53064ed339Sjjj	svccfg -s $BIND_FMRI setprop config/local_only = boolean: false
54064ed339Sjjj	if [ $? != 0 ]; then
55064ed339Sjjj		echo "$0: WARNING setprop failed" 1>&2
56064ed339Sjjj	fi
57064ed339Sjjj
58064ed339Sjjj	svcadm refresh $BIND_FMRI
59064ed339Sjjj	if [ $? != 0 ]; then
60064ed339Sjjj		echo "$0: WARNING svcadm refresh failed" 1>&2
61064ed339Sjjj	fi
62064ed339Sjjjfi
63064ed339Sjjj
64*7b4e6d92SPaul Dagnelie#
65*7b4e6d92SPaul Dagnelie# We have to wait for statd to finish starting up before lockd can
66*7b4e6d92SPaul Dagnelie# start running. If statd hangs after service startup (so SMF thinks
67*7b4e6d92SPaul Dagnelie# it's done) but before it registers an rpc address, we can end up
68*7b4e6d92SPaul Dagnelie# failing in the kernel when we attempt to contact it.
69*7b4e6d92SPaul Dagnelie#
70*7b4e6d92SPaul Dagnelieuntil /usr/bin/rpcinfo -T tcp 127.0.0.1 status >/dev/null 2>&1
71*7b4e6d92SPaul Dagneliedo
72*7b4e6d92SPaul Dagnelie	sleep 1
73*7b4e6d92SPaul Dagneliedone
74*7b4e6d92SPaul Dagnelie
75064ed339Sjjjexec /usr/lib/nfs/lockd
76