#!/bin/bash
FAN_SPEED=${1:-30}
if [[ ! "$FAN_SPEED" =~ ^[0-9]+$ ]] || [ "$FAN_SPEED" -lt 5 ] || [ "$FAN_SPEED" -gt 100 ]; then
  echo "Usage: $0 [5-100]"
  echo "Fan speed must be between 5-100%"
  echo "Examples:"
  echo "  $0 30    # Set fans to 30%"
  echo "  $0 60    # Set fans to 60%"
  exit 1
fi
echo "Setting fan speed to $FAN_SPEED%..."
ipmitool raw 0x30 0x30 0x01 0x00
ipmitool raw 0x30 0x30 0x02 0xff 0x$(printf %02x $FAN_SPEED)
echo "Fan speed successfully set to $FAN_SPEED%"
echo "This disables automatic thermal management. Monitor temperatures and adjust as needed."
