News Stay informed about the latest enterprise technology news and product updates.

Generated an update script for ESX 3.0.0 and 3.0.1

In my last post I showed you how to get all the available updates for an ESX 3.0.0 and 3.0.1 server. This post showcases a script that will generate the commands you need to run to update your server with the downloaded patches in the order that they were released. The script, newupdates, examines installed updates and ignored updates (via a file you specify) and generates esxupdate commands that can be used to update an ESX server in one fell swoop. This script can be downloaded from www.lostcreations.com.

Note: The ignored updates file is simply a file with a list of ESX patch numbers, IF or line delimited.

#!/bin/bash

# require arguments or print usage
if [ “$1” == “” ]
then
echo “Usage: newupdates [-r REPOS_PARENT_PATH]
[-i IGNORE_FILE]”

exit 1

fi

# get the options

while getopts r:i: o

do case “$o” in

r) REPOS_PARENT_PATH=”$OPTARG”;;

i) IGNORE_FILE=”$OPTARG”;;

[?]) echo “Usage: newupdates [-r REPOS_PARENT_PATH]
[-i IGNORE_FILE]”

exit 1;;

esac

done

# get a list of installed updates

INSTALLED_UPDATES=`esxupdate query |
grep -io “ESX-[[:digit:]]*”`

# get a list of the updates in the parent repository path

REPOS=`ls $REPOS_PARENT_PATH`

# if the user defined an ignore file then read its contents

if [ -f “$IGNORE_FILE” ]

then

IGNORED_UPDATES=`cat $IGNORE_FILE`

fi

for R in $REPOS

do

# get the update/patch number from the repo

# directory name (strip the date prefix off)

UPDATE=`echo $R | sed “s/(.*-)(ESX-.*)/2/gi”`

# check to see if the update is already installed

echo “$INSTALLED_UPDATES” | grep -ioq “$UPDATE”

R_INSTALLED=”$?”

# if the user specified an ignore file, check

# to see if the update should be ignored

if [ -f “$IGNORE_FILE” ]

then

echo “$IGNORED_UPDATES” | grep -ioq “R$”

R_IGNORED=”$?”

else

R_IGNORED=”1″

fi

# generate an update command for the repo if it is neither

# installed or ignored

if [ “$R_INSTALLED” != “0” ] && [ “$R_IGNORED” != “0” ]

then

U_COMMAND=”esxupdate -nr file:$REPOS_PARENT_PATH/$R update”

# strip any double slashes out of the update command.

# the esxupdate utility barfs on them

U_COMMAND=`echo “$U_COMMAND” | sed “s//////gi”`

echo $U_COMMAND

fi

done

Join the conversation

2 comments

Send me notifications when other members comment.

Please create a username to comment.

Ya know, at 1500 bucks a license, you'd think VMware could afford to write something like this and, *gasp*, include it with the release. Thanks for making up where they seemingly overlooked. This tool has saved me time already. Graçias.
Cancel
Dave, $1500 per license? you really got a good deal there... its usually double and even triple of $1500. Also, I have made a script that downloads the patches for ESX 3.0.0 or ESX 3.0.1 from the internet, it gives you an ability to choose which packages. Critical, general, security or all. It creates an installation script as well. Easy to use, with screenshots... well documented.. visit http://www.serverchief.com for more details on ESX 3.x Updater. Good Luck... ServerChief
Cancel

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close