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 # setup the $SERVER for testing NFS V4 recovery testing by: 28 # first removing LOFI file systems setup prior to recovery 29 # test execution. Setup server with testfiles, export it, 30 # start reboot/restart daemon. 31 # 32 33 SetDebugMode 34 [ -n "$DEBUG" ] && [ "$DEBUG" != "0" ] && set -x 35 36 NAME=`basename $0` 37 38 id | grep "0(root)" > /dev/null 2>&1 39 if [ $? -ne 0 ]; then 40 echo "$NAME: ERROR - Must be root to run this script for setup." 41 exit 1 42 fi 43 44 Usage="Usage: $NAME -s | -c \n 45 -s: to setup this host w/daemon, testfiles, and share\n 46 -c: to cleanup the server\n 47 " 48 if [ $# -lt 1 ]; then 49 echo "$NAME: ERROR - incorrect usage." 50 echo $Usage 51 exit 2 52 fi 53 54 TMPDIR=Tmpdir_from_client 55 CONFIGFILE=CONFIGFILE_from_client 56 CONFIGDIR=CONFIGDIR_from_client 57 58 # sourcing framework global environment variables created after go_setup 59 # and for this purpose only this file should be sourced 60 if [[ ! -f $CONFIGFILE ]]; then 61 echo "$NAME: CONFIGFILE[$CONFIGFILE] not found;" 62 echo "\texit UNINITIATED." 63 exit 6 64 fi 65 . $CONFIGFILE 66 67 getopts sc opt 68 case $opt in 69 s) 70 # First cleanup the LOFI test filesystems (to avoid reboot warning) 71 /usr/bin/ksh $CONFIGDIR/setserver -r > $TMPDIR/ssrv-r.out.$$ 2>&1 72 [ $? -ne 0 ] && cat $TMPDIR/ssrv-r.out.$$ 73 74 # make sure nfs4red reboot/reset-nfsd daemon is running 75 chmod +x $CONFIGDIR/nfs4red > /dev/null 2>&1 76 $CONFIGDIR/nfs4red > /dev/null 2>&1 & 77 ps -e | grep -w "nfs4red" > /dev/null 78 if [ $? -ne 0 ]; then 79 $CONFIGDIR/nfs4red > /dev/null 2>&1 & 80 fi 81 82 echo "Done - setup nfs4red OKAY." 83 ;; 84 85 c) 86 pkill -x -u 0 nfs4red 87 88 echo "Done - recovery cleanup of test filesystems/daemons OKAY" 89 rm -f $CONFIGDIR/recov_setserver $CONFIGDIR/nfs4red \ 90 /etc/rc3.d/S99nfs4red 91 ;; 92 93 \?) 94 echo $Usage 95 exit 2 96 ;; 97 esac 98 99 exit 0