Home | History | Annotate | Download | only in nicdrv
      1 #!/usr/bin/ksh -p
      2 #
      3 # The contents of this file are subject to the terms of the
      4 # Common Development and Distribution License (the "License").
      5 # You may not use this file except in compliance with the License.
      6 #
      7 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      8 # or http://www.opensolaris.org/os/licensing.
      9 # See the License for the specific language governing permissions
     10 # and limitations under the License.
     11 #
     12 # When distributing Covered Code, include this CDDL HEADER in each
     13 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     14 # If applicable, add the following below this CDDL HEADER, with the
     15 # fields enclosed by brackets "[]" replaced with your own identifying
     16 # information: Portions Copyright [yyyy] [name of copyright owner]
     17 #
     18 # CDDL HEADER END
     19 #
     20 
     21 #
     22 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
     23 # Use is subject to license terms.
     24 #
     25 # ident	"@(#)unconfigure.ksh	1.7	09/06/24 SMI"
     26 #
     27 
     28 . ${STF_TOOLS}/include/stf.kshlib
     29 . ${STF_SUITE}/include/common.kshlib
     30 
     31 #
     32 # disable services in $g_service_bak file
     33 # In this file, each line is a service.
     34 # The first column is either "local" or "remote"
     35 #
     36 restore_service()
     37 {
     38         typeset service_name
     39         for service_name in $(cat $g_service_bak | grep ^local |awk '{print $2}'); do
     40                 exec_cmd "svcadm disable $service_name"
     41         done
     42 
     43 	cat $g_service_bak | grep ^remote |  while read line; do
     44 		typeset hostname=$(echo $line | awk '{print $2}')
     45 		service_name=$(echo $line | awk '{print $3}')
     46 		echo remote $hostname $service_name
     47 		exec_rshcmd $hostname "svcadm disable $service_name"
     48         done
     49 
     50 
     51 }
     52 
     53 
     54 FAIL_FLAG=0
     55 
     56 check_host_alive $LOCAL_HST $RMT_HST
     57 if [ $? -ne 0 ]; then
     58         echo "Warning: The client isn't alive, Client configuration can not be restored."
     59 else
     60         echo "The client is alive!"
     61 fi
     62 
     63 #
     64 # Restore nsswitch.conf
     65 #
     66 if [ -f /etc/nsswitch.nicdrv ]; then
     67 	cp /etc/nsswitch.nicdrv /etc/nsswitch.conf || FAIL_FLAG=1
     68 	rm -f /etc/nsswitch.nicdrv || FAIL_FLAG=1
     69 fi
     70 
     71 
     72 if exec_rshcmd $RMT_HST "test -f /etc/nsswitch.nicdrv" > /dev/null ; then
     73 	exec_rshcmd $RMT_HST "cp /etc/nsswitch.nicdrv /etc/nsswitch.conf" || FAIL_FLAG=1
     74 	exec_rshcmd $RMT_HST "rm /etc/nsswitch.nicdrv" || FAIL_FLAG=1
     75 fi
     76 
     77 #
     78 # Restore ftpusers
     79 #
     80 if [ -f /etc/ftpd/ftpusers.nicdrv ]; then
     81 	cp /etc/ftpd/ftpusers.nicdrv /etc/ftpd/ftpusers || FAIL_FLAG=1
     82 	rm -f /etc/ftpd/ftpusers.nicdrv || FAIL_FLAG=1
     83 fi
     84 
     85 if exec_rshcmd $RMT_HST "test -f /etc/ftpd/ftpusers.nicdrv" > /dev/null; then
     86 	exec_rshcmd $RMT_HST "cp /etc/ftpd/ftpusers.nicdrv /etc/ftpd/ftpusers" || FAIL_FLAG=1
     87 	exec_rshcmd $RMT_HST "rm -f /etc/ftpd/ftpusers.nicdrv" || FAIL_FLAG=1
     88 fi
     89 
     90 #
     91 # restore service
     92 #
     93 g_service_bak=$LOGDIR/svc.nicdrv
     94 
     95 if [ -f $g_service_bak ]; then
     96 	restore_service && rm -f $g_service_bak
     97 fi
     98 
     99 #
    100 # Restore user attribute 
    101 #
    102 if [ -f /etc/user_attr.nicdrv ]; then
    103 	exec_cmd "pfexec cp /etc/user_attr.nicdrv /etc/user_attr" 
    104 	exec_cmd "pfexec rm -f /etc/user_attr.nicdrv"
    105 fi
    106 
    107 #
    108 # Clean up driver functions list
    109 #
    110 if [ -f "$DRV_ALL_FUNC_LOG" ]; then
    111         rm -f $DRV_ALL_FUNC_LOG
    112 fi
    113 
    114 if [[ $FAIL_FLAG = 0 ]] ; then
    115 	exit ${STF_PASS}
    116 else
    117 	exit ${STF_FAIL}
    118 fi
    119