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 2008 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 # ident	"@(#)srv_setup.ksh	1.6	08/07/31 SMI"
     28 #
     29 
     30 # setup the $SERVER for testing AUTOFS over NFS
     31 
     32 NAME=`basename $0`
     33 
     34 Usage="Usage: $NAME -s | -c \n
     35 		-s: to setup this host with mountd/nfsd\n
     36 		-c: to cleanup the server\n
     37 "
     38 if [ $# -lt 1 ]; then
     39 	print $Usage
     40 	exit 2
     41 fi
     42 
     43 PATH=ServerPath
     44 MNTPTR=MNTPTR_on_server
     45 TMPDIR=Tempdir
     46 
     47 timeout=30
     48 
     49 function cleanup
     50 {
     51 	rm -f *.out.$$
     52 	exit $1
     53 }
     54 
     55 # Include common STC utility functions for SMF/Greenline
     56 . $TMPDIR/nfs-util.kshlib
     57 . $TMPDIR/libsmf.shlib
     58 . $TMPDIR/nfs-smf.kshlib
     59 
     60 getopts sc opt
     61 case $opt in
     62 	s)
     63 		[ ! -d $MNTPTR ] && \
     64 			mkdir -p -m 0777 $MNTPTR || chmod 0777 $MNTPTR
     65 		nfs_smf_setup "rw" $MNTPTR $timeout 
     66 		if [ $? -ne 0 ]; then
     67 			print "SERVER=`uname -n` did not share $MNTPTR correctly"
     68 			cleanup 99
     69 		else
     70 			print "Successfully shared: $MNTPTR"
     71 		fi
     72 		
     73 		print "Done - setup test users and daemon OKAY."
     74 		;;
     75 	c)
     76 		
     77 		nfs_smf_clean $MNTPTR $timeout
     78 		if [ $? -ne 0 ]; then
     79 			print "SERVER=`uname -n` failed to unshare $MNTPTR"
     80 			cleanup 99
     81 		fi
     82 
     83 		rm -fr $MNTPTR
     84 		if [ $? -ne 0 ]; then
     85 			print "SERVER=`uname -n` failed to remove $MNTPTR"
     86 			cleanup 99
     87 		fi
     88 		
     89 		rm -f *.out.$$ $TMPDIR/libsmf.shlib $TMPDIR/nfs-smf.kshlib \
     90 			$TMPDIR/nfs-util.kshlib
     91 		rm -f $0
     92 		
     93 		print "Done - cleanup SERVER=`uname -n` OKAY"
     94 		;;
     95 	?) 
     96 	        print $Usage
     97 	        cleanup 2
     98 	        ;;
     99 esac
    100 
    101 cleanup 0
    102