ipfyx

Logo

View My GitHub Profile

D-LINK DNS-323 : Fan speed control

D-LINK DNS-323

A while ago I installed Debian jessie on my old D-LINK DNS-323 C1. I barely managed to find an installer and struggled to install it. Unfortunately an update broke it, my dlink is now unable to boot and I was unable to recover it through the serial port. But, when it worked, the fan was out of control, so I developped a bash script run in a cronjob, inspire by FIB. Now that I have my own website I can finally share it, I hope it can help someone.

#!/bin/sh
#
# This script was created at http://wiki.dns323.info by FIB,
# it has been slightly modified by leper (with help from
# fonz). It sets the fanspeed of the device depending on 
# the temperature, which is measured in Fahrenheit. If 
# your box measures temperature in Celsius, you need to 
# edit it to work.
# Additional changes by gartylad.
 
# Set the path to use RAM-disk instead of harddrive, to 
# execute from. This is done so that the disks will go
# into sleep mode, while the script is running.
PATH=/usr/bin:/bin:/usr/sbin:/sbin
 
# T1 = temp where fan switches on
# T2 = temp where fan switches to high
# T3 = temp where fan switches off when it is already running
update_interval=180
T1=43
T2=49
T3=40

while [ 1 ]
do
# get the current temperature and fan status
T=`temperature g 0`
T=${T##*=}
S=`fanspeed g`

if [ $S -lt 1 ]; then
    echo "Fan status: stopped"
    if [ $T -gt $T2 ]; then
        echo "Fan set: high"
        fanspeed h > /dev/null
    elif [ $T -gt $T1 ]; then
        echo "Fan set: low"
        fanspeed l > /dev/null
    fi
else
    echo "Fan status: running"
    if [ $T -lt $T3 ]; then
        echo "Fan set: stop"
        fanspeed s > /dev/null
    elif [ $T -lt $T2 ]; then
        echo "Fan set: low"
        fanspeed l > /dev/null
    else
        echo "Fan set: high"
        fanspeed h > /dev/null
    fi
fi 

sleep $update_interval
done