Skip to content

Instantly share code, notes, and snippets.

@ingardm
Forked from DavidWittman/supermicro-mount-iso.sh
Created June 28, 2016 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ingardm/73a4d50218e2cd7d6d3f74ad184dd049 to your computer and use it in GitHub Desktop.
Save ingardm/73a4d50218e2cd7d6d3f74ad184dd049 to your computer and use it in GitHub Desktop.
#!/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