Skip to content

Instantly share code, notes, and snippets.

@funzoneq
Created August 24, 2015 17:15
Show Gist options
  • Save funzoneq/aad1a8a100f0e5563379 to your computer and use it in GitHub Desktop.
Save funzoneq/aad1a8a100f0e5563379 to your computer and use it in GitHub Desktop.
#!/bin/bash -x
URL=$1
USER=$2
PASSWORD=$3
LATEST_FIRMWARE="0.00"
# ILO3 firmware: http://h20564.www2.hpe.com/hpsc/swd/public/detail?swItemId=MTX_ef5d840040af4d189c4b4991a7#tab-history
# ILO4 firmware: http://h20566.www2.hpe.com/hpsc/swd/public/detail?swItemId=MTX_a6d201edd56c4ff4b7d0488d01#tab-history
# chmod +x CP*.scexe; ./CP026424.scexe --unpack=.
TYPE=`curl -k https://$URL/xmldata?item=All | grep "<PN>" | sed -e 's,.*<PN>\([^<]*\)</PN>.*,\1,g'`
if [ "$TYPE" == "Integrated Lights-Out 3 (iLO 3)" ];
then
LATEST_FIRMWARE="1.85"
fi
if [ "$TYPE" == "Integrated Lights-Out 4 (iLO 4)" ];
then
LATEST_FIRMWARE="2.10"
fi
if [ "$LATEST_FIRMWARE" == "0.00" ];
then
# Somethings wrong
exit 1
fi
FIRMWARE=`curl -k https://$URL/xmldata?item=All | grep "<FWRI>" | sed -e 's,.*<FWRI>\([^<]*\)</FWRI>.*,\1,g'`
if [ "$LATEST_FIRMWARE" == "$FIRMWARE" ];
then
exit 0;
else
echo "logging in"
SESSION_KEY=`curl -k -X POST https://$URL/json/login_session -d "{\"method\":\"login\",\"user_login\":\"$USER\",\"password\":\"$PASSWORD\"}" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["session_key"]'`
echo "starting upload to $URL"
if [ "$TYPE" == "Integrated Lights-Out 3 (iLO 3)" ];
then
curl -v -k --cookie "sessionUrl=https%253A%2F%2F$URL%2F; sessionLang=en; sessionKey=$SESSION_KEY" -F sessionKey=$SESSION_KEY -F file=@ilo3_185.bin https://$URL/cgi-bin/uploadFile
fi
if [ "$TYPE" == "Integrated Lights-Out 4 (iLO 4)" ];
then
curl -v -k --cookie "sessionUrl=https%253A%2F%2F$URL%2F; sessionLang=en; sessionKey=$SESSION_KEY" -F sessionKey=$SESSION_KEY -F file=@ilo4_210.bin https://$URL/cgi-bin/uploadFile
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment