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 # Turn on debug info, if requested
33 export STC_GENUTILS_DEBUG=$STC_GENUTILS_DEBUG:$SHAREMNT_DEBUG
34 [[ :$SHAREMNT_DEBUG: == *:$NAME:* \
35 || :$SHAREMNT_DEBUG: == *:all:* ]] && set -x
36
37 function cleanup { # cleanup and exit
38 [[ :$SHAREMNT_DEBUG: == *:$NAME:* \
39 || :$SHAREMNT_DEBUG: == *:all:* ]] && set -x
40 rm -f $STF_TMPDIR/*.out.$$
41 exit ${1}
42 }
43
44 # Now cleanup the server
45 SRVDEBUG=$STC_GENUTILS_DEBUG:$SHAREMNT_DEBUG
46 [[ :$SRVDEBUG: == *:RSH:* ]] && SRVDEBUG=all
47 RSH root $SERVER \
48 "export SHAREMNT_DEBUG=$SRVDEBUG; \
49 F=$SRV_TMPDIR/sharemnt.shtab; \
50 if [[ -f \$F ]]; then \$F -c; else echo NeedlessToDo; fi" \
51 > $STF_TMPDIR/rsh.out.$$ 2>&1
52 rc=$?
53 [[ :$SRVDEBUG: == *:all:* ]] && cat $STF_TMPDIR/rsh.out.$$
54
55 egrep "^NeedlessToDo$" $STF_TMPDIR/rsh.out.$$ > /dev/null 2>&1
56 if (( $? == 0 && $rc == 0 )); then
57 echo "$NAME: script<$SRV_TMPDIR/sharemnt.shtab> does not exist"
58 echo "\t it seems we don't need to cleanup on SERVER<$SERVER>"
59 cleanup $STF_PASS
60 fi
61
62 grep "Done" $STF_TMPDIR/rsh.out.$$ > /dev/null 2>&1
63 if [[ $? != 0 || $rc != 0 ]]; then
64 echo "$NAME: run cleanup script on SERVER<$SERVER> failed :"
65 cat $STF_TMPDIR/rsh.out.$$
66 echo "\t please cleanup the SERVER manually"
67 cleanup $STF_FAIL
68 fi
69
70 cleanup $STF_PASS