-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dell-r720-fan-control_local.sh
75 lines (68 loc) · 1.61 KB
/
dell-r720-fan-control_local.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
ITERATION_NOW=0
ITERATION_MAX=4
ITERATION_SLEEP=10
restore_dynamic_control() {
echo "Restoring dynamic fan control"
ipmitool raw 0x30 0x30 0x01 0x01
}
set_speed() {
if [ -z $1 ]; then
echo "No speed set"
exit 2
fi
correction=-5
let speed_result=($1+$correction)
hex_speed=$( printf "%x" $speed_result ) ;
echo "Set speed: $speed_result% (0x$hex_speed)"
ipmitool raw 0x30 0x30 0x01 0x00
ipmitool raw 0x30 0x30 0x02 0xff 0x$hex_speed
}
on_error() {
restore_dynamic_control
}
detect_speed(){
#trap "on_error" ERR
TEMP=$(ipmitool sdr type temperature | egrep "^Temp" | cut -d"|" -f5 | cut -d" " -f2 | sort -n -r | head -1)
echo "Highest Temp: $TEMP C"
if [[ "$TEMP" -ge "80" ]]; then
set_speed 50
elif [[ "$TEMP" -ge "76" ]]; then
set_speed 45
elif [[ "$TEMP" -ge "70" ]]; then
set_speed 40
elif [[ "$TEMP" -ge "67" ]]; then
set_speed 34
elif [[ "$TEMP" -ge "65" ]]; then
set_speed 30
elif [[ "$TEMP" -ge "62" ]]; then
set_speed 27
elif [[ "$TEMP" -ge "60" ]]; then
set_speed 25
elif [[ "$TEMP" -ge "50" ]]; then
set_speed 23
elif [[ "$TEMP" -ge "47" ]]; then
set_speed 20
elif [[ "$TEMP" -ge "40" ]]; then
set_speed 17
elif [[ "$TEMP" -ge "30" ]]; then
set_speed 10
elif [[ "$TEMP" -ge "20" ]]; then
set_speed 7
elif [[ "$TEMP" -ge "0" ]]; then
set_speed 5
else
restore_dynamic_control
fi
}
while :
do
detect_speed
((ITERATION_NOW++));
echo "Pres CTRL+C to stop..."
if(($ITERATION_NOW >= $ITERATION_MAX))
then
break #Exit the loop.
fi
sleep $ITERATION_SLEEP
done