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 # Turn on debug info, if requested
34 export STC_GENUTILS_DEBUG=$STC_GENUTILS_DEBUG:$SHAREMNT_DEBUG
35 [[ :$SHAREMNT_DEBUG: == *:$NAME:* \
36 || :$SHAREMNT_DEBUG: == *:all:* ]] && set -x
37
38 function cleanup { # cleanup and exit
39 [[ :$SHAREMNT_DEBUG: == *:$NAME:* \
40 || :$SHAREMNT_DEBUG: == *:all:* ]] && set -x
41 rm -f $STF_TMPDIR/*.out.$$ $STF_TMPDIR/sharemnt.shtab
42 exit ${1}
43 }
44
45 # Firstly add environment variables to srv_setup script and create
46 # a new script called sharemnt.shtab which will be copied
47 # over to the server:
48 rm -f $STF_TMPDIR/sharemnt.shtab
49 sed -e "s%STF_TMPDIR_from_client%${SRV_TMPDIR}%" \
50 -e "s%SHAREMNT_DEBUG_from_client%${SHAREMNT_DEBUG}%" \
51 $DIR/srv_setup > ${STF_TMPDIR}/sharemnt.shtab \
52 2> $STF_TMPDIR/sed.out.$$
53 if [[ $? != 0 ]]; then
54 echo "$NAME: failed to create [sharemnt.shtab] file."
55 cat $STF_TMPDIR/sed.out.$$
56 echo "PATH is $PATH"
57 cleanup $STF_UNINITIATED
58 fi
59
60 server_files="${STF_TMPDIR}/sharemnt.shtab"
61 scp $server_files root@$SERVER:$SRV_TMPDIR > $STF_TMPDIR/scp.out.$$ 2>&1
62 if [[ $? != 0 ]]; then
63 echo "$NAME: failed to copy <$server_files> to $SERVER:"
64 cat $STF_TMPDIR/scp.out.$$
65 cleanup $STF_FAIL
66 fi
67
68 # ..finally execute the script on the server.
69 SRVDEBUG=$STC_GENUTILS_DEBUG:$SHAREMNT_DEBUG
70 [[ :$SRVDEBUG: == *:RSH:* ]] && SRVDEBUG=all
71 RSH root $SERVER \
72 "export SHAREMNT_DEBUG=$SRVDEBUG; \
73 F=$SRV_TMPDIR/sharemnt.shtab; \
74 chmod 0555 \$F && \$F -s" \
75 > $STF_TMPDIR/rsh.out.$$ 2>&1
76 rc=$?
77 [[ :$SRVDEBUG: == *:all:* ]] && cat $STF_TMPDIR/rsh.out.$$
78 grep "Done" $STF_TMPDIR/rsh.out.$$ > /dev/null 2>&1
79 if [[ $? != 0 || $rc != 0 ]]; then
80 echo "$NAME: run $SRV_TMPDIR/sharemnt.shtab in $SERVER failed:"
81 cat $STF_TMPDIR/rsh.out.$$
82 cleanup $STF_FAIL
83 fi
84
85 cleanup $STF_PASS