home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20120305.etc.tar.gz / bradford.20120305.etc.tar / etc / sysconfig / hardware / scripts / hwdown-scsi < prev    next >
Text File  |  2006-06-02  |  2KB  |  101 lines

  1. #!/bin/bash
  2. #
  3. # Deconfigures a zfcp lun.
  4. #
  5. # Following steps are required:
  6. #
  7. # 1.) set the SCSI ID offline
  8. # 2.) delete the SCSI ID
  9. # -> hotplug event scsi
  10.  
  11. SCRIPTNAME=${0##*/}
  12. HWDESC=$1
  13.  
  14. # Read in common functions
  15. . ./scripts/functions
  16. test -r ./config && . ./config
  17.  
  18. # Check for variables
  19. if test -z "$SYSFS"; then
  20.     message "sysfs not mounted, aborting."
  21.     exit 1
  22. fi
  23.  
  24. # Set defaults
  25. if [ -z "$HWD_DEVICEPATH" ]; then
  26.     HWD_DEVICEPATH=${SYSFS}/bus/ccw/devices/${HWD_BUSID}
  27. fi
  28.  
  29. if [ ! -d "$HWD_DEVICEPATH" ]; then
  30.     message "No hardware devicepath given, cannot configure"
  31.     exit 1
  32. fi
  33.  
  34. # Read in the configuration file
  35. . ./hwcfg-${HWDESC}
  36.  
  37. # Set sysfs paths
  38. _zfcp_dir=${HWD_DEVICEPATH}
  39.  
  40. # Delete all SCSI Ids
  41. read _scsi_host_no < ${_zfcp_dir}/scsi_host_no
  42.  
  43. num_ids=0
  44. for id in ${_zfcp_dir}/host$((_scsi_host_no))/*; do
  45.     if [ -d $id ]; then
  46.     echo "0" > ${id}/online
  47.     echo "1" > ${id}/delete
  48.     num_ids=$(expr $num_ids + 1)
  49.     fi
  50. done
  51.  
  52. # If no SCSI IDs has been found, no hotplug
  53. # events have been generated either. So we need
  54. # to deconfigure the adapter by hand.
  55. if (($num_ids == 0)); then
  56.     # No IDs found / configured
  57.     # Tear down the adapter
  58.     for tmp_wwpn in ${_zfcp_dir}/0x*; do
  59.     if [ -d "$tmp_wwpn" ]; then
  60.         # Remove all luns
  61.         fcp_wwpn=${tmp_wwpn##*/}
  62.         for tmp_lun in ${tmp_wwpn}/0x*; do
  63.         if [ -d "$tmp_lun" ]; then
  64.             fcp_lun=${tmp_lun##*/}
  65.             echo "$fcp_lun" > ${tmp_wwpn}/unit_remove
  66.             debug "Removing unit $fcp_wwpn:$fcp_lun"
  67.         fi
  68.         done
  69.         # Recheck for failures
  70.         num_luns=0
  71.         for tmp_lun in ${tmp_wwpn}/0x*; do
  72.         if [ -d "$tmp_lun" ]; then
  73.             num_luns=$(expr $num_luns + 1)
  74.         fi
  75.         done
  76.         if (($num_luns == 0)); then
  77.         echo "$fcp_wwpn" > ${_zfcp_dir}/port_remove
  78.         debug "Removing port $fcp_wwpn"
  79.         else
  80.         message "Error removing FCP port $fcp_wwpn: $num_luns units open"
  81.         fi
  82.     fi
  83.     done
  84.     # Recheck for failures
  85.     num_ports=0
  86.     for tmp_wwpn in ${_zfcp_dir}/0x*; do
  87.     if [ -d "$tmp_wwpn" ]; then
  88.         num_ports=$(expr $num_ports + 1)
  89.     fi
  90.     done
  91.     if (($num_ports == 0)); then
  92.     echo "0" > ${_zfcp_dir}/online
  93.     else
  94.     message "Error on deconfigure adapter $HWD_BUSID: $num_ports still open"
  95.     exit 1
  96.     fi
  97. fi
  98.  
  99. # EOF
  100.