1 #! /bin/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 #
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27 # ident "@(#)S99nfs4red.sh 1.1 09/04/27 SMI"
28 #
29
30 NAME=`basename $0`
31
32 # Script to restart the 'nfs4red' after system reboot.
33 # This should be installed at /etc/rc3.d as 'S99nfs4red'
34 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] && set -x
35
36 [ ! -d /usr/bin ] && exit
37
38 id | grep "0(root)" > /dev/null 2>&1
39 if [ $? -ne 0 ]; then
40 echo "$NAME: This script require root permission to run."
41 exit 99
42 fi
43
44 ENVFILE=ENV_from_client
45 STF_TMPDIR=Tmpdir_from_client
46
47 # source the environment/config file from client to be consistent
48 . $STF_TMPDIR/$ENVFILE
49
50 NOTICEDIR=$SHRDIR/._Notice__Dir_.
51 LPROG=$STF_TMPDIR/nfs4red
52
53 if [ ! -d $NOTICEDIR ]; then
54 echo "$NAME: NOTICEDIR=[$NOTICEDIR] not found"
55 exit 2
56 fi
57 rm -f $NOTICEDIR/re* $NOTICEDIR/DONE_reboot
58
59 if [ ! -x $LPROG ]; then
60 echo "$NAME: LPROG=[$LPROG] not found/executable"
61 exit 2
62 fi
63 echo "$LPROG \c"
64 $LPROG &
65 echo "started"
66
67 # nfsd should be started by now, notify client
68 i=5
69 timer=2
70 while [ $i -le $timer ]
71 do
72 pgrep nfsd > /dev/null 2>&1
73 if [ $? -eq 0 ]; then
74 i="OK"
75 break
76 fi
77 i=`expr $i + 1`
78 sleep 2
79 done
80 if [ $i = "OK" ]; then
81 echo "ReBoot NFSD(`pgrep nfsd`) started" > $NOTICEDIR/DONE_reboot
82 else
83 echo "ReBoot: nfsd STF_FAILed" > $NOTICEDIR/DONE_reboot
84 fi
85
86 exit 0