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 28 NAME=$(basename $0) 29 30 . $STF_SUITE/include/sharemnt.kshlib 31 32 export STC_GENUTILS_DEBUG=$STC_GENUTILS_DEBUG:$SHAREMNT_DEBUG 33 [[ :$SHAREMNT_DEBUG: == *:$NAME:* \ 34 || :$SHAREMNT_DEBUG: == *:all:* ]] && set -x 35 36 typeset SRVDEBUG=$STC_GENUTILS_DEBUG:$SHAREMNT_DEBUG 37 [[ :$SRVDEBUG: == *:RSH:* ]] && SRVDEBUG=all 38 39 40 USAGE="Usage: $NAME <Tname> <opt>" 41 42 if (( $# < 2 )); then 43 echo "$USAGE" 44 exit $STF_UNRESOLVED 45 fi 46 typeset Tname=$1 47 typeset opt=$2 48 49 case $opt in 50 i|a|m|z|u) 51 # i: initial check 52 # a: Access /etc/dfs/sharetab as end user. 53 # m: Change the state of mountd, verify the consistence of 54 # /etc/dfs/sharetab. 55 # z/u: Share/unshare zfs as end user 56 # This section will not run until zfs delegation putback 57 RSH root "$SERVER" \ 58 "export SHAREMNT_DEBUG=$SRVDEBUG; \ 59 $SRV_TMPDIR/sharemnt.shtab -$opt" \ 60 > $STF_TMPDIR/rsh.out.$$ 2>&1 61 rc=$? 62 ;; 63 r) 64 if [[ $SHRTAB_REBOOT != "TRUE" ]]; then 65 echo "\n$Tname: UNTESTED, This case need to reboot server, \c" 66 echo "if you want to test it,\n" 67 echo "\tplease define SHRTAB_REBOOT as TRUE\n" 68 exit $STF_UNTESTED 69 fi 70 # save the SHARETAB on server and reboot server 71 RSH root "$SERVER" \ 72 "export SHAREMNT_DEBUG=$SRVDEBUG; \ 73 $SRV_TMPDIR/sharemnt.shtab -r 1" \ 74 > $STF_TMPDIR/rsh.out.$$ 2>&1 75 grep "Done" $STF_TMPDIR/rsh.out.$$ > /dev/null 2>&1 76 if [[ $? != 0 ]]; then 77 echo "$Tname: run $SRV_TMPDIR/sharemnt.shtab \c" 78 echo "-$opt 1 in $SERVER failed" 79 cat $STF_TMPDIR/rsh.out.$$ 80 cleanup $STF_FAIL 81 fi 82 # make sure server is not alive 83 condition="ping $SERVER | grep \"^no answer\" >/dev/null 2>&1" 84 wait_now 60 "$condition" 85 if [[ $? != 0 ]]; then 86 echo "$Tname: run $SRV_TMPDIR/sharemnt.shtab \c" 87 echo "-$opt 1 in $SERVER failed,\n" 88 echo "$SERVER is still alive after 60 seconds" 89 cleanup $STF_FAIL 90 fi 91 # check the consistence of /etc/dfs/sharetab. 92 condition="RSH root $SERVER ls > /dev/null" 93 wait_now 1200 "$condition" 60 94 RSH root "$SERVER" \ 95 "export SHAREMNT_DEBUG=$SRVDEBUG; \ 96 $SRV_TMPDIR/sharemnt.shtab -r 2" \ 97 > $STF_TMPDIR/rsh.out.$$ 2>&1 98 rc=$? 99 ;; 100 *) 101 echo $Usage 102 exit 2 103 ;; 104 esac 105 106 [[ :$SRVDEBUG: == *:all:* ]] && cat $STF_TMPDIR/rsh.out.$$ 107 108 grep "Done" $STF_TMPDIR/rsh.out.$$ > /dev/null 2>&1 109 if [[ $? != 0 || $rc != 0 ]]; then 110 echo "$Tname: run $SRV_TMPDIR/sharemnt.shtab \c" 111 echo "-$opt in $SERVER failed" 112 cat $STF_TMPDIR/rsh.out.$$ 113 cleanup $STF_FAIL 114 fi 115 116 echo "$Tname: testing complete - Result PASS" 117 cleanup $STF_PASS