Fan Control Script
#!/bin/bash
cpu=$(</sys/class/thermal/thermal_zone0/temp)
run_limit=45000
stop_limit=33000
port_state=$(sudo uhubctl -l 1-1 -p 2)
if [ $cpu -gt $run_limit ]; then
if [ $(echo "$port_state" | grep off | wc -l) -gt 0 ]
then
echo "Overtemp: CPU raw temp is $cpu 'C at $(date)"
sudo uhubctl -l 2 -a 1
printf " -----\n"
fi
elif [ $cpu -lt $stop_limit ]; then
if [ $(echo "$port_state" | grep power | wc -l) -gt 0 ]
then
echo "Undertemp: CPU raw temp is $cpu 'C at $(date)"
sudo uhubctl -l 2 -a 0
printf " -----\n"
fi
fi
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