1*0Sstevel@tonic-gate#!/sbin/sh 2*0Sstevel@tonic-gate# 3*0Sstevel@tonic-gate# CDDL HEADER START 4*0Sstevel@tonic-gate# 5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*0Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*0Sstevel@tonic-gate# with the License. 9*0Sstevel@tonic-gate# 10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*0Sstevel@tonic-gate# See the License for the specific language governing permissions 13*0Sstevel@tonic-gate# and limitations under the License. 14*0Sstevel@tonic-gate# 15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*0Sstevel@tonic-gate# 21*0Sstevel@tonic-gate# CDDL HEADER END 22*0Sstevel@tonic-gate# 23*0Sstevel@tonic-gate# 24*0Sstevel@tonic-gate# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 25*0Sstevel@tonic-gate# Use is subject to license terms. 26*0Sstevel@tonic-gate# 27*0Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate# Start/stop processes required for server NFS 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate. /lib/svc/share/smf_include.sh 32*0Sstevel@tonic-gatezone=${_INIT_ZONENAME:=`/sbin/zonename`} 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gatecase "$1" in 35*0Sstevel@tonic-gate'start') 36*0Sstevel@tonic-gate # The NFS server is not supported in a local zone 37*0Sstevel@tonic-gate if [ $zone != "global" ] ; then 38*0Sstevel@tonic-gate /usr/sbin/svcadm disable svc:/network/nfs/server 39*0Sstevel@tonic-gate echo "The NFS server is not supported in a local zone" 40*0Sstevel@tonic-gate sleep 5 & 41*0Sstevel@tonic-gate exit $SMF_EXIT_OK 42*0Sstevel@tonic-gate fi 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate # If /etc/dfs/dfstab exists and has non-blank or non-commented-out 45*0Sstevel@tonic-gate # lines, then run shareall to export them, and then start up mountd 46*0Sstevel@tonic-gate # and nfsd if anything is exported. 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate startnfsd=0 49*0Sstevel@tonic-gate if [ -f /etc/dfs/dfstab ] && /usr/bin/egrep -v '^[ ]*(#|$)' \ 50*0Sstevel@tonic-gate /etc/dfs/dfstab >/dev/null 2>&1; then 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate /usr/sbin/shareall -F nfs 53*0Sstevel@tonic-gate fi 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate if /usr/bin/grep -s nfs /etc/dfs/sharetab >/dev/null; then 56*0Sstevel@tonic-gate startnfsd=1 57*0Sstevel@tonic-gate fi 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate # When the system comes up umask is not set; so set the mode now 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate [ -f /etc/dfs/sharetab ] && /usr/bin/chmod 644 /etc/dfs/sharetab 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate # Start nfslogd if /etc/nfs/nfslogtab exists and is not empty 64*0Sstevel@tonic-gate # This means that either we just shared new filesystems with 65*0Sstevel@tonic-gate # logging enabled, or they were shared in the previous session 66*0Sstevel@tonic-gate # and their working buffers haven't been processed yet. 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate if [ -s /etc/nfs/nfslogtab ]; then 69*0Sstevel@tonic-gate /usr/lib/nfs/nfslogd & 70*0Sstevel@tonic-gate fi 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate # Options for nfsd are now set in /etc/default/nfs 73*0Sstevel@tonic-gate if [ $startnfsd -ne 0 ]; then 74*0Sstevel@tonic-gate /usr/lib/nfs/mountd 75*0Sstevel@tonic-gate /usr/lib/nfs/nfsd 76*0Sstevel@tonic-gate else 77*0Sstevel@tonic-gate /usr/sbin/svcadm disable svc:/network/nfs/server 78*0Sstevel@tonic-gate echo "No NFS filesystems are shared" 79*0Sstevel@tonic-gate sleep 5 & 80*0Sstevel@tonic-gate fi 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate ;; 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate'stop') 85*0Sstevel@tonic-gate /usr/bin/pkill -x -u 0,1 -z $zone '(nfsd|mountd)' 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate if /usr/bin/grep -s nfs /etc/dfs/sharetab >/dev/null; then 88*0Sstevel@tonic-gate /usr/sbin/unshareall -F nfs 89*0Sstevel@tonic-gate fi 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate # 92*0Sstevel@tonic-gate # Wait up to 10 seconds for nfslogd to gracefully handle SIGHUP 93*0Sstevel@tonic-gate # 94*0Sstevel@tonic-gate /usr/bin/pkill -HUP -x -u 0 -z $zone nfslogd 95*0Sstevel@tonic-gate wtime=10 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate while [ $wtime -gt 0 ]; do 98*0Sstevel@tonic-gate /usr/bin/pgrep -x -u 0 -z $zone nfslogd >/dev/null || break 99*0Sstevel@tonic-gate wtime=`expr $wtime - 1` 100*0Sstevel@tonic-gate sleep 1 101*0Sstevel@tonic-gate done 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate # 104*0Sstevel@tonic-gate # Kill nfslogd more forcefully if it did not shutdown during 105*0Sstevel@tonic-gate # the grace period 106*0Sstevel@tonic-gate # 107*0Sstevel@tonic-gate if [ $wtime -eq 0 ]; then 108*0Sstevel@tonic-gate /usr/bin/pkill -TERM -x -u 0 -z $zone nfslogd 109*0Sstevel@tonic-gate fi 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate # Kill any processes left in service contract 112*0Sstevel@tonic-gate smf_kill_contract $2 TERM 1 113*0Sstevel@tonic-gate [ $? -ne 0 ] && exit 1 114*0Sstevel@tonic-gate ;; 115*0Sstevel@tonic-gate*) 116*0Sstevel@tonic-gate echo "Usage: $0 { start | stop }" 117*0Sstevel@tonic-gate exit 1 118*0Sstevel@tonic-gate ;; 119*0Sstevel@tonic-gateesac 120*0Sstevel@tonic-gateexit $SMF_EXIT_OK 121