#!/bin/bash

#Checks to see if the server is a HP, exit if not
SERVER_TYPE="$(dmidecode -t system|grep Manufacturer |grep HP -c)"
	if [ $SERVER_TYPE -eq 0 ]; then
		echo This is not a HP server, exiting. 
		exit
	fi 

#FWDLURL="https://dl.server.domain/fwdir"


#Upgrade ILO firmware to latest version as of 02/10/2015

hponcfg -g 
VERSION=$(hponcfg -g|grep type|awk -F 'type' '{print $2}'|awk '{print $3}')

echo "Upgrading firmware...."

if [ $VERSION -eq "4" ]; then
	curl --silent $FWDLURL/ilo/HPILO4 > /tmp/HPILO4
	chmod +x /tmp/HPILO4
	/tmp/HPILO4
fi

if [ $VERSION -eq "2" ]; then
	curl --silent $FWDLURL/ilo/HPILO2 > /tmp/HPILO2
	chmod +x /tmp/HPILO2
	/tmp/HPILO2
fi
