59 lines
1.1 KiB
Bash
Executable File
59 lines
1.1 KiB
Bash
Executable File
#!/bin/sh -e
|
|
#
|
|
# script to manage fan speeds on dell poweredge servers
|
|
# note: uses default creds of root/calvin
|
|
#
|
|
# * NOTE: *
|
|
# To resolve ipmi issue, need to change the IPMI over LAN setting from
|
|
# [Disabled] to [Enabled] in the iDRAC/iLO.
|
|
#
|
|
|
|
# default creds are root/calvin
|
|
: "${IDRAC_USER:=root}"
|
|
: "${IDRAC_PW:=calvin}"
|
|
|
|
usage() {
|
|
>&2 printf 'Usage: %s host [-a]|[1-100]\n' "${0##*/}"
|
|
exit 1
|
|
}
|
|
|
|
dec2hex() {
|
|
printf '%x\n' "$1"
|
|
}
|
|
|
|
sendcommand() {
|
|
# shellcheck disable=2086
|
|
ipmitool \
|
|
-I lanplus \
|
|
-H "${IDRAC_IP:-192.168.0.94}" \
|
|
-U "$IDRAC_USER" \
|
|
-P "$IDRAC_PW" \
|
|
$1
|
|
}
|
|
|
|
manual='raw 0x30 0x30 0x01 0x00'
|
|
auto='raw 0x30 0x30 0x01 0x01'
|
|
|
|
case $1 in
|
|
-h|--help)
|
|
usage
|
|
esac
|
|
|
|
case ${1#-} in
|
|
m|manual)
|
|
sendcommand "$manual"
|
|
;;
|
|
a|automatic)
|
|
sendcommand "$auto"
|
|
;;
|
|
*)
|
|
sendcommand "$manual" &&
|
|
case $1 in
|
|
[1-9])
|
|
sendcommand "raw 0x30 0x30 0x02 0xff 0x0$1"
|
|
;;
|
|
*)
|
|
sendcommand "raw 0x30 0x30 0x02 0xff 0x0$(dec2hex "$1")"
|
|
esac
|
|
esac
|