*** /usr/sbin/fancontrol 2010-02-03 03:45:15.000000000 +0100 --- /usr/sbin/fancontrol2 2010-02-28 03:29:38.000000000 +0100 *************** *** 5,11 **** # # Version 0.70 # ! # Usage: fancontrol [CONFIGFILE] # # Dependencies: # bash, egrep, sed, cut, sleep, readlink, lm_sensors :) --- 5,13 ---- # # Version 0.70 # ! # Usage: fancontrol [-D] [CONFIGFILE] ! # ! # (-D causes fancontrol to 'fork' to the background after some tests) # # Dependencies: # bash, egrep, sed, cut, sleep, readlink, lm_sensors :) *************** *** 43,48 **** --- 45,69 ---- #DEBUG=1 MAX=255 + + + set -- `getopt "D" "$@"` || { + echo "Usage: `basename $0` [-D] [CONFIGFILE]" 1>&2 + exit 1 + } + DAEMON=0 + while : + do + case "$1" in + -D) DAEMON=1 ;; + --) break ;; + esac + shift + done + shift + + + declare -i pwmval function LoadConfig { *************** *** 303,309 **** echo "File $PIDFILE exists, is fancontrol already running?" exit 1 fi - echo $$ > "$PIDFILE" # $1 = pwm file name function pwmdisable() --- 324,329 ---- *************** *** 475,480 **** --- 495,508 ---- let fcvcount=$fcvcount+1 done + if [ "$DAEMON" -gt 0 ]; then + echo "Forking..." + $0 $* &> /dev/null & + exit 0 + fi + + echo $$ > "$PIDFILE" + echo 'Starting automatic fan control...' # main loop calling the main function at specified intervals