Unattended upgrade of HP mgmt agents – Part 3

In my post Unattended upgrade of HP mgmt agents – Part 2 you could read about my script for an unattended installation of the HP Management agents on ESX3.5. In this part I’ll share my next version of the script for installing the HP Management agents on ESX4.0 and ESX4.0 U1.

In the ESX4 installation, the location of the smhpd.xml file is changed and a reboot is necessary afterwards instead of upfront. Simon Long did a write-up on installing and configuring HP management agents on ESX4 a couple of weeks ago, but unfortunately this was the manual way. I like automation!.

Here’s my new version of the unattend script for ESX4.0

#!/bin/sh
# +-----------------------------------------------------+
# | HP Insight Manager Agents unattend install Script   |
# |                                                     |
# | Version : 3.0                                       |
# | Author  : Arnim van Lieshout                        |
# +-----------------------------------------------------+

# version 3.0
# ==========
# This script only supports HP management agents 8.3.1 for VMware ESX4.0 and ESX4.0U1

# +-----------------------------------------------------+
# | Setting some variables                              |
# +-----------------------------------------------------+

HPPACKAGE=hpmgmt-8.3.1-vmware4x.tgz
HBAPACKAGE=qlapi_vmw-v4.00build26.tgz
HPVERSION=831
HPCONFIG=hpmgmt${HPVERSION}.conf
HPSMHCONFIG=smhpd${HPVERSION}.xml

# +-----------------------------------------------------+
# | Warn about the reboot                               |
# +-----------------------------------------------------+

SETCOLOR_YELLOW="echo -en \\033[1;33m"
SETCOLOR_RED="echo -en \\033[0;31m"
SETCOLOR_WHITE="echo -en \\033[0;39m"

$SETCOLOR_YELLOW
echo "This update requires a reboot! "
echo -n "Do you wish to continue (y/n) "
	read answer
	if [ "$answer" != "y" ]; then
		echo "Action cancelled by user"
		$SETCOLOR_WHITE
		exit
	fi
$SETCOLOR_WHITE

# +-----------------------------------------------------+
# | Check if host is in Maintenance mode                |
# +-----------------------------------------------------+

if [ `vimsh -n -e hostsvc/runtimeinfo | grep -i "inMaintenanceMode = false" | wc -l` == 1 ]; then
	$SETCOLOR_RED
	echo -e "\nHost must be in Maintenance Mode, exiting...\n\n"
	$SETCOLOR_WHITE
	exit
fi

# +-----------------------------------------------------+
# | Download files                                      |
# +-----------------------------------------------------+

/usr/sbin/esxcfg-firewall --allowOutgoing

lwp-download http://repository.mydomain.com/hpagents/$HPPACKAGE /tmp/$HPPACKAGE
lwp-download http://repository.mydomain.com/hpagents/$HBAPACKAGE /tmp/$HBAPACKAGE
lwp-download http://repository.mydomain.com/hpagents/$HPCONFIG /tmp/$HPCONFIG
lwp-download http://repository.mydomain.com/hpagents/$HPSMHCONFIG /tmp/$HPSMHCONFIG

/usr/sbin/esxcfg-firewall --blockOutgoing

# +-----------------------------------------------------+
# | Unpack archives                                     |
# +-----------------------------------------------------+

cd /tmp
tar -zxvf $HPPACKAGE
mkdir /tmp/hbaapi
tar -C /tmp/hbaapi -zxvf $HBAPACKAGE
mkdir /opt/hp
mkdir /opt/hp/hp-agents-config
cp /tmp/$HPSMHCONFIG /opt/hp/hp-agents-config/smhpd.xml

# +-----------------------------------------------------+
# | Uninstall old packages                              |
# +-----------------------------------------------------+

cd /tmp/hpmgmt/$HPVERSION
echo -e 'y\ny' | ./install${HPVERSION}vibs.sh --uninstall
cd /tmp/hbaapi
./Remove.sh

# +-----------------------------------------------------+
# | Install new packages                                |
# +-----------------------------------------------------+

cd /tmp/hbaapi
./Install.sh
cd /tmp/hpmgmt/$HPVERSION
./install${HPVERSION}vibs.sh --silent --inputfile /tmp/$HPCONFIG

# +-----------------------------------------------------+
# | Reboot host as requested by the HP agents installer |
# +-----------------------------------------------------+
shutdown -r now "System shutdown to complete HP agents installation"

You can also download a copy of the script here.

Always test this in a test environment first before using it in production. I don’t take any responsibilities for things that might happen to your ESX servers due to using this script.

Related posts:

  1. Unattended upgrade of HP mgmt agents – Part 2 Tweet It’s been a year since I blogged about my script to perform an unattended upgrade of the HP management agents 8.1.1 on ESX 3.5 U3. After HP upgraded their...
  2. Unattended upgrade of HP management agents Tweet After upgrading to ESX 3.5 to update3, I found out that the HP management agents needed to be upgraded to version 8.1.1, since this version supports ESX3.5 update3. So...
  3. Monitor ESX datastores using Hostmonitor Tweet A lot of customers I worked with use Advanced Hostmonitor from KS-Soft to monitor their Windows environment. So is the customer I  am currently working at. Advanced Hostmonitor is...
  4. How to force a login on a QLogic HBA Tweet When running some storage test on an ESX 3.5 environment lately, I ran into a problem where a dead storage path disappeared after a rescan. While this was as...

0 Comments on “Unattended upgrade of HP mgmt agents – Part 3”

Leave a Comment