"Quick and Dirty" Patch Script für HP/HPE G9 Server mit VMware ESXi 6, da nur scsi-hpsa NICHT aktualisiert werden darf.

Links:

#!/bin/sh

##############
## 2016-03-09
## Script by Clemens Steinkogler (clemens[at]steinkogler.org) for patching VMware ESXi 6 hosts
##   running on HP/HPE G9 hardware
## Copyright (C) 2016 Clemens Steinkogler
##
## This program is free software; you can redistribute it and/or modify it under the terms of the
## GNU General Public License as published by the Free Software Foundation; either version 2 of
## the License, or (at your option) any later version. This program is distributed in the hope
## that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details. You should have received a copy of the GNU General Public License along with this program;
## if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
## MA 02111-1307 USA
#
#
# I created this script for patching HP G9 servers because new HP G9 servers use
# some by HP modified scsi-hpsa vib, it's not recommended to install this file. ESXi
# then may NOT detect any harddisks anymore.
#
# Originally scripted for patch ESXi600-201602001.zip
#    KB 2144054
#    see Note: Before applying this patch on HP Proliant Gen 9 servers, see
#              VMware ESXi 6.0 host fails to detect local disk after patching or
#              applying Update 1 on HP Proliant Gen 9 servers (2120539).
#
# Links:
# * https://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2144054
# * https://kb.vmware.com/selfservice/search.do?cmd=displayKC&docType=kc&docTypeID=DT_KB_1_1&externalId=2120539
################################################################################
#
# Usage
#
# * Shutdown/suspend all running VMs
# * Switch to "Maintainance Mode"
# * Upload patch zip-file e.g. to /vmfs/volumes/datastore1/Patches
# * Change to this directory
# * Create this script in the same folder
# * Set proper execute rights e.g. chmod 700 HP_G9_patch.sh
# * Execute script e.g.: ./HP_G9_patch.sh ESXi600-201602001.zip
# * Cross fingers
# * Reboot after script finished without errors

patch_file="$1"
# we need the full path of the given file
patch_file=readlink -f $patch_file

patch_vibs="/tmp/patch_vibs.txt"
hp_g9_exclude_vib="scsi-hpsa"

if [[ -e $patch_file ]]; then
    echo "File existing. Beginning patch procedure..."

    # creating patch list
    # tail -n+4 skips following lines of unzip -l
    # Archive:  /vmfs/volumes/datastore1/Patches/ESXi600-201602001_patch.zip
    # Length     Date   Time    Name
    # --------    ----   ----    ----
    unzip -l $patch_file | tail -n+4 | awk -F "/" '{ print $2 }' | grep -v ^$ | sort > /tmp/patch_vibs.txt
    # remove esx-base because it's installed first
    sed -i '/^esx-base/d' $patch_vibs
    # remove tools-light because it's installed second
    sed -i '/^tools-light/d' $patch_vibs

    # installing esx-base
    echo "installing esx-base ..."
    if esxcli software vib update -n esx-base -d $patch_file; then
        echo "Updating of esx-base OK"
    else
        echo "ERROR updating esx-base. Exiting ..."
        exit 1
    fi

    # installing tools-light
    echo "installing tools-light ..."
    if esxcli software vib update -n tools-light -d $patch_file; then
        echo "Updating of tools-light OK"
    else
        echo "ERROR updating tools-light.  Exiting ..."
        exit 1
    fi

    # read through patched vibs and install them except the scsi-hpsa
    while read new_vib; do
        #echo $new_vib
        if [ "$new_vib" = "$hp_g9_exclude_vib" ]; then
                echo " "
                echo "#### SKIPPING $new_vib ####"
                echo " "
        else
            echo "Installing $new_vib ..."
            if esxcli software vib update -n $new_vib -d $patch_file; then
                echo "Updating of $new_vib OK"
            else
                echo "ERROR updating ${new_vib}. Exiting ..."
                exit 1
            fi
        fi
    done < $patch_vibs
else
    echo "File not found! Exiting..."
    exit 1
fi

echo "Deleting tmp-files..."
rm $patch_vibs
Zuletzt bearbeitet: Dezember 19, 2020

Autor

Kommentare

Kommentar verfassen

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.