#!/bin/bash #Standalone iLO updater script - Jason Mak 6/25/2018 #Defines the latest version of iLO ilo2latest="2.33" ilo4latest="2.61" #Checks server type, only proceeds on HP servers function server-check() { ISHP=$(dmidecode -t System | grep Manufacturer | grep HP -c) ISDELL=$(dmidecode -t System | grep Manufacturer | grep Dell -c) if [ $ISDELL -eq 1 ]; then echo "Server is a Dell, exiting" server-cleanup exit fi if [ $ISHP -eq 1 ]; then echo "Server is an HP, proceeding" ilogeneration=$(hponcfg | grep -i "ilo" | awk -F= '{print $3}' | awk '{print $2}') iloversionraw=$(hponcfg | grep -i "ilo" | awk -F= '{print $2}' | awk '{print $1}') iloversion=${iloversionraw//.} ilo-versioncheck fi } #Checks iLO generation and version, updates as necessary function ilo-versioncheck() { if [ $ilogeneration -eq "2" ]; then if [ $(echo $iloversion -lt ${ilo2latest//.}) ]; then echo "iLO2 firmware:" $iloversionraw "latest version is:" $ilo2latest "updating..." wget http://172.16.99.121/iLO/ilo2_${ilo2latest//.}.bin -O /tmp/iloFW.bin update-ilo server-cleanup else echo "iLO 2 is up to date, exiting" server-cleanup exit fi fi if [ $ilogeneration -eq "4" ]; then if [ $(echo $iloversion -lt ${ilo4latest//.}) ]; then echo "iLO4 firmware:" $iloversionraw "latest version is:" $ilo4latest "updating..." wget http://172.16.99.121/iLO/ilo4_${ilo4latest//.}.bin -O /tmp/iloFW.bin update-ilo server-cleanup else echo "iLO 4 is up to date, exiting" server-cleanup exit fi fi } #xml file that performs the update function update-ilo() { cat > /tmp/ilo_update.xml << EOF EOF hponcfg -f /tmp/ilo_update.xml } #Clean-up function server-cleanup() { rm -vf /tmp/iloFW.bin rm -vf /tmp/ilo_update.xml rm -vf /tmp/iloUpdater.sh } #Control logic main () { server-check } main