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 DIR=$(dirname $0)
  29 NAME=$(basename $0)
  30 
  31 . $STF_SUITE/include/sharemnt.kshlib
  32 
  33 function cleanup {              # cleanup and exit
  34         rm -f $STF_TMPDIR/*.out.$$ \
  35                 $STF_TMPDIR/sharemnt.nfslogd $STF_TMPDIR/test_nfslogd
  36         exit ${1}
  37 }
  38 
  39 # Turn on debug info, if requested
  40 export STC_GENUTILS_DEBUG=$STC_GENUTILS_DEBUG:$SHAREMNT_DEBUG
  41 [[ :$SHAREMNT_DEBUG: == *:${NAME}:* \
  42         || :${SHAREMNT_DEBUG}: == *:all:* ]] && set -x
  43 
  44 #
  45 # Now setup the server..
  46 #
  47 # Firstly add environment variables to srv_setup script and
  48 # create a new script called sharemnt.nfslogd which will be
  49 # copied over to the server:
  50 sed -e "s%STF_TMPDIR_from_client%${SRV_TMPDIR}%" \
  51         -e "s%SHAREMNT_DEBUG_from_client%${SHAREMNT_DEBUG}%" \
  52         $DIR/srv_setup > ${STF_TMPDIR}/sharemnt.nfslogd \
  53         2> $STF_TMPDIR/sed.out.$$
  54 if (( $? != 0 )); then
  55         echo "$NAME: failed to create [sharemnt.nfslogd] file."
  56         cat $STF_TMPDIR/sed.out.$$
  57         echo "PATH is $PATH"
  58         cleanup $STF_UNINITIATED
  59 fi
  60 
  61 #
  62 # also copy test_nfslogd to server, which is called to verify log.
  63 #
  64 sed -e "s%STF_TMPDIR_from_client%$SRV_TMPDIR%" \
  65         $DIR/test_nfslogd > $STF_TMPDIR/test_nfslogd \
  66         2> $STF_TMPDIR/sed.out.$$
  67 if (( $? != 0 )); then
  68         echo "$NAME: failed to create [test_nfslogd] file."
  69         cat $STF_TMPDIR/sed.out.$$
  70         echo "PATH is $PATH"
  71         cleanup $STF_UNINITIATED
  72 fi
  73 chmod 0555 $STF_TMPDIR/test_nfslogd
  74 
  75 # the files which need to copy to the server
  76 server_files="$DIR/nfslogd \
  77         $DIR/nfslog.conf \
  78         $STF_TMPDIR/sharemnt.nfslogd \
  79         $STF_TMPDIR/test_nfslogd"
  80 scp $server_files $SERVER:$SRV_TMPDIR > $STF_TMPDIR/rcp.out.$$ 2>&1
  81 if (( $? != 0 )); then
  82         echo "$NAME: failed to copy <$server_files> to $SERVER:"
  83         cat $STF_TMPDIR/rcp.out.$$
  84         cleanup $STF_FAIL
  85 fi
  86 
  87 # ..finally execute the script on the server.
  88 SRVDEBUG=$SHAREMNT_DEBUG
  89 [[ :$SHAREMNT_DEBUG: == *:all:* ]] && SRVDEBUG=all
  90 RSH root $SERVER \
  91         "export SHAREMNT_DEBUG=$SRVDEBUG; \
  92          F=$SRV_TMPDIR/sharemnt.nfslogd; \
  93          chmod 0555 \$F && \$F -s" \
  94         > $STF_TMPDIR/rsh.out.$$ 2>&1
  95 rc=$?
  96 print_debug $STF_TMPDIR/rsh.out.$$
  97 grep "Done" $STF_TMPDIR/rsh.out.$$ > /dev/null 2>&1
  98 if (( $? != 0 || $rc != 0 )); then
  99         echo "$NAME: run $STF_TMPDIR/sharemnt.nfslogd in $SERVER failed:"
 100         cat $STF_TMPDIR/rsh.out.$$
 101         cleanup $STF_FAIL
 102 fi
 103 
 104 cleanup $STF_PASS