Code/fan-enable-safe
Revision as of 22:20, 26 July 2006 by Thinker (Talk | contribs) (moved from ACPI fan control script)
- !/bin/sh
- july 2005 Erik Groeneveld, erik@cq2.nl
- It makes sure the fan is on in case of errors
- and only turns it off when all temps are ok.
IBM_ACPI=/proc/acpi/ibm THERMOMETER=$IBM_ACPI/thermal FAN=$IBM_ACPI/fan MAXTRIPPOINT=65 MINTRIPPOINT=60 TRIPPOINT=$MINTRIPPOINT
echo fancontrol: Thermometer: $THERMOMETER, Fan: $FAN echo fancontrol: Current `cat $THERMOMETER` echo fancontrol: Controlling temperatures between $MINTRIPPOINT and $MAXTRIPPOINT degrees.
- Make sure the fan is turned on when the script crashes or is killed
trap "echo enable > $FAN; exit 0" HUP KILL INT ABRT STOP QUIT SEGV TERM
while [ 1 ]; do
command=enable temperatures=`sed s/temperatures:// < $THERMOMETER` result= for temp in $temperatures do test $temp -le $TRIPPOINT && result=$result.Ok done if [ "$result" = ".Ok.Ok.Ok.Ok.Ok.Ok.Ok.Ok" ]; then command=disable TRIPPOINT=$MAXTRIPPOINT else command=enable TRIPPOINT=$MINTRIPPOINT fi echo $command > $FAN # Temperature ramps up quickly, so pick this not too large: sleep 5
done