#!/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 MAX_TEMP=37 # this is Celsius, not Fahrenheit HD_TEMP=`/usr/sbin/hddtemp -nq /dev/hda` # AVR # TTY="/dev/ttyS1" STR_L="\\\\" STR_H="]]]]" ############################### # functions fanlow() { echo -n "${STR_L}" > $TTY echo LOW } fanhigh() { echo -n "${STR_H}" > $TTY echo 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