forked from MagnaCapax/mcxBMCView
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetscreen
More file actions
executable file
·32 lines (26 loc) · 884 Bytes
/
Copy pathgetscreen
File metadata and controls
executable file
·32 lines (26 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# Capture screenshot from AMI MegaRAC BMC HTML5 KVM
# Usage: getscreen <bmc-ip> [output.jpg]
# Env: BMC_USER (required), BMC_PASS (required), BMC_DEBUG=1 (optional)
set -euo pipefail
if [[ $# -lt 1 ]]; then
echo "Usage: getscreen <bmc-ip> [output.jpg]" >&2
echo " Env: BMC_USER, BMC_PASS (required)" >&2
exit 1
fi
HOST="$1"
OUTPUT="${2:-/tmp/bmc-${HOST}.jpg}"
if [[ -z "${BMC_USER:-}" || -z "${BMC_PASS:-}" ]]; then
echo "ERROR: BMC_USER and BMC_PASS environment variables must be set" >&2
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SUPPRESS="${BMC_DEBUG:+/dev/stderr}"
node "${SCRIPT_DIR}/kvm-capture.js" "$HOST" "$BMC_USER" "$BMC_PASS" "$OUTPUT" 2>"${SUPPRESS:-/dev/null}"
EXIT=$?
if [[ $EXIT -eq 0 && -s "$OUTPUT" ]]; then
echo "${OUTPUT}"
else
echo "ERROR: Screenshot capture failed for ${HOST}" >&2
exit 1
fi