Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.03 KB | None | 0 0
  1. #!/bin/sh
  2. # Copyright 2008 VMware Inc.,
  3.  
  4. MountDisk()
  5. {
  6.    local COSCoreFile=
  7.  
  8.    if [ ! -f "$@" ] ; then
  9.       return ${FALSE}
  10.    fi
  11.  
  12.    Exec vsd -scu -f "$@" || {
  13.       if [ "${VERBOSE}" != "no" ] ; then
  14.          Error "Failed to mount VMDK Disk: $@"
  15.       else
  16.          Log "Failed to mount VMDK Disk: $@"
  17.       fi
  18.  
  19.       return ${FALSE}
  20.    }
  21.  
  22. # Awful hack 'n' slash to automatically open second VMDK
  23. # By J.Piscaer, Virtual Lifestyle, November 4th, 2010
  24.    Exec vsd -scu -f /vmfs/volumes/lun1/esxconsole-[longnumber]/var_cache_esxupdate.vmdk || {
  25.       if [ "${VERBOSE}" != "no" ] ; then
  26.          Error "Failed to mount VMDK Disk: $@"
  27.       else
  28.          Log "Failed to mount VMDK Disk: $@"
  29.       fi
  30.  
  31.       return ${FALSE}
  32.    }
  33. # End awful hack.
  34.  
  35.    COSCoreFile="$(esxcfg-advcfg -qg /Misc/CosCorefile)"
  36.  
  37.    if [ "${COSCoreFile}" = "" -o ! -d "$(dirname "${COSCoreFile}")" ] ; then
  38.       Exec mkdir -p "$(dirname "$@")/core-dumps/"
  39.       Exec esxcfg-advcfg -qs "$(dirname "$@")/core-dumps/cos-core" /Misc/CosCorefile
  40.    fi
  41.  
  42.    return ${TRUE}
  43. }
  44.  
  45.  
  46. CommandLineVMDK="$(GetBootOption 'cosvmdk')"
  47.  
  48. if [ -n "${CommandLineVMDK}" ] ; then
  49.    Log "COS VMDK Specified on Kerenel Boot Line: ${CommandLineVMDK}"
  50.    MountDisk "${CommandLineVMDK}" || return ${FATAL_ERROR}
  51.    return ${SUCCESS}
  52. fi
  53.  
  54. ConfigVMDK="$(GetRawConfigOption '/boot/cosvmdk')"
  55.  
  56. if [ -n "${ConfigVMDK}" ] ; then
  57.    Log "COS VMDK Specified in esx.conf: ${ConfigVMDK}"
  58.    MountDisk "${ConfigVMDK}" || return ${FATAL_ERROR}
  59.    return ${SUCCESS}
  60. fi
  61.  
  62. Log "Scanning VMFS for COS VMDK..."
  63. for disk in /vmfs/volumes/*/esxconsole-*/esxconsole.vmdk ; do
  64.    Log "Attempting to use VMDK found by inspection: ${disk}"
  65.    MountDisk "${disk}" || continue
  66.    return ${SUCCESS}
  67. done
  68.  
  69. Log "Scanning VMFS for legacy COS VMDK..."
  70. for disk in /vmfs/volumes/*/cos/default-cos.vmdk ; do
  71.    Log "Attempting to use VMDK found by inspection: ${disk}"
  72.    MountDisk "${disk}" || continue
  73.    return ${SUCCESS}
  74. done
  75.  
  76. Error "Unable to find COS VMDK"
  77. return ${FATAL_ERROR}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement