Last active
December 10, 2022 18:02
-
-
Save DavidWittman/eaee7d909cef478ab898 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
#!/usr/bin/env bash | |
# Loads and mounts an ISO over SMB via the | |
# SuperMicro IPMI web interface | |
# | |
# usage: supermicro-mount-iso.sh <ipmi-host> <smb-host> <path> | |
# e.g.: supermicro-mount-iso.sh 10.0.0.1 10.0.0.2 '\foo\bar\windows.iso' | |
set -x | |
IPMI_HOST="$1" | |
SMB_HOST="$2" | |
ISO="$3" | |
USER=ADMIN | |
PASS=ADMIN | |
if [[ $# -ne 3 ]]; then | |
echo "usage: $0 <ipmi-host> <smb-host> <path>" | |
exit 1 | |
fi | |
SESSION_ID=$(curl -d "name=${USER}&pwd=${PASS}" "https://${IPMI_HOST}/cgi/login.cgi" --silent --insecure -i | awk '/Set-Cookie/ && NR != 2 { print $2 }') | |
curl "https://${IPMI_HOST}/cgi/virtual_media_share_img.cgi" -H "Cookie: ${SESSION_ID}" --data-urlencode "host=${SMB_HOST}" --data-urlencode "path=${ISO}" --data-urlencode "user=" --data-urlencode "pwd=" --data-urlencode "_=" --insecure | |
sleep 1 | |
curl "https://${IPMI_HOST}/cgi/uisopin.cgi" -H "Cookie: ${SESSION_ID}" --silent --insecure --data "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On X8DTi-F mainboards with latest IPMI firmware version 3.03 the URIs are a bit different. I used this script as a starting point and identified the following URIs.
Login:
Output looks like this:
Mount ISO image.
Notice that
"${SMB_SHARE}"
now exists in addition to hostname and path to ISO image. X8DTi-F boards with latest IPMI firmware explicitly specify the share name in this separate field. Also if necessary set"${SMB_USER}"
and"${SMB_PASS}"
but that part hasn't changed from before.Bonus, log out:
Bonus, verify login state:
That last one returns for example
HAPI_STATUS:2
, not logged in, no session present for session cookie:... or it returns
HAPI_STATUS:0
, cookie corresponds to valid active session (i.e. you're currently logged in):Bonus, unmount ISO image:
Reworked script
For shits and giggles I'm also posting the script that resulted from above URI discoveries. Working on X8DTi-F mainboards with latest IPMI firmware version 3.03, it's based on above script, it's ShellCheck'd. You run it via either one of the following:
The first one makes sure your image is mounted, the second one cleans up, meaning it unmounts the currently mounted ISO image. It doesn't care if there's actually anything mounted or not, It just tries unmounting the ISO image and possibly fails if there wasn't an image in the first place. On a side note, using a values for
"${SMB_SHARE}"
without forward or backward slashes and using a value for"${ISO}"
with a leading forward slash (to denote the ISO file location underneath your share) works on X8DTi-F. Backslashes may or may not work, No slashes may or may not work as well. I didn't try those combinations.