Skip to content

Instantly share code, notes, and snippets.

@thost96
Forked from DavidWittman/supermicro-bmc-reset.sh
Created July 31, 2018 13:05
Show Gist options
  • Save thost96/559894d18861fc9a4395e38335a32812 to your computer and use it in GitHub Desktop.
Save thost96/559894d18861fc9a4395e38335a32812 to your computer and use it in GitHub Desktop.
Issues a reset of the SuperMicro BMC via the web interface
#!/usr/bin/env bash
# Issues a reset of the SuperMicro BMC via the web interface
#
# usage: supermicro-bmc-reset.sh <ipmi-host>
# e.g.: supermicro-bmc-reset.sh 10.0.0.1
#
set -x
IPMI_HOST="$1"
IPMI_USER=${IPMI_USER:-ADMIN}
IPMI_PASS=${IPMI_PASS:-ADMIN}
if [[ $# -ne 1 ]]; then
echo "usage: $0 <ipmi-host>"
exit 1
fi
SESSION_ID=$(curl -d "name=${IPMI_USER}&pwd=${IPMI_PASS}" "https://${IPMI_HOST}/cgi/login.cgi" --silent --insecure -i | awk '/Set-Cookie/ && NR != 2 { print $2 }')
# It doesn't seem to care about the timestamp, so I don't.
curl "https://${IPMI_HOST}/cgi/BMCReset.cgi?time_stamp=Thu%20Sep%2011%202014%2017%3A07%3A02%20GMT-0500%20(CDT)&_=" -H "Cookie: ${SESSION_ID}" --insecure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment