Home | History | Annotate | Download | only in nfsv4
      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 2009 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 # ident	"@(#)go_setup.ksh	1.3	09/07/23 SMI"
     28 #
     29 # Setup server test files/directories, export them, and check
     30 # that NFSv4 is registered.
     31 
     32 [[ -n $DEBUG ]] && [[ $DEBUG != 0 ]] && set -x
     33 
     34 NAME=$(basename $0)
     35 CDIR=$(dirname $0)
     36 NSPC=$(echo $NAME | sed 's/./ /g')
     37 TMPDIR=${TMPDIR:-"/var/tmp"}
     38 DEBUG=${DEBUG:-"0"}; export DEBUG	# export it for tcl.init
     39 
     40 # ================================ include =================================== #
     41 # sourcing framework global environment variables
     42 ENVFILE="./nfs4test.env"
     43 if [[ ! -f $ENVFILE ]]; then
     44         echo "$NAME: ENVFILE[$ENVFILE] not found;"
     45         echo "\texit UNINITIATED."
     46         exit 6
     47 fi
     48 . $ENVFILE
     49 
     50 # sourcing support functions
     51 LIBFILE="./testsh"
     52 if [[ ! -f $LIBFILE ]]; then
     53         echo "$NAME: LIBFILE[$LIBFILE] not found;"
     54         echo "\texit UNINITIATED."
     55         exit $UNINITIATED
     56 fi
     57 . $LIBFILE
     58 
     59 # check v4config file
     60 V4CFGFILE="./v4test.cfg"
     61 if [[ ! -f $V4CFGFILE ]]; then
     62         echo "$NAME: V4CFGFILE[$V4CFGFILE] not found;"
     63         echo "\texit UNINITIATED."
     64         exit $UNINITIATED
     65 fi
     66 . $V4CFGFILE
     67 
     68 # =============================== functions ================================== #
     69 function cleanup { # ensure umount MNTPTR & exit
     70 	[[ -n $DEBUG && $DEBUG != 0 ]] && set -x
     71 
     72 	mount -p | grep -w "$MNTPTR" > /dev/null 2>&1
     73 	if (( $? != 0 )); then
     74 		rm -f $TMPDIR/*.$$
     75         	exit $1
     76 	fi
     77 
     78         # Need to unmount the test directory
     79         umount $MNTPTR > $TMPDIR/$NAME.umount.$$ 2>&1
     80         if (( $? != 0 )); then
     81                 echo "$NAME: cleanup - umount $MNTPTR failed"
     82                 cat $TMPDIR/$NAME.umount.$$
     83 	fi
     84 
     85 	rm -f $TMPDIR/*.$$
     86         exit $1
     87 }
     88 
     89 # get full name of machine
     90 function get_fullname {
     91 	[[ -n $DEBUG && $DEBUG != 0 ]] && set -x
     92 
     93 	typeset mach=$1
     94 	typeset res=$(get_domain $mach "FQDN")
     95 
     96 	# if get_domain give no results, use the orginal value.
     97 	[[ -z $res ]] && res=$mach
     98 	echo $res
     99 
    100 	ping $res > /dev/null 2>&1
    101 	return $?
    102 }
    103 
    104 # ================================= main ===================================== #
    105 # must be root to run
    106 id | grep "0(root)" > /dev/null 2>&1
    107 if (( $? != 0 )); then
    108         echo "$NAME: Must be root to run this script."
    109 	echo "\texit UNINITIATED."
    110         exit $UNINITIATED 
    111 fi
    112 
    113 # create config dir and config file
    114 CONFIGDIR=$(dirname $CONFIGFILE)
    115 [[ ! -d $CONFIGDIR ]] && mkdir -p $CONFIGDIR
    116 cat > $CONFIGFILE << __EOF__
    117 # Do NOT modify this file directly,
    118 # as it is created and only maintained by $NAME.
    119 #
    120 PATH=/usr/bin:/usr/sbin:/usr/lib/nfs:\$PATH; export PATH
    121 DEBUG=$DEBUG; export DEBUG
    122 CONFIGDIR=$CONFIGDIR; export CONFIGDIR
    123 __EOF__
    124 cat $V4CFGFILE | grep -v "^#" | sed '/^$/d' >> $CONFIGFILE
    125 cat $ENVFILE | grep -v "^#" | sed -e '/^$/d' \
    126 	-e '/^BASEDIR=/d' -e '/^ROOTDIR=/d' -e '/^ROFSDIR=/d' \
    127 	-e '/^NSPCDIR=/d' -e '/^QUOTADIR=/d' -e '/^PUBTDIR=/d' \
    128 	-e '/^KRB5DIR=/d' -e '/^SSPCDIR=/d' -e '/^SSPCDIR2=/d' \
    129 	-e '/^SSPCDIR3=/d' -e '/^NOTSHDIR=/d' >> $CONFIGFILE
    130 cat >> $CONFIGFILE << __EOF__
    131 BASEDIR=$BASEDIR; export BASEDIR
    132 ROOTDIR=$ROOTDIR; export ROOTDIR
    133 ROFSDIR=$ROFSDIR; export ROFSDIR
    134 NSPCDIR=$NSPCDIR; export NSPCDIR
    135 QUOTADIR=$QUOTADIR; export QUOTADIR
    136 PUBTDIR=$PUBTDIR; export PUBTDIR
    137 KRB5DIR=$KRB5DIR; export KRB5DIR
    138 SSPCDIR=$SSPCDIR; export SSPCDIR
    139 SSPCDIR2=$SSPCDIR2; export SSPCDIR2
    140 SSPCDIR3=$SSPCDIR3; export SSPCDIR3
    141 NOTSHDIR=$NOTSHDIR; export NOTSHDIR
    142 __EOF__
    143 
    144 # create the tmp directory if it doesn't exist.
    145 DATETAG=$(date +"%y-%m-%d-%H-%M-%S" | sed 's/-//'g)
    146 TMPDIR=$TMPDIR/TMPDIR-nfsv4-$DATETAG 
    147 [[ ! -d $TMPDIR ]] && mkdir -p $TMPDIR
    148 TMPDIR=$TMPDIR; export TMPDIR # export it for tcl.init
    149 echo "TMPDIR=$TMPDIR; export TMPDIR" >> $CONFIGFILE
    150 
    151 # create name of LOGDIR, JOURNAL_SETUP, JOURNAL_CLEANUP
    152 LOGDIR=$LOGDIR/journal.$DATETAG.$(uname -p)
    153 echo "LOGDIR=$LOGDIR; export LOGDIR" >> $CONFIGFILE
    154 JOURNAL_SETUP=$LOGDIR/journal.setup
    155 echo "JOURNAL_SETUP=$JOURNAL_SETUP; export JOURNAL_SETUP"  >> $CONFIGFILE
    156 JOURNAL_CLEANUP=$LOGDIR/journal.cleanup
    157 echo "JOURNAL_CLEANUP=$JOURNAL_CLEANUP; export JOURNAL_CLEANUP" >> $CONFIGFILE
    158 
    159 # check the basic env variables - SERVER CLIENT
    160 if [[ -z $SERVER ]]; then
    161 	echo "$NAME: SERVER must be defined."
    162 	echo "\texit UNINITIATED."
    163 	cleanup $UNINITIATED
    164 fi
    165 ping $SERVER > $TMPDIR/ping.out.$$ 2>&1
    166 if (( $? != 0 )); then
    167 	echo "$NAME: SERVER=<$SERVER> not responding."
    168 	echo "\texit UNINITIATED."
    169 	cleanup $UNINITIATED
    170 fi
    171 SERVER=$(get_fullname $SERVER)
    172 if (( $? != 0 )); then
    173         echo "$NAME: get_fullname for SERVER<$SERVER> failed."
    174 	echo "\texit UNINITIATED."
    175 	cleanup $UNINITIATED
    176 fi
    177 SERVER=$SERVER; export SERVER # export it for tcl.init
    178 echo "SERVER=$SERVER; export SERVER" >> $CONFIGFILE
    179 
    180 CLIENT=$(get_fullname $(uname -n))
    181 if (( $? != 0 )); then
    182         echo "$NAME: get_fullname for CLIENT<$CLIENT> failed."
    183 	echo "\texit UNINITIATED."
    184 	exit $UNINITIATED
    185 fi
    186 echo "CLIENT=$CLIENT; export CLIENT" >> $CONFIGFILE
    187 
    188 tUDP=udp
    189 tTCP=tcp
    190 [[ $TRANSPORT == *6 ]] && tUDP=udp6 && tTCP=tcp6
    191 
    192 # Solaris NFS server does not support UDP
    193 if [[ $SRVOS == Solaris && $TRANSPORT = @(udp|udp6) ]]; then
    194 	echo "$NAME: SRVOS<$SRVOS> does not support TRANSPORT<$TRANSPORT>\c"
    195 	echo "for NFSv4;"
    196 	echo "\tTesting is terminated."
    197 	cleanup $UNSUPPORTED
    198 fi
    199 
    200 # check to support TX
    201 [[ -z $NFSMOPT ]] && TMPNFSMOPT="vers=4" || TMPNFSMOPT=$NFSMOPT
    202 iscipso=0
    203 is_cipso "$TMPNFSMOPT" $SERVER
    204 ret=$?
    205 if (( ret == CIPSO_NFSV2 )); then
    206 	echo "$NAME: CIPSO NFSv2 not supported under Trusted Extensions"
    207 	echo "\texit UNSUPPORTED."
    208 	cleanup $UNSUPPORTED
    209 fi
    210 
    211 if (( ret == CIPSO_NFSV4 || ret == CIPSO_NFSV3 )); then
    212 	cipso_check_mntpaths $BASEDIR $MNTPTR
    213 	if (( $? != 0 )); then
    214         	echo "$NAME: UNSUPPORTED"
    215 		echo "$NAME: CIPSO NFSv4/v3 requires non-global zone mount dirs."
    216 		echo "$NSPC  The server's BASEDIR and client's MNTPTR"
    217 		echo "$NSPC  must contain path legs with matching"
    218 		echo "$NSPC  non-global zone paths."
    219 		echo "$NSPC: Please try again ..."
    220 		cleanup $UNSUPPORTED
    221 	fi
    222 	iscipso=1
    223 fi
    224 
    225 # Get the nfsv4shell program over if we do not have it yet
    226 if [[ ! -x $TESTROOT/nfsh || ! -f $TESTROOT/tclprocs ]]; then
    227 	echo "$NAME: ERROR - Can't find nfsv4shell programs from $TESTROOT."
    228 	echo "\tPlease check if <nfsh> and <tclprocs> are installed properly"
    229 	cleanup $UNINITIATED
    230 fi
    231 
    232 if (( iscipso == 1 )); then
    233 	ZONENAME=$(echo "$ZONE_PATH" | sed -e 's/\// /g' | awk '{print $2}')
    234 	echo "ZONENAME=$ZONENAME; export ZONENAME" >> $CONFIGFILE
    235 	cp $TESTROOT/nfsh $ZONE_PATH/root/
    236 	cp $TESTROOT/tclprocs $ZONE_PATH/root/
    237 fi
    238 
    239 # Create a wrapper to start programs as root
    240 echo '#!/bin/sh -p\nexec $*' > /suexec
    241 chmod 7555 /suexec
    242 
    243 # setup the server ... add environment variables to srv_setup script:
    244 rm -f $TMPDIR/setserver
    245 sed -e "s%Tmpdir_from_client%$TMPDIR%" \
    246 	-e "s%ENV_from_client%$(basename $CONFIGFILE)%" \
    247 	-e "s%CONFIGDIR_from_client%$CONFIGDIR%" \
    248 	-e "s%ZONE_PATH_from_client%$ZONE_PATH%" \
    249 	-e "s%SETDEBUG%$SETD%" srv_setup > $TMPDIR/setserver
    250 if (( $? != 0 )); then
    251         echo "$NAME: can't setup [setserver] file."
    252         cleanup $UNINITIATED
    253 fi
    254 
    255 execute $SERVER root "mkdir -m 0777 -p $TMPDIR $CONFIGDIR" > /dev/null 2>&1
    256 
    257 # get test filesystem type from server
    258 rcp -p getTestFSType $SERVER:$CONFIGDIR> $TMPDIR/$NAME.rcp.$$ 2>&1
    259 if (( $? != 0 )); then
    260 	echo "$NAME: copying file<getTestFSType> to $SERVER failed:"
    261 	cat $TMPDIR/$NAME.rcp.$$
    262 	cleanup $UNINITIATED
    263 fi
    264 
    265 execute $SERVER root \
    266 	"export DEBUG=$DEBUG; \
    267 	/usr/bin/ksh $CONFIGDIR/getTestFSType $BASEDIR" \
    268 	> $TMPDIR/$NAME.rsh.out.$$ 2> $TMPDIR/$NAME.rsh.err.$$
    269 ret=$?
    270 [[ -n $DEBUG && $DEBUG != 0 ]] && cat $TMPDIR/$NAME.rsh.err.$$
    271 grep "^OKAY " $TMPDIR/$NAME.rsh.out.$$ > /dev/null 2>&1
    272 if (( $? != 0 || ret != 0 )); then
    273 	echo "$NAME: execute <getTestFSType> failed on <$SERVER>"
    274 	cat $TMPDIR/$NAME.rsh.out.$$
    275 	cat $TMPDIR/$NAME.rsh.err.$$
    276 	cleanup $UNINITIATED
    277 fi
    278 
    279 strfs=$(cat $TMPDIR/$NAME.rsh.out.$$)
    280 fs_type=$(echo $strfs | awk '{print $2}')
    281 if [[ $fs_type == "ufs" ]]; then
    282 	TestZFS=0
    283 elif [[ $fs_type == "zfs" ]]; then
    284 	TestZFS=1
    285 else
    286 	TestZFS=2
    287 fi
    288 if [[ $TestZFS == 2 ]]; then # fs is neither zfs nor ufs
    289 	echo "$NAME: BASEDIR<$BASEDIR> on server<$SERVER> is based $fs_type,"
    290 	echo "\t this test suite only supports UFS and ZFS!"
    291 	cleanup $UNSUPPORTED
    292 fi
    293 if [[ $TestZFS == 1 ]]; then # fs is zfs
    294 	zpool_name=$(echo $strfs | awk '{print $3}')
    295 	ZFSDISK=$zpool_name
    296 	echo "ZFSDISK=$ZFSDISK; export ZFSDISK" >> $CONFIGFILE
    297 	zpool_stat=$(echo $strfs | awk '{print $4}')
    298 	if [[ $zpool_stat != "ONLINE" ]]; then
    299 		echo "$NAME: BASEDIR<$BASEDIR> on server<$SERVER> is based ZFS,"
    300 		echo "\t but zpool<$zpool_name> is not online: $zpool_stat"
    301 		cat $TMPDIR/rsh.out.$$
    302 		cleanup $UNTESTED
    303 	fi
    304 fi
    305 TestZFS=$TestZFS; export TestZFS # export it for tcl.init 
    306 echo "# What type of filesystem will run over: 0-UFS 1-ZFS" >> $CONFIGFILE
    307 echo "TestZFS=$TestZFS; export TestZFS=$TestZFS" >> $CONFIGFILE
    308 
    309 # ... now setup the $SERVER
    310 echo "Setting up server [$SERVER] now:"
    311 echo "\ttest filesystem is based <$BASEDIR> and whose fs is <$fs_type>"
    312 echo "\tthis will take a while. Please be patient ..."
    313 # copy server programs over to $SERVER for setup
    314 rcp $TMPDIR/setserver ./mk_srvdir ./fillDisk ./setupFS \
    315 	./get_tunable ./set_nfstunable $CONFIGFILE ./libsmf.sh \
    316 	./operate_dir $SERVER:$CONFIGDIR > $TMPDIR/rcp.out.$$ 2>&1
    317 if (( $? != 0 )); then
    318 	echo "$NAME: copying files to $SERVER failed:"
    319 	cat $TMPDIR/rcp.out.$$
    320 	cleanup $OTHER
    321 fi
    322 
    323 execute $SERVER root "/usr/bin/ksh $CONFIGDIR/setserver -s" \
    324 	> $TMPDIR/rsh.out.$$ 2>&1
    325 ret=$?
    326 grep "OKAY" $TMPDIR/rsh.out.$$ > /dev/null 2>&1
    327 if (( $? == 0 && ret == 0 )); then
    328 	# If server returned some warning, print it out
    329 	grep "WARNING" $TMPDIR/rsh.out.$$ > /dev/null 2>&1
    330 	if (( $? == 0 )); then
    331 		echo "$NAME: setup $SERVER have warnings:"
    332 		grep WARNING $TMPDIR/rsh.out.$$
    333 	fi
    334 	[[ $DEBUG != 0 ]] && cat $TMPDIR/rsh.out.$$
    335 else
    336 	grep "ERROR" $TMPDIR/rsh.out.$$ > /dev/null 2>&1
    337 	if (( $? == 0 )); then
    338 		echo "$NAME: setup $SERVER had errors:"
    339 	else
    340 		echo "$NAME: setup $SERVER failed:"
    341 	fi
    342 	cat $TMPDIR/rsh.out.$$
    343 	cleanup $OTHER
    344 fi
    345 
    346 # Record shared information in journal file for debugging
    347 grep "^SHARE" $TMPDIR/rsh.out.$$
    348 
    349 # Save the server's NFS mapid domain
    350 NFSmapid_domain=$(grep "^SERVER_NFSmapid_Domain=" $TMPDIR/rsh.out.$$ |\
    351 	awk -F\= '{print $2}')
    352 if [[ $? != 0 || -z $NFSmapid_domain ]]; then
    353 	echo "$NAME: setup failed:"
    354 	echo "ERROR: could not get SERVER<$SERVER>'s NFS mapid domain"
    355 	grep "^SERVER"  $TMPDIR/rsh.out.$$
    356 	cleanup $OTHER
    357 fi
    358 
    359 # check if the nfs tunable values meet the requirement, if not,
    360 # set the new values and save the old values to .nfs.flg file
    361 if [[ ! -f $CONFIGDIR/$CLIENT.nfs.flg ]]; then
    362     res=$(./set_nfstunable CLIENT_VERSMIN=2 CLIENT_VERSMAX=4 \
    363 	NFSMAPID_DOMAIN=$NFSmapid_domain 2> $TMPDIR/svars.out.$$)
    364     if (( $? != 0 )); then
    365 	echo "ERROR: cannot set the specific nfs tunable on $CLIENT"
    366 	cat $TMPDIR/svars.out.$$
    367         echo "\texit UNINITIATED."
    368         cleanup $UNINITIATED
    369     else
    370 	[[ -n $res ]] && echo $res > $CONFIGDIR/$CLIENT.nfs.flg
    371     fi
    372 fi
    373 
    374 # Now setup the client
    375 echo "Setting up client [$CLIENT] now."
    376 cp -p /etc/passwd /etc/passwd.orig
    377 cp -p /etc/group /etc/group.orig
    378 # remove users left from setups not cleaned
    379 /usr/xpg4/bin/egrep -v "2345678." /etc/passwd.orig > /etc/passwd 2>&1
    380 /usr/xpg4/bin/egrep -v "2345678." /etc/group.orig > /etc/group 2>&1
    381 # add test users ... should be same as in $SERVER
    382 echo "$TUSER1:x:23456787:10:NFSv4 Test User 1:$TMPDIR:/usr/bin/ksh" \
    383 	>> /etc/passwd
    384 echo "$TUSER2:x:23456788:10:NFSv4 Test User 2:$TMPDIR:/usr/bin/ksh" \
    385 	>> /etc/passwd
    386 echo "$TUSER3:x:23456789:1:NFSv4 Test User 3:$TMPDIR:/usr/bin/ksh" \
    387 	>> /etc/passwd
    388 #except this entry
    389 echo "$TUSERC:x:$TUSERCID:10:NFSv4 Test User Client:$TMPDIR:/usr/bin/ksh" \
    390 	>> /etc/passwd
    391 echo "$TUSERC2:x:$TUSERID:10:NFSv4 Test User Client 2:$TMPDIR:/usr/bin/ksh" \
    392 	>> /etc/passwd
    393 echo "$TUSERC3:x:$TUSERCID3:10:NFSv4 Test User Client 3:$TMPDIR:/usr/bin/ksh" \
    394 	>> /etc/passwd
    395 echo "$UTF8_USR:x:$TUSERUTF8:$TUSERUTF8:uts8 USER 1:$TMPDIR:/sbin/sh" \
    396 	>> /etc/passwd
    397 echo "$UTF8_USR::$TUSERUTF8:" >> /etc/group
    398 
    399 pwconv	# make sure shadow file match
    400 N=1
    401 n=$(/usr/xpg4/bin/egrep "2345678." /etc/group | wc -l | nawk '{print $1}')
    402 if (( n != N )); then
    403         echo "ERROR: "\
    404 	"$NAME: adding test groups failed, groups file shows n=$n not $N"
    405         cleanup $OTHER
    406 fi
    407 N=6
    408 n=$(/usr/xpg4/bin/egrep \
    409 	"^$TUSER1|^$TUSER2|^$TUSER3|^$TUSERC|^$TUSERC2|^$TUSERC3" \
    410 	/etc/shadow | wc -l | nawk '{print $1}')
    411 if (( n != N )); then
    412         echo "ERROR: "\
    413 	"$NAME: adding normal test users failed, shadow file shows n=$n not $N"
    414         cleanup $OTHER
    415 fi
    416 
    417 res=$(locale | awk -F= '{print $2}' | grep -v "^$" | grep -v -w "C")
    418 if (( $? == 0 )); then
    419 	echo "WARNING: locale not set to C. Some utf8 tests may fail."
    420 	[[ $DEBUG != 0 ]] && echo "locale = $(locale)\n"
    421 else
    422 	# this test is broken with some locales, so execute only with lang=C
    423 	N=1
    424 	n=$(/usr/xpg4/bin/egrep "^$(echo $UTF8_USR)" /etc/shadow | wc -l | \
    425 		nawk '{print $1}')
    426 	if (( n != N )); then
    427 		echo "ERROR: $NAME: adding UTF8 test users failed, \
    428 			shadow file shows n=$n not $N"
    429 		[[ $DEBUG != 0 ]] && echo "locale = $(locale)\n"
    430         	cleanup $OTHER
    431 	fi
    432 fi
    433 
    434 # NULL $TUSER2's passwd for QUOTA testing:
    435 sed "s/^$TUSER2:x:/$TUSER2::/" /etc/shadow > $TMPDIR/shadow.out.$$
    436 mv $TMPDIR/shadow.out.$$ /etc/shadow
    437 chmod 0400 /etc/shadow
    438 
    439 # get server lease time period
    440 $TESTROOT/nfsh $TESTROOT/getleasetm > $TMPDIR/getls.out1.$$ 2>&1
    441 LEASE_TIME=$(egrep "^[0-9]+" $TMPDIR/getls.out1.$$ 2>$TMPDIR/getls.err.$$)
    442 if (( $? != 0 )); then
    443 	# get a default
    444 	LEASE_TIME=90
    445 	grep "ld.so.1: nfsh:" $TMPDIR/getls.out1.$$ \
    446 		grep "No such file" > /dev/null 2>&1
    447 	if (( $? != 0 )); then
    448 		echo "$NAME: UNINITIATED - \c"
    449 		echo "TCL library is NOT installed in client <$CLIENT>"
    450 		echo "nfsv4shell<nfsh> failed to run:"
    451 		echo "  \c"
    452 		cat $TMPDIR/getls.out1.$$
    453 		echo ""
    454 		cleanup $UNINITIATED
    455 	else
    456 		echo "Warning: could not get lease time from server $SERVER:"
    457 		echo "stderr = <$(cat $TMPDIR/getls.err.$$)>"
    458 	fi
    459 fi
    460 rm -f $TMPDIR/getls.*.$$ > /dev/null 2>&1
    461 # check if grace period is different from the lease period
    462 grace=$(grep "^SERVER_GRACE_PERIOD=" $TMPDIR/rsh.out.$$ | awk -F\= '{print $2}')
    463 if [[ $? != 0 || -z $grace ]]; then
    464 	echo "WARNING: could not get $SERVER's grace period"
    465 	echo
    466 	# use same default for grace as for LEASE_TIME (90 seconds)
    467 	grace=90
    468 else
    469 	# use upper case
    470 	typeset -u grace
    471 	# convert from hex to dec
    472 	grace=$(echo "ibase=16\n$grace\n" | bc)
    473 fi
    474 if (( LEASE_TIME != grace )); then
    475 	echo "IMPORTANT WARNING: server $SERVER internal variables modified:"
    476 	echo "\tlease time ($LEASE_TIME) != grace time ($grace)"
    477 	echo "\tit is recommended to set them to the same value,"
    478 	echo "\totherwise some tests may fail. Assuming the largest value"
    479 	(( LEASE_TIME < grace )) && LEASE_TIME=$grace
    480 	echo "\ttrying to prevent failures ($LEASE_TIME seconds)"
    481 fi
    482 echo "LEASE_TIME=$LEASE_TIME; export LEASE_TIME" >> $CONFIGFILE
    483 
    484 # mount the server testdir in /mnt;
    485 [[ ! -d $MNTPTR ]] && mkdir -m 777 $MNTPTR > /dev/null 2>&1
    486 
    487 # check $SERVER support both tcp and udp
    488 # Trusted Extensions doesn't support CIPSO NFSv4 UDP
    489 is_cipso "vers=4" $SERVER
    490 if (( $? == CIPSO_NOT )); then
    491 	umount -f $MNTPTR >/dev/null 2>&1
    492 	mount -o proto=$tUDP $SERVER:$BASEDIR $MNTPTR \
    493 	    > $TMPDIR/$NAME.mnt.$$ 2>&1
    494 	if (( $? != 0 )); then
    495 		echo "$NAME: UNINITIATED - \c"
    496 		echo "[mount -o proto=$tUDP $SERVER:$BASEDIR $MNTPTR] failed"
    497 		cat $TMPDIR/$NAME.mnt.$$
    498 		cleanup $UNINITIATED
    499 	fi
    500 fi
    501 
    502 #Trusted Extensions support CIPSO NFSv3 UDP
    503 is_cipso "vers=3" $SERVER
    504 if (( $? == CIPSO_NFSV3 )); then
    505         umount -f $MNTPTR >/dev/null 2>&1
    506         mount -o proto=$tUDP,vers=3 $SERVER:$BASEDIR $MNTPTR \
    507             > $TMPDIR/$NAME.mnt.$$ 2>&1
    508         if (( $? != 0 )); then
    509                 echo "$NAME: UNINITIATED - \c"
    510                 echo "[mount -o proto=$tUDP,vers=3 $SERVER:$BASEDIR $MNTPTR]" \
    511                     "failed"
    512                 cat $TMPDIR/$NAME.mnt.$$
    513                 cleanup $UNINITIATED
    514         fi
    515 fi
    516 
    517 umount -f $MNTPTR >/dev/null 2>&1
    518 mount -o proto=$tTCP $SERVER:$BASEDIR $MNTPTR \
    519 	> $TMPDIR/$NAME.mnt.$$ 2>&1
    520 if (( $? != 0 )); then
    521         echo "$NAME: UNINITIATED - \c"
    522 	echo "[mount -o proto=$tTCP $SERVER:$BASEDIR $MNTPTR] failed"
    523         cat $TMPDIR/$NAME.mnt.$$
    524         cleanup $UNINITIATED
    525 fi
    526 
    527 umount -f $MNTPTR >/dev/null 2>&1
    528 mount -F nfs -o $NFSMOPT $SERVER:$BASEDIR $MNTPTR \
    529 	> $TMPDIR/$NAME.mnt.$$ 2>&1
    530 if (( $? != 0 )); then
    531         echo "$NAME: UNINITIATED - can't mount [$SERVER:$BASEDIR] on [$MNTPTR]"
    532         cat $TMPDIR/$NAME.mnt.$$
    533         cleanup $UNINITIATED
    534 fi
    535 [[ -z $NFSMOPT ]] && NFSMOPT="default"
    536 echo "mount [NFSMOPT:$NFSMOPT] [$SERVER:$BASEDIR] on [$MNTPTR] OK"
    537 
    538 # Check the grace period as well, just in case
    539 echo "xxx" > $MNTPTR/wait_for_grace
    540 rm -f $MNTPTR/wait_for_grace > /dev/null 2>&1
    541 
    542 echo "$NAME: SERVER=$SERVER setup OK!!"
    543 echo "$NAME: CLIENT=$CLIENT ready for testing!!"
    544 
    545 # print client and server information
    546 echo "====================== TEST SUITE VERSION =====================" 
    547 grep "^STC_VERSION" ./STC.INFO
    548 echo "====================== CLIENT INFO ============================" 
    549 uname -a; isainfo; domainname; zonename
    550 echo "NFSmapid_domain=$NFSmapid_domain"
    551 echo "====================== MOUNT  INFO ============================" 
    552 nfsstat -m $MNTPTR
    553 
    554 echo "====================== SERVER INFO ============================" 
    555 execute $SERVER root "uname -a; isainfo; domainname; zonename"
    556 if [[ $TestZFS == "1" ]]; then
    557 echo "====================== ZFS    INFO ============================" 
    558 	execute $SERVER root "df -lhF zfs"	
    559 else
    560 echo "====================== UFS    INFO ============================" 
    561 	execute $SERVER root "df -lhF ufs"
    562 fi
    563 echo "====================== SHARE  INFO ============================" 
    564 execute $SERVER root "share"
    565 
    566 echo "$NAME: PASS"
    567 cleanup $PASS
    568