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