Forked from funzoneq/Update HP ILO3 and ILO4 via command line
Created
March 13, 2019 15:23
-
-
Save bbrk364/a45376d434b38c310b58e6536e2da69d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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