Forked from DavidWittman/supermicro-java-console.sh
Created
January 27, 2022 20:02
-
-
Save bdwarr6/677434f52d5f95a287fc32b6667b977d to your computer and use it in GitHub Desktop.
Retrieves the plaintext JNLP for the iKVM console from a SuperMicro IPMI webserver
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
#!/usr/bin/env bash | |
# Retrieves the plaintext JNLP from a SuperMicro IPMI webserver | |
# Usage: supermicro-java-console.sh <hostname> | |
# supermicro-java-console.sh 10.1.2.34 > login.jnlp | |
set -x | |
HOST="$1" | |
IPMI_USER=${IPMI_USER:-ADMIN} | |
IPMI_PASS=${IPMI_PASS:-ADMIN} | |
SESSION_ID=$(curl -s "http://${HOST}/cgi/login.cgi" --data "name=${IPMI_USER}&pwd=${IPMI_PASS}" -i | awk '/SID=[^;]/ { print $2 }') | |
URL="http://${HOST}/cgi/url_redirect.cgi?url_name=ikvm&url_type=jwsk" | |
is_mac() { | |
[[ "$(uname)" == "Darwin" ]] | |
} | |
# Some versions of the SuperMicro webserver return a 500 w/o the referer set, | |
# so we just use http://localhost here. | |
if is_mac; then | |
curl -s "${URL}" -H 'Referer: http://localhost' -H "Cookie: ${SESSION_ID}" | |
else | |
# The sed is to fix the "no iKVM64 in java.library.path bug on Linux | |
# Source: http://blog.coffeebeans.at/?p=83 | |
curl -s "${URL}" -H 'Referer: http://localhost' -H "Cookie: ${SESSION_ID}" | sed 's/Linux" arch="a.*/&\n <property name="jnlp.packEnabled" value="true"\/>\n <property name="jnlp.versionEnabled" value="true"\/>/' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment