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 / hwup-zfcp < prev   
Text File  |  2006-06-02  |  2KB  |  77 lines

  1. #!/bin/bash
  2. #
  3. # Configures a zfcp lun.
  4. #
  5. # The hardware description should look like
  6. # <type>-<bus>-<devid>
  7. # e.g.
  8. # 'hwup-zfcp lun-zfcp-0.0.f900'
  9.  
  10. SCRIPTNAME=${0##*/}
  11. HWDESC=$1
  12.  
  13. # Read in common functions
  14. . ./scripts/functions
  15. test -r ./config && . ./config
  16.  
  17. # Check for variables
  18. if test -z "$SYSFS"; then
  19.     message "sysfs not mounted, aborting."
  20.     exit 1
  21. fi
  22.  
  23. if [ -z "$HWD_DEVICEPATH" ]; then
  24.     message "no device path given, aborting."
  25.     exit 1
  26. fi
  27.  
  28. # Read in the configuration file
  29. . ./hwcfg-${HWDESC}
  30.  
  31. # Set sysfs paths
  32. _zfcp_dir=${HWD_DEVICEPATH%/host*}
  33.  
  34. # Check whether a device ID was given
  35. if [ -z "$ZFCP_LUNS" ]; then
  36.     # Nothing to configure
  37.     message "$SCRIPTNAME: No zfcp luns available for configuration"
  38.     exit 1;
  39. fi
  40.  
  41. # Check whether the adapter is available
  42. if [ ! -d "$_zfcp_dir" ]; then
  43.     message "$SCRIPTNAME: zfcp adapter ${HWD_BUSID} is not available"
  44.     exit 1
  45. fi
  46.  
  47. # Check whether the adapter is configured
  48. _zfcp_online=$(cat "${_zfcp_dir}/online")
  49. if [ "$_zfcp_online" = "0" ]; then
  50.     message "$SCRIPTNAME: zfcp adapter ${HWD_BUSID} is not configured"
  51.     exit 1
  52. fi
  53.  
  54. # Configure all wwpn/lun settings
  55. for _zfcp_dev in $ZFCP_LUNS; do
  56.     _zfcp_wwpn=`echo $_zfcp_dev | sed -n 's/:.*//p'`
  57.     _zfcp_lun=`echo $_zfcp_dev | sed -n 's/.*://p'`
  58.  
  59.     # Check whether the wwpn is already configured
  60.     _zfcp_wwpn_dir="${_zfcp_dir}/${_zfcp_wwpn}"
  61.     if [ ! -d "${_zfcp_wwpn_dir}" ]; then
  62.     echo "$_zfcp_wwpn" > ${_zfcp_dir}/port_add
  63.     fi
  64.     # Re-check whether it exists now
  65.     if [ ! -d "${_zfcp_wwpn_dir}" ] ; then
  66.     message "$SCRIPTNAME: No WWPN ${_zfcp_wwpn} for zfcp adapter ${HWD_BUSID}"
  67.     else
  68.         # Check and configure the zfcp-lun
  69.     if [ ! -d "${_zfcp_wwpn_dir}/${_zfcp_lun}" ] ; then
  70.         echo "$_zfcp_lun" > ${_zfcp_wwpn_dir}/unit_add
  71.     fi
  72.     fi
  73. done
  74.  
  75. # EOF
  76.