1 #! /usr/bin/ksh -p
   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 # cleanup script for nfs server environment
  28 
  29 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x
  30 
  31 id | grep "0(root)" > /dev/null 2>&1
  32 if [ $? -ne 0 ]; then
  33         echo "Must be root to run this script."
  34         exit $OTHER
  35 fi
  36 
  37 NAME=`basename $0`
  38 DIR=`dirname $0`
  39 TESTROOT=${TESTROOT:-"$DIR/../"}
  40 TESTSH=$TESTROOT/testsh
  41 
  42 # sourcing framework global environment variables created after go_setup
  43 # and for this purpose only this file should be sourced
  44 CONFIGFILE=/var/tmp/nfsv4/config/config.suite
  45 if [[ ! -f $CONFIGFILE ]]; then
  46         echo "$NAME: CONFIGFILE[$CONFIGFILE] not found;"
  47         echo "\texit UNINITIATED."
  48         exit 6
  49 fi
  50 . $CONFIGFILE
  51 
  52 # sourcing useful functions
  53 . $TESTSH
  54 
  55 # now cleanup the SERVER
  56 execute $SERVER root \
  57         "ksh ${CONFIGDIR}/recov_setserver -c" \
  58         > ${TMPDIR}/rsh.out.$$ 2>&1
  59 grep "OKAY" ${TMPDIR}/rsh.out.$$ | grep -v echo > /dev/null 2>&1
  60 if [ $? -ne 0 ]; then
  61         grep ERROR ${TMPDIR}/rsh.out.$$ | grep -v echo > /dev/null 2>&1
  62         if [ $? -eq 0 ]; then
  63                 echo "$NAME: cleanup $SERVER failed:"
  64                 cat ${TMPDIR}/rsh.out.$$
  65         fi
  66 else
  67         # If server returned some warning, print it out
  68         grep "WARNING" $TMPDIR/rsh.out.$$ | grep -v echo > /dev/null 2>&1
  69         if [ $? -eq 0 ]; then
  70                 cat $TMPDIR/rsh.out.$$
  71         fi
  72 fi
  73 [ $DEBUG != "0" ] && cat $TMPDIR/rsh.out.$$
  74 
  75 echo "$NAME: $SERVER recov_cleanup OK!! "
  76 echo "$NAME: PASS"
  77 exit $PASS