summaryrefslogtreecommitdiffstats
path: root/ipmi.sh
blob: 889efe517f4bda1b0df4fd3663022081c35ddf9a (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh
#
#   |                              _
#   |  o                  o       | |
#   |       _   _  _  _        ,  | |
#   |  |  |/ \_/ |/ |/ |  |   / \_|/ \
#   |  |_/|__/   |  |  |_/|_/o \/ |   |_/
#   |    /|
#   |    \|
#
# ipmi.sh
#
# ipmi shared functions
#
# ~ rgoncalves.se

log() {
	echo "[${0}] $@"
}

# load ipmi environment variables
# cross-referenced in next functions,
# and user-scripts.
ipmi_env() {
	# export
	export IPMI_DEBUG="${IPMI_DEBUG:=false}"
	export IPMI_IP="${IPMI_IP:=192.168.5.100}"
	export IPMI_USER="${IPMI_USER:=root}"
	export IPMI_PASS="${IPMI_PASS:=calvin}"
	# debug
	if "${IPMI_DEBUG}"; then
		for var in $(env | grep "^IPMI_"); do
			log "${var}"
		done
	fi
	# cleanup
	unset var
}

# send a raw command to an ipmi host.
# ipmi environment variables are required.
ipmi_cmd() {
	out=$(ipmitool -I lanplus -H ${IPMI_IP} -U ${IPMI_USER} -P ${IPMI_PASS} ${@})
	echo "${out}" | awk NF
	# cleanup
	unset out
}
remember that computers suck.