Home | History | Annotate | Download | only in fnfs
      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	"@(#)configure.ksh	1.12	09/02/16 SMI"
     28 #
     29 
     30 . $STF_SUITE/include/autofs-util.kshlib
     31 . $STF_TOOLS/contrib/include/nfs-tx.kshlib
     32 
     33 configfile=$1
     34 ZONE_PATH=${ZONE_PATH%%/}
     35 MNTPTR=${ZONE_PATH}$MNTPTR
     36 
     37 # Check for required env variables
     38 if  [[ -z $SERVER ]]; then
     39         print "SERVER not set, exiting."
     40         exit $STF_UNINITIATED
     41 fi
     42 
     43 # Strip off the domain extension if one exists.
     44 srv_name=$(print "$SERVER" | awk -F. '{ print $1 }')
     45 
     46 if [[ $srv_name == $(uname -n) ]]; then
     47         print "SERVER is set to be the same as local host."
     48         exit $STF_UNINITIATED
     49 fi
     50 
     51 # Check TX related info
     52 check_for_cipso "$MNTPTR" "$MNTPTR" "" || return $STF_UNSUPPORTED
     53 
     54 function cleanup
     55 {
     56 	rm -f $CLIENT.srv_setup *.out.$$
     57 	exit $1
     58 }
     59 
     60 # setup the server ... add environment variables to srv_setup script:
     61 rm -f $CLIENT.srv_setup
     62 sed -e "s%MNTPTR_on_server%${MNTPTR}%" \
     63         -e "s%ServerPath%$PATH:\$PATH%" \
     64         -e "s%Tempdir%$SRVTMPDIR%" \
     65 	$STF_SUITE/srv_setup.ksh > $CLIENT.srv_setup
     66 
     67 # ... now setup the $SERVER
     68 ping $SERVER > ping.out.$$ 2>&1
     69 if (( $? != 0 )); then
     70 	print "$NAME: setup $SERVER failed - not responding?"
     71 	cat ping.out.$$
     72 	cleanup $STF_UNINITIATED
     73 fi
     74 
     75 [[ -d $TMPDIR ]] || mkdir -p $TMPDIR
     76 cp $STF_SUITE/setupFS.ksh $TMPDIR > cp.out.$$ 2>&1
     77 if (( $? != 0 )); then
     78 	print "$NAME: cp setupFS.ksh to $TMPDIR failed - \c"
     79 	cat cp.out.$$
     80 	cleanup $STF_UNINITIATED
     81 fi
     82 
     83 RSH root $SERVER "[[ -d $SRVTMPDIR ]] || mkdir -p $SRVTMPDIR" > rsh1.out.$$ 2>&1
     84 if (( $? != 0 )); then
     85 	print "$NAME: setup $SERVER failed"
     86 	cat rsh1.out.$$
     87 	cleanup $STF_UNINITIATED
     88 fi
     89 chmod 0755 $TMPDIR/setupFS.ksh
     90 rcp -p $CLIENT.srv_setup \
     91         $STF_TOOLS/contrib/include/libsmf.shlib \
     92         $STF_TOOLS/contrib/include/nfs-smf.kshlib \
     93         $STF_TOOLS/contrib/include/nfs-util.kshlib \
     94 	$TMPDIR/setupFS.ksh \
     95         $SERVER:$SRVTMPDIR > rcp.out.$$ 2>&1
     96 if (( $? != 0 )); then
     97 	print "$NAME: setup $SERVER failed - \c"
     98 	cat rcp.out.$$
     99 	cleanup $STF_UNINITIATED
    100 fi
    101 
    102 RSH root $SERVER "ksh $SRVTMPDIR/$CLIENT.srv_setup -s" > rsh2.out.$$ 2>&1
    103 grep "OKAY" rsh2.out.$$ > /dev/null 2>&1
    104 if (( $? != 0 )); then
    105         print "$NAME: setup $SERVER failed - \c"
    106         cat rsh2.out.$$
    107         cat $CLIENT.srv_setup
    108         cleanup $STF_UNINITIATED
    109 fi
    110 
    111 # create map directory
    112 [[ -d $FNFS_MAPS ]] || mkdir -p $FNFS_MAPS
    113 
    114 [[ -d $MNTPTR ]] || mkdir -p $MNTPTR
    115 mount $SERVER:$MNTPTR $MNTPTR > mnt.out.$$ 2>&1
    116 mount | grep "$SERVER:$MNTPTR" > /dev/null 2>&1
    117 if (( $? != 0 )); then
    118 	echo "$NAME UNINITIATED"
    119         echo "mount $SERVER:$MNTPTR $MNTPTR failed. "
    120 	cat mnt.out.$$
    121 	cleanup $STF_UNINITIATED
    122 fi
    123 
    124 #
    125 # Write to a config file which will be sourced by the
    126 # tests (via the stf_configure/stf_execute mechanism).
    127 #
    128 cat >> $configfile <<EOF
    129 export SERVER="$SERVER"
    130 export ZONE_PATH=$ZONE_PATH
    131 export MNTPTR=$MNTPTR
    132 EOF
    133 if (( $? != 0 )); then
    134 	print "Could not write to configure file, $configfile"
    135 	cleanup $STF_FAIL
    136 fi
    137 
    138 # configure nfsmapid_domain setting on CLIENT and SERVER
    139 set_nfsmapid
    140 
    141 autofs_backup -f
    142 
    143 cleanup $STF_PASS
    144 
    145