Skip to content

Instantly share code, notes, and snippets.

@rzr
Forked from florianjacob/fanctrl.sh
Created August 1, 2012 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rzr/3230334 to your computer and use it in GitHub Desktop.
Save rzr/3230334 to your computer and use it in GitHub Desktop.
fanctrl.sh for LSPRODUO
#!/bin/sh
#
if [ $# -ne 1 ]; then
cat 2>&1 << EOF
##############################################
fanctrl
-------
purpose: adjusts Kurobox fan speed based on supplied argument
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
DISK=/dev/sda
#MAX_TEMP=37 # this is Celsius, not Fahrenheit
MAX_TEMP=39 # this is Celsius, not Fahrenheit
HD_TEMP=`LANG=C /usr/sbin/hddtemp -nq $DISK`
###############################
# functions
# get current fan speed with
# cat /proc/linkstation/gpio/fan
fanlow() {
echo slow > /proc/linkstation/gpio/fan ; sleep 2
echo "log: ${HD_TEMP} : LOW"
}
fanhigh() {
echo fast > /proc/linkstation/gpio/fan ; sleep 2
echo "log: ${HD_TEMP} : HIGH"
}
fanfull() {
echo full > /proc/linkstation/gpio/fan ; sleep 2
echo "log: ${HD_TEMP} : VERY HIGH"
}
################################
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment