Fan Control

Method 1
http://spock.ss.u-tokai.ac.jp/~kamii/kurobox/hddtemp.shtml % cat /usr/local/bin/HDDtempChk PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin export PATH REC=/var/spool/rwho/ondorec LOG=/var/spool/rwho/temp time=`date '+%y-%m-%d %H:%M'` data=`hddtemp -nq $1` ondo=`expr "$data" : '.*: *\([0-9][0-9]*\)[^0-9]*'` fastspeed { /bin/echo -n ']]]]' > /dev/ttyS1 } slowspeed { /bin/echo -n '\\\\' > /dev/ttyS1 } if [ -f $REC ] ; then count=`cat $REC` else echo 0 > $REC count=-1 fi if [ $ondo -ge $2 ] ; then count=`expr $count + 1` echo $count > $REC if [ $count -lt 3 ] ; then ACT=fastspeed elif [ $count -eq 3 ] ; then ACT=slowspeed else ACT= fi else if [ $count -ne 0 ] ; then ACT=slowspeed echo 0 > $REC else ACT= fi fi echo "$time $data ($ondo : $2) $ACT" >> $LOG tail -24 $LOG > ${LOG}x mv ${LOG}x $LOG if [ "$ACT" = "fastspeed" ] ; then fastspeed elif [ "$ACT" = "slowspeed" ] ; then slowspeed fi exit
 * 1) !/bin/sh
 * 1) exit

Method 2
http://www.kurobox.info/bbs/index.php?showtopic=550 # MAX_TEMP=35 HD_TEMP=`smartctl -A /dev/hda | awk '/^194/ { print($10) }'` # TTY="/dev/ttyS1" STR_L="\\\\" STR_H="]]]]" if [ $HD_TEMP -lt $MAX_TEMP ]; then echo -n "${STR_L}" > $TTY else echo -n "${STR_H}" > $TTY fi
 * 1) Check HD temperature to control the fan speed
 * 1) AVR
 * 1) ... check temperature and "silence" the fan
 * 1) tell the AVR Low-speed
 * 1) tell the AVR  High-speed

To install this one
*/7 *  * * *   root     /usr/scripts/fanctrl auto
 * # su (Become root)
 * # mkdir /usr/scripts (Create a directory for your scripts)
 * # vim /usr/scripts/fanctrl (Create a directory for your scripts)
 * (Paste the script in there, than save and exit)
 * # chmod 755 /usr/scripts/fanctrl (Make the file executable)
 * # vim /etc/crontab (Edit your crontab and add the next line)

The number 7 means in how frequently cron will run the fanctrl (in minutes)

Suggested Improvements
'Give up' cooling the HD if tried successively for more than x minutes.

if [ $# -ne 1 ]; then cat 2>&1 << EOF fanctrl --- purpose: adjusts Kurobox fan speed based on supplied argument
 * 1) !/bin/sh

author: Mathias Weiersmueller ( matti_at_weiersmuellerdotcom ) version: 1.0 date:   20060917 license: LGPL, no warranty, use at your own risk

arguments: auto    = sets fan to low/high speed depending on current temp (based in variable HD_TEMP) low     = sets fan to low speed high    = sets fan to high speed (number) = sets fan to high speed if HD temp is           equal or higher than (number), or to low speed if HD temp is lower EOF exit 127 fi

MAX_TEMP=37    # this is Celsius, not Fahrenheit HD_TEMP=`/usr/sbin/hddtemp -nq /dev/hda`

TTY="/dev/ttyS1" STR_L="\\\\" STR_H="]]]]"
 * 1) AVR


 * 1) functions
 * 1) functions

fanlow { echo -n "${STR_L}" > $TTY echo LOW }

fanhigh { echo -n "${STR_H}" > $TTY echo HIGH }


 * 1) main
 * 1) main

case $1 in

auto)   if [ $HD_TEMP -ge $MAX_TEMP ]      then fanhigh    else fanlow    fi  ;;

low)   fanlow  ;;

high)   fanhigh  ;;

-h|--help|-help|-\?)   exec fanctrl # calls fanctrl without arguments, thus displaying help...   ;;

*)   if expr "$1" : "[0-9][0-9]" >/dev/null     # check for 2-digit number      then        if [ $HD_TEMP -ge $1 ]          then fanhigh        else fanlow        fi    else echo "error: wrong arguments";exit 127;    fi  ;; esac