#! /bin/sh # # $Id: nw_node_preremove.SunOS,v 1.11.2.1 2007/03/05 22:42:33 hulikv Exp $ Copyright (c) 2003-2007 EMC Corporation. # # # Copyright (c) 2003-2007 EMC Corporation. # # All rights reserved. This is an UNPUBLISHED work, and # comprises proprietary and confidential information of EMC. # Unauthorized use, disclosure, and distribution are strictly # prohibited. Use, duplication, or disclosure of the software # and documentation by the U.S. Government is subject to # restrictions set forth in a license agreement between the # Government and EMC or other written agreement specifying # the Government's rights to use the software and any applicable # FAR provisions, such as FAR 52.227-19. # PATH=/usr/sbin:/usr/bin:/sbin PRODUCT_NAME="Sun StorageTek EBS" #============================================================================== # Function: unload_drivers # Summary: unload the lus and op drivers so they can be removed #============================================================================== unload_drivers() { if [ `uname -r | cut -f 2 -d '.'` -lt 10 ]; then # remove lus driver on Solaris 9 and below rem_drv lus > /dev/null 2>&1 if [ $? -eq 0 ]; then echo "lus driver unloaded" else echo "lus driver did not unload properly" exit 2 fi else # cleanup and unload/reload sgen driver on Solaris 10 and above # if user says it is OK # always remove any mods we made to /kernel/drv/sgen.conf del_sgen ID=`modinfo | grep sgen | awk '{print $1}'` if [ -n "$ID" ]; then echo echo "The changes made to sgen.conf will not take effect " echo "until sgen reloads the sgen.conf file. " echo echo "If you are sure that no process is currently using sgen " echo "to control a tape library or other device, then it may " echo "be safe to inform sgen to reload the sgen.conf " echo "configuration file. " RESULT=`ckyorn -Q -p "Would you like sgen to reload sgen.conf? (default=no)" -d no` if [ `expr ${RESULT} : [yY]` -ne 0 ]; then echo " Reloading sgen.conf..." /usr/sbin/update_drv -f sgen if [ $? != 0 ]; then echo " ERROR: update_drv -f sgen failed " echo " You must issue 'update_drv -f sgen' manually or reboot this system before changes will take effect." echo "" echo "Press return to continue..." read dummy_read else echo " sgen successfully reloaded sgen.conf." echo fi else echo " You must issue 'update_drv -f sgen' manually or reboot this system before changes will take effect." echo "" echo "Press return to continue..." read dummy_read fi else # on removal, if sgen isn't currently loaded we don't need to do anything... echo " sgen is not currently loaded so we have nothing to do right here. Have a nice day!" fi fi # remove the optical driver from the system rem_drv op > /dev/null 2>&1 } #============================================================================== # Function: del_sgen # Summary: remove entries from /kernel/drv/sgen.conf #============================================================================== del_sgen() { file=${PKG_INSTALL_ROOT}/kernel/drv/sgen.conf echo "Removing entries from ${file}" # remove entries from /etc/devlink.tab sedcmd="/^#begin - added by ${PKGINST}/,/^#end - added by ${PKGINST}/d" sed -e "${sedcmd}" ${file} > ${file}.tmp.$$ if [ $? -eq 0 ]; then mv ${file}.tmp.$$ ${file} else echo "cleanup of ${file} failed" exit 2 fi } #============================================================================== # Function: stop_daemons # Summary: find nsr_shutdown and stop any running daemons #============================================================================== stop_daemons() { if [ $PKGINST = LGTOnode ]; then NSR_SHUTDOWN=${CLIENT_BASEDIR}/sbin/nsr_shutdown else NSR_SHUTDOWN=${CLIENT_BASEDIR}/sbin/nsr/nsr_shutdown fi [ -z "${NSR_SHUTDOWN}" ] && return # not installed [ ! -x "${NSR_SHUTDOWN}" ] && return # not executable ${NSR_SHUTDOWN} -l > /dev/null 2>&1 # no running daemons if [ $? -eq 0 ]; then echo "Shutting down the ${PRODUCT_NAME} daemons" ${NSR_SHUTDOWN} -q fi } #============================================================================== # Function: main #============================================================================== stop_daemons unload_drivers exit 0