diff --git a/conf/ipmi-fancontrol.conf.example b/conf/ipmi-fancontrol.conf.example new file mode 100644 index 0000000..e2a7c5e --- /dev/null +++ b/conf/ipmi-fancontrol.conf.example @@ -0,0 +1,17 @@ +# Credentials for the BMC user driving ipmi-fancontrol-manual / ipmi-fancontrol-auto. +# +# Copy to conf/ipmi-fancontrol.conf next to the scripts and lock it down: +# cp conf/ipmi-fancontrol.conf.example conf/ipmi-fancontrol.conf +# chmod 0600 conf/ipmi-fancontrol.conf +# +# The scripts look for it relative to their own location, so this works both in a +# checkout and deployed at /opt/ergosteur. Override with IPMI_FANCONTROL_CONFIG. + +IPMI_HOST=169.254.0.1 +IPMI_USER=fancontrol + +# Read by ipmitool -E, so it never appears in the process table. +IPMI_PASSWORD=changeme + +# Fan speed applied in manual mode, as a raw hex byte (0x15 = 21%). +FAN_SPEED=0x15 diff --git a/docker-idrac.sh b/docker-idrac.sh new file mode 100755 index 0000000..85ccb74 --- /dev/null +++ b/docker-idrac.sh @@ -0,0 +1,11 @@ +#!/bin/bash +docker run -d \ + --name Dell_iDRAC_fan_controller \ + --restart=unless-stopped \ + -e IDRAC_HOST=local \ + -e FAN_SPEED=24 \ + -e CPU_TEMPERATURE_THRESHOLD=70 \ + -e CHECK_INTERVAL=60 \ + -e DISABLE_THIRD_PARTY_PCIE_CARD_DELL_DEFAULT_COOLING_RESPONSE=true \ + --device=/dev/ipmi0:/dev/ipmi0:rw \ + tigerblue77/dell_idrac_fan_controller:latest diff --git a/ipmi-fancontrol-auto b/ipmi-fancontrol-auto new file mode 100755 index 0000000..8952b87 --- /dev/null +++ b/ipmi-fancontrol-auto @@ -0,0 +1,25 @@ +#!/bin/sh +# Hand fan control back to the BMC's automatic curve. +# Paired with ipmi-fancontrol-manual via ipmi-fancontrol.service. +set -eu + +SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +CONFIG=${IPMI_FANCONTROL_CONFIG:-$SCRIPT_DIR/conf/ipmi-fancontrol.conf} + +if [ ! -r "$CONFIG" ]; then + echo "Error: cannot read $CONFIG" >&2 + echo "Copy conf/ipmi-fancontrol.conf.example there and fill in the BMC credentials." >&2 + exit 1 +fi + +. "$CONFIG" + +: "${IPMI_HOST:?not set in $CONFIG}" +: "${IPMI_USER:?not set in $CONFIG}" +: "${IPMI_PASSWORD:?not set in $CONFIG}" + +# ipmitool -E reads the password from IPMI_PASSWORD, keeping it out of argv. +export IPMI_PASSWORD + +# Re-enable automatic fan control. +ipmitool -I lanplus -H "$IPMI_HOST" -U "$IPMI_USER" -E raw 0x30 0x30 0x01 0x01 diff --git a/ipmi-fancontrol-manual b/ipmi-fancontrol-manual new file mode 100755 index 0000000..8ec3a2f --- /dev/null +++ b/ipmi-fancontrol-manual @@ -0,0 +1,29 @@ +#!/bin/sh +# Put the BMC into manual fan control and pin the fans to a fixed speed. +# Paired with ipmi-fancontrol-auto via ipmi-fancontrol.service. +set -eu + +SCRIPT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) +CONFIG=${IPMI_FANCONTROL_CONFIG:-$SCRIPT_DIR/conf/ipmi-fancontrol.conf} + +if [ ! -r "$CONFIG" ]; then + echo "Error: cannot read $CONFIG" >&2 + echo "Copy conf/ipmi-fancontrol.conf.example there and fill in the BMC credentials." >&2 + exit 1 +fi + +. "$CONFIG" + +: "${IPMI_HOST:?not set in $CONFIG}" +: "${IPMI_USER:?not set in $CONFIG}" +: "${IPMI_PASSWORD:?not set in $CONFIG}" +: "${FAN_SPEED:=0x15}" + +# ipmitool -E reads the password from IPMI_PASSWORD, keeping it out of argv. +export IPMI_PASSWORD + +# Disable the BMC's automatic fan curve. +ipmitool -I lanplus -H "$IPMI_HOST" -U "$IPMI_USER" -E raw 0x30 0x30 0x01 0x00 + +# Apply the fixed speed to all fans. +ipmitool -I lanplus -H "$IPMI_HOST" -U "$IPMI_USER" -E raw 0x30 0x30 0x02 0xff "$FAN_SPEED" diff --git a/systemd-system/ipmi-fancontrol.service b/systemd-system/ipmi-fancontrol.service new file mode 100644 index 0000000..33baf75 --- /dev/null +++ b/systemd-system/ipmi-fancontrol.service @@ -0,0 +1,9 @@ +[Unit] +Description=IPMI Fan Control silencing +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/opt/ergosteur/ipmi-fancontrol-manual +ExecStop=/opt/ergosteur/ipmi-fancontrol-auto +[Install] +WantedBy=multi-user.target