-
Notifications
You must be signed in to change notification settings - Fork 0
/
FanControl.sh
46 lines (40 loc) · 1.12 KB
/
FanControl.sh
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
#!/usr/bin/env bash
TempA=40;
TempB=55;
TempC=60;
TempD=65;
ReadTemps() {
if ! Temps=$(ipmitool sdr type temperature | awk -F"|" '{print $5}' | awk '{print $1}'); then
echo "FAILED TO READ TEMPERATURE SENSOR" >&2;
echo "Mode: auto";
ipmitool raw 0x30 0x30 0x01 0x01 >& /dev/null;
fi
TempPolled=$(echo $Temps | sed 's/ /\n/g' | sort -nr | head -n1);
echo "HighTemp: $TempPolled";
};
SetMode() {
if [[ $TempPolled < $TempD ]]; then
ipmitool raw 0x30 0x30 0x01 0x00 >& /dev/null;
sleep .2;
fi
if [[ $TempPolled < $TempA ]]; then
echo "FanSpeed: 12%";
ipmitool raw 0x30 0x30 0x02 0xff 0x0C >& /dev/null;
elif [[ $TempPolled < $TempB ]]; then
echo "FanSpeed: 16%";
ipmitool raw 0x30 0x30 0x02 0xff 0x10 >& /dev/null;
elif [[ $TempPolled < $TempC ]]; then
echo "FanSpeed: 20%";
ipmitool raw 0x30 0x30 0x02 0xff 0x14 >& /dev/null;
elif [[ $TempPolled < $TempD ]]; then
echo "FanSpeed: 24%";
ipmitool raw 0x30 0x30 0x02 0xff 0x18 >& /dev/null;
else
echo "FanSpeed: Auto";
ipmitool raw 0x30 0x30 0x01 0x01 >& /dev/null;
fi
};
echo -e "\n###################";
date '+%Y-%m-%d %H:%M:%S';
ReadTemps;
SetMode;