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	"@(#)unconfigure.ksh	1.7	08/07/31 SMI"
     28 #
     29 
     30 . $STF_SUITE/include/autofs-util.kshlib
     31 
     32 function cleanup
     33 {
     34 	# cleanup tmp files, ignore error
     35 	automount
     36 	rm -f *.out.$$ $autofs_config_bak $auto_master_bak > /dev/null 2>&1
     37 	rmdir /bad > /dev/null 2>&1
     38 	exit $1
     39 }
     40 
     41 # Paranoid check for required env variables
     42 if  [[ -z $SERVER ]]; then
     43         echo "SERVER not set, exiting."
     44         exit $STF_FAIL
     45 fi
     46 
     47 if [[ -z $MNTPTR ]]; then
     48         echo "MNTPTR not set, exiting."
     49         exit $STF_FAIL
     50 fi
     51 
     52 echo "$NAME: Waiting to cleanup automounter .\c"
     53 clean_ret=1
     54 K=0
     55 KMAX=20
     56 while (( clean_ret != 0 && K < KMAX ))
     57 do
     58 	clean_restore ck_ > clean.out.$$ 2>&1
     59 	clean_ret=$?
     60 	echo ".\c"
     61 	K=$((K + 1))
     62 done
     63 echo ""
     64 if (( K == KMAX )); then
     65 	echo "$NAME: warning - <clean_restore ck_> didn't return 0\c"
     66 	echo " after $KMAX tries."
     67 	cat clean.out.$$
     68 fi
     69 rm -rf /ck_*
     70 
     71 # cleanup map directory
     72 rm -rf $FNFS_MAPS $TMPDIR/setupFS.ksh
     73 # cleanup mount directory
     74 umount -f $MNTPTR && rmdir $MNTPTR
     75 
     76 # cleanup $SERVER:
     77 ping $SERVER > ping.out.$$ 2>&1
     78 if (( $? != 0 )); then
     79 	echo "$NAME: cleanup $SERVER failed - \c"
     80 	cat ping.out.$$
     81 	cleanup $OTHER
     82 fi
     83 RSH root $SERVER \
     84    "ksh $SRVTMPDIR/$CLIENT.srv_setup -c;rm -f $SRVTMPDIR/$CLIENT.srv_setup; \
     85         rm -f $SRVTMPDIR/setupFS.ksh" > rsh.out.$$ 2>&1
     86 rc=$?
     87 grep "OKAY" rsh.out.$$ > /dev/null 2>&1
     88 if (( $? != 0 || $rc != 0 )); then
     89 	echo "$NAME: cleanup $SERVER failed - \c"
     90 	cat rsh.out.$$
     91 	cleanup $OTHER
     92 fi
     93 
     94 #restore nfsmapid_domain on CLIENT and SERVER
     95 restore_nfsmapid
     96 
     97 cleanup $STF_PASS
     98