root/lm-sensors/branches/lm-sensors-3.0.0/prog/pwm/pwmconfig @ 5323

Revision 5323, 19.3 KB (checked in by khali, 5 years ago)

Test MINSTOP before MINSTART. We know that MINSTART can't be less than
MINSTOP, so we can use MINSTOP as the initial value for the MINSTART test.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/bin/bash
2#
3# pwmconfig $Revision$
4# Tests the pwm outputs of sensors and configures fancontrol
5#
6#    Warning!!! This program will stop your fans, one at a time,
7#    for approximately 5 seconds each!!!
8#    This may cause your processor temperature to rise!!!
9#    Verify that all fans are running at normal speed after this
10#    program has exited!!!
11#
12#    Copyright (C) 2007-2008 Jean Delvare <khali@linux-fr.org>
13#
14#    This program is free software; you can redistribute it and/or modify
15#    it under the terms of the GNU General Public License as published by
16#    the Free Software Foundation; either version 2 of the License, or
17#    (at your option) any later version.
18#
19#    This program is distributed in the hope that it will be useful,
20#    but WITHOUT ANY WARRANTY; without even the implied warranty of
21#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22#    GNU General Public License for more details.
23#
24#    You should have received a copy of the GNU General Public License
25#    along with this program; if not, write to the Free Software
26#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27#    MA 02110-1301 USA.
28#
29#
30
31PIDFILE="/var/run/fancontrol.pid"
32
33if [ -f "$PIDFILE" ]
34then
35        echo "File $PIDFILE exists. This typically means that the"
36        echo "fancontrol deamon is running. You should stop it before running pwmconfig."
37        echo "If you are certain that fancontrol is not running, then you can delete"
38        echo "$PIDFILE manually."
39        exit 1
40fi
41
42echo 'This program will search your sensors for pulse width modulation (pwm)'
43echo 'controls, and test each one to see if it controls a fan on'
44echo 'your motherboard. Note that many motherboards do not have pwm'
45echo 'circuitry installed, even if your sensor chip supports pwm.'
46echo
47echo 'We will attempt to briefly stop each fan using the pwm controls.'
48echo 'The program will attempt to restore each fan to full speed'
49echo 'after testing. However, it is ** very important ** that you'
50echo 'physically verify that the fans have been to full speed'
51echo 'after the program has completed.'
52echo
53
54DELAY=5 # 3 seconds delay is too short for large fans, thus I increased it to 5
55MAX=255
56
57DIR=/proc/sys/dev/sensors
58if [ ! -d $DIR ]
59then
60        if [ -d "/sys/class/hwmon" ]
61        then
62                SYSFS=2
63                DIR="/sys/class/hwmon"
64        elif [ -d "/sys/bus/i2c/devices" ]
65        then
66                SYSFS=1
67                DIR="/sys/bus/i2c/devices"
68        else
69                echo $0: 'No sensors found! (modprobe sensor modules?)'
70                exit 1
71        fi     
72fi
73
74cd $DIR
75if [ "$SYSFS" = "2" ]
76then
77        PREFIX='hwmon*/device'
78else
79        PREFIX='*-*'
80fi
81DEVICES=`echo $PREFIX`
82if [ "$PREFIX" = "$DEVICES" ]
83then
84        echo $0: 'No sensors found! (modprobe sensor modules?)'
85        exit 1
86fi
87
88MATCH=$PREFIX/'pwm[1-9]'
89PWM=`echo $MATCH`
90if [ "$SYSFS" = "1" -a "$MATCH" = "$PWM" ]
91then
92        # Deprecated naming scheme (used in kernels 2.6.5 to 2.6.9)
93        MATCH=$PREFIX/'fan[1-9]_pwm'
94        PWM=`echo $MATCH`
95fi
96if [ "$MATCH" = "$PWM" ]
97then
98        echo $0: 'There are no pwm-capable sensor modules installed'
99        exit 1
100fi
101
102if [ -n "$SYSFS" ]
103then
104        MATCH=$PREFIX/'fan[1-9]_input'
105else
106        MATCH=$PREFIX/'fan[1-9]'
107fi
108FAN=`echo $MATCH`
109if [ "$MATCH" = "$FAN" ]
110then
111        echo $0: 'There are no fan-capable sensor modules installed'
112        exit 1
113fi
114
115# $1 = padding
116# Only works with Linux 2.6
117function print_devices()
118{
119        for device in $DEVICES
120        do
121                echo "$1$device is `cat $device/name`"
122        done
123}
124
125# $1 = pwm file name
126function is_pwm_auto()
127{
128        if [ -n "$SYSFS" ]
129        then
130                ENABLE=${1}_enable
131                if [ -f $ENABLE ]
132                then
133                        if [ "`cat $ENABLE`" -gt 1 ]
134                        then
135                                return 0
136                        fi
137                fi
138        fi
139
140        return 1
141}
142
143# $1 = pwm file name
144function pwmdisable()
145{
146        if [ -n "$SYSFS" ]
147        then
148                ENABLE=${1}_enable
149                # No enable file? Just set to max
150                if [ ! -f $ENABLE ]
151                then
152                        echo $MAX > $1
153                        return 0
154                fi
155
156                # Try pwmN_enable=0
157                echo 0 2>/dev/null > $ENABLE
158                if [ "`cat $ENABLE`" -eq 0 ]
159                then
160                        # Success
161                        return 0
162                fi
163
164                # It didn't work, try pwmN_enable=1 pwmN=255
165                echo 1 2>/dev/null > $ENABLE
166                if [ "`cat $ENABLE`" -ne 1 ]
167                then
168                        echo "$ENABLE stuck to `cat $ENABLE`" >&2
169                        return 1
170                fi
171
172                echo $MAX > $1
173                if [ "`cat $1`" -ge 190 ]
174                then
175                        # Success
176                        return 0
177                fi
178
179                # Nothing worked
180                echo "$1 stuck to `cat $1`" >&2
181                return 1
182        else
183                echo $MAX 0 > $1
184        fi
185}
186
187# $1 = pwm file name
188function pwmenable()
189{
190        if [ -n "$SYSFS" ]
191        then
192                ENABLE=${1}_enable
193                if [ -w $ENABLE ]
194                then
195                        echo 1 2>/dev/null > $ENABLE
196                        if [ $? -ne 0 ]
197                        then
198                                return 1
199                        fi
200                fi
201                echo $MAX > $1
202        else
203                echo $MAX 1 > $1
204        fi
205}
206
207# $1 = pwm file name; $2 = pwm value 0-255
208function pwmset()
209{
210        echo $2 > $1
211}
212
213if [ -n "$SYSFS" ]
214then
215        echo 'Found the following devices:'
216        print_devices "   "
217        echo
218fi
219
220echo 'Found the following PWM controls:'
221for i in $PWM
222do
223        echo "   $i"
224        if [ -w $i ]
225        then
226                # First check if PWM output is in automatic mode
227                if is_pwm_auto $i
228                then
229                        echo "$i is currently setup for automatic speed control."
230                        echo 'In general, automatic mode is preferred over manual mode, as'
231                        echo 'it is more efficient and it reacts faster. Are you sure that'
232                        echo -n 'you want to setup this output for manual control? (n) '
233                        read X
234                        if [ "$X" = "" -o "$X" != "y" -a "$X" != "Y" ]
235                        then
236                                continue
237                        fi
238                fi
239
240                pwmdisable $i
241                if [ $? -ne 0 ]
242                then
243                        echo "Manual control mode not supported, skipping $i."
244                elif [ "$GOODPWM" = "" ]
245                then
246                        GOODPWM=$i
247                else
248                        GOODPWM="$GOODPWM $i"
249                fi
250        else
251                NOTROOT=1
252        fi
253done
254
255if [ "$GOODPWM" = "" ]
256then
257        echo 'There are no usable PWM outputs.'
258        exit 1
259fi
260
261echo
262echo "Giving the fans some time to reach full speed..."
263sleep $DELAY
264echo 'Found the following fan sensors:'
265for i in $FAN
266do
267        # this will return the first field if there's only one (sysfs)
268        S=`cat $i | cut -d' ' -f2`
269        if [ "$S" = "0" -o "$S" = "-1" ]
270        then
271                echo "   $i     current speed: 0 ... skipping!"
272        else
273                echo "   $i     current speed: $S RPM"
274                if [ "$GOODFAN" = "" ]
275                then
276                        GOODFAN=$i
277                        SPEEDS=$S
278                else
279                        GOODFAN="$GOODFAN $i"
280                        SPEEDS="$SPEEDS $S"
281                fi
282        fi
283done
284echo
285
286if [ "$GOODFAN" = "" ]
287then
288        echo 'There are no working fan sensors, all readings are 0.'
289        echo 'Make sure you have a 3-wire fan connected.'
290        echo 'You may also need to increase the fan divisors.'
291        echo 'See doc/fan-divisors for more information.'
292        exit 1
293fi
294
295if [ "$NOTROOT" = "1" ]
296then
297        echo 'As you are not root, we cannot write the PWM settings.'
298        echo 'Please run as root to continue.'
299        exit 1
300fi
301
302echo 'Warning!!! This program will stop your fans, one at a time,'
303echo "for approximately $DELAY seconds each!!!"
304echo 'This may cause your processor temperature to rise!!!'
305echo 'If you do not want to do this hit control-C now!!!'
306echo -n 'Hit return to continue: '
307read X
308echo
309
310PLOTTER=gnuplot
311STEP=15
312PDELAY=2
313# Use a smaller step for low PWM values as this is typically where the
314# more important fan speed changes are happening.
315STEP2=2
316STEP2_BELOW=31
317
318function pwmdetail()
319{
320        P=$1
321        F=$2
322        PLOT=
323
324        type $PLOTTER > /dev/null 2>&1
325        if [ $? -eq 0 ]
326        then
327                echo -n "Would you like to generate a graphical plot using $PLOTTER (y)? "
328                read X
329                if [ "$X" = "y" -o "$X" = "Y" -o "$X" = "" ]
330                then
331                        PLOT=y         
332                fi
333        else
334                if [ -n "$DISPLAY" ]
335                then
336                        echo "Note: If you had $PLOTTER installed, I could generate a graphical plot."
337                fi
338        fi
339
340        if [ "$PLOT" = "y" ]
341        then
342                TMP1=`mktemp -t pwmtest1.XXXXXXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1; }
343                TMP2=`mktemp -t pwmtest2.XXXXXXXXXX` || { rm -f $TMP1 ; echo "$0: Cannot create temporary file" >&2; exit 1; }
344                echo "set xlabel \"PWM: $P\"" > $TMP1
345                echo "set ylabel \"FAN: $F (RPM)\"" >> $TMP1
346                echo 'set nokey' >> $TMP1
347                echo 'set xrange [0:255]' >> $TMP1
348                echo "plot \"$TMP2\" with lines" >> $TMP1
349                echo 'pause -1 "    Hit return to continue..."' >> $TMP1
350                > $TMP2
351        fi
352
353        let pwm=$MAX
354        pwmenable $P
355        while [ $pwm -ge 0 ]
356        do
357                pwmset $P $pwm 
358                sleep $PDELAY
359                if [ $? -ne 0 ]
360                then
361                        pwmdisable $P   
362                        echo '^C received, aborting...'
363                        rm -f $TMP1 $TMP2
364                        exit 1
365                fi             
366                # this will return the first field if there's only one (sysfs)
367                S=`cat $F | cut -d' ' -f2`
368                echo "    PWM $pwm FAN $S"
369                if [ "$PLOT" = "y" ]
370                then
371                        echo "$pwm $S" >> $TMP2
372                fi
373                if [ "$S" = "0" -o "$S" = "-1" ]
374                then
375                        pwmdisable $P   
376                        echo "    Fan Stopped at PWM = $pwm"
377                        if [ $pwm -eq $MAX ]
378                        then
379                                echo "    This fan appears to stop when the PWM is enabled;"
380                                echo "    perhaps the fan input shares a pin with the PWM output"
381                                echo "    on the sensor chip."
382                                echo "    You cannot control this fan with this PWM output."
383                                rm -f $TMP1 $TMP2
384                                echo
385                                return 0
386                        fi
387                        break
388                fi
389                if [ $pwm -lt $STEP2_BELOW ]
390                then
391                        let pwm=$pwm-$STEP2
392                else
393                        let pwm=$pwm-$STEP
394                fi
395        done
396        pwmdisable $P   
397        if [ "$PLOT" = "y" ]
398        then
399                $PLOTTER  $TMP1
400                rm -f $TMP1 $TMP2
401        fi
402        echo
403}
404
405for i in $GOODPWM
406do
407        echo Testing pwm control $i ...
408        pwmenable $i
409        if [ $? -ne 0 ]
410        then
411                echo "Manual control mode not supported, skipping."
412                continue
413        fi
414        pwmset $i 0
415        sleep $DELAY
416        if [ $? -ne 0 ]
417        then
418                pwmdisable $i
419                echo '^C received, restoring PWM and aborting...'
420                exit 1
421        fi             
422        let pwmactivecount=0
423        let count=1
424        for j in $GOODFAN
425        do
426                OS=`echo $SPEEDS | cut -d' ' -f$count`
427                # this will return the first field if there's only one (sysfs)
428                S=`cat $j | cut -d' ' -f2`
429                echo "  $j ... speed was $OS now $S"
430                pwmdisable $i
431                let threshold=2*$OS/3
432                if [ $S -lt $threshold ]
433                then
434                        echo "    It appears that fan $j"
435                        echo "    is controlled by pwm $i"
436#
437# a PWM can control more than one fan....
438#
439                        if [ $pwmactivecount -eq 0 ]
440                        then
441                                let pwmactivecount=1
442                                pwmactive="$i ${pwmactive}"
443                                fanactive="$j ${fanactive}"
444                        else
445                                fanactive="$j+${fanactive}" #not supported yet by fancontrol
446                        fi
447                        sleep $DELAY
448                        if [ $? -ne 0 ]
449                        then
450                                echo '^C received, aborting...'
451                                exit 1
452                        fi             
453                        # this will return the first field if there's only one (sysfs)
454                        S=`cat $j | cut -d' ' -f2`
455                        if [ $S -lt $threshold ]
456                        then
457                                echo "    Fan $j has not returned to speed, please investigate!"
458                        else
459                                echo -n "Would you like to generate a detailed correlation (y)? "
460                                read X
461                                if [ "$X" = "y" -o "$X" = "Y" -o "$X" = "" ]
462                                then
463                                        pwmdetail $i $j
464                                fi
465                        fi
466                else
467                        echo "    no correlation"
468                fi
469                let count=count+1
470        done
471        echo
472        if [ "$pwmactivecount" = "0" ]
473        then
474                echo "No correlations were detected."
475                echo "There is either no fan connected to the output of $i,"
476                echo "or the connected fan has no rpm-signal connected to one of"
477                echo "the tested fan sensors. (Note: not all motherboards have"
478                echo "the pwm outputs connected to the fan connectors,"
479                echo "check out the hardware database on http://www.almico.com/forumindex.php)"
480                echo
481                echo -n "Did you see/hear a fan stopping during the above test (n)? "
482                read X
483                if [ "$X" = "y" -o "$X" = "Y" ]
484                then
485                        pwmactive="$i ${pwmactive}"
486                fi
487                echo
488        fi
489done
490
491
492echo 'Testing is complete.'
493echo 'Please verify that all fans have returned to their normal speed.'
494echo
495echo 'The fancontrol script can automatically respond to temperature changes'
496echo 'of your system by changing fanspeeds.'
497echo -n 'Do you want to set up its configuration file now (y)? '
498
499read X
500if [ "$X" = "n" -o "$X" = "N" ]
501then
502        exit
503fi
504
505if [ -n "$SYSFS" ]
506then
507        MATCH=$PREFIX/'temp[1-9]_input'
508else
509        MATCH=$PREFIX/'temp[1-9]'
510fi
511TEMPS=`echo $MATCH`
512if [ "$MATCH" = "$TEMPS" ]
513then
514        echo $0: 'There are no temperature-capable sensor modules installed'
515        exit 1
516fi
517
518function AskPath()
519{
520        echo -n 'What should be the path to your fancontrol config file (/etc/fancontrol)? '
521
522        read FCCONFIG
523        if [ "$FCCONFIG" = "" ]
524        then
525                FCCONFIG="/etc/fancontrol"
526        fi
527}
528
529AskPath
530
531function ClearConfig()
532{
533        FCTEMPS=""
534        FCFANS=""
535        MINTEMP=""
536        MAXTEMP=""
537        MINSTART=""
538        MINSTOP=""
539        MINPWM=""
540        MAXPWM=""
541}
542
543function LoadConfig()
544{
545        # Nothing to do
546        if [ ! -f "$1" ]
547        then
548                ClearConfig
549                return 0
550        fi
551
552        echo "Loading configuration from $1 ..."
553        INTERVAL=`egrep '^INTERVAL=.*$' $1 | sed -e 's/INTERVAL= *//g'`
554        FCTEMPS=`egrep '^FCTEMPS=.*$' $1 | sed -e 's/FCTEMPS= *//g'`
555        FCFANS=`egrep '^FCFANS=.*$' $1 | sed -e 's/FCFANS= *//g'`
556        MINTEMP=`egrep '^MINTEMP=.*$' $1 | sed -e 's/MINTEMP= *//g'`
557        MAXTEMP=`egrep '^MAXTEMP=.*$' $1 | sed -e 's/MAXTEMP= *//g'`
558        MINSTART=`egrep '^MINSTART=.*$' $1 | sed -e 's/MINSTART= *//g'`
559        MINSTOP=`egrep '^MINSTOP=.*$' $1 | sed -e 's/MINSTOP= *//g'`
560        MINPWM=`egrep '^MINPWM=.*$' $1 | sed -e 's/MINPWM= *//g'`
561        MAXPWM=`egrep '^MAXPWM=.*$' $1 | sed -e 's/MAXPWM= *//g'`
562
563        # Check for configuration change
564        local item
565        for item in $FCFANS
566        do
567                if [ ! -f "`echo $item | sed -e 's/=.*$//'`" ]
568                then
569                        echo "Configuration appears to be outdated, discarded"
570                        ClearConfig
571                        return 0
572                fi
573        done
574}
575
576LoadConfig $FCCONFIG
577
578# $1 = pwm value below which the fan is stopped
579function TestMinStart()
580{
581        echo
582        echo 'Now we increase the PWM value in 10-unit-steps.'
583        echo 'Let the fan stop completely, then press return until the'
584        echo "fan starts spinning. Then enter 'y'."
585        echo 'We will use this value +20 as the starting speed.'
586        let fanok=0
587        let fanval="$1"
588
589        pwmenable $pwms
590        until [ "$fanok" = "1" ]
591        do
592                if [ $fanval -gt 240 ] ; then let fanval=$MAX ; let fanok=1 ; fi
593                echo -n "Setting $pwms to $fanval..."
594                pwmset $pwms $fanval
595                read FANTEST
596                if [ "$FANTEST" != "" ] ; then let fanok=1 ; fi
597                let fanval=fanval+10
598        done
599        pwmdisable $pwms
600
601        let fanval=fanval+20
602        if [ $fanval -gt 240 ] ; then let fanval=$MAX ; fi
603        echo "OK, using $fanval"
604}
605
606function TestMinStop()
607{
608        echo
609        echo 'Now we decrease the PWM value in 10-unit-steps.'
610        echo 'Let the fan reach full speed, then press return until the'
611        echo "fan stops spinning. Then enter 'y'."
612        echo 'We will use this value +20 as the minimum speed.'
613        let fanok=0
614        let fanval=$MAX
615
616        pwmenable $pwms
617        until [ "$fanok" = "1" ]
618        do
619                let fanval=fanval-10
620                if [ $fanval -lt 0 ] ; then let fanval=0 ; let fanok=1 ; fi
621                echo -n "Setting $pwms to $fanval..."
622                pwmset $pwms $fanval
623                read FANTEST
624                if [ "$FANTEST" != "" ] ; then let fanok=1 ; fi
625        done
626        pwmdisable $pwms
627
628        let fanval=fanval+20
629        if [ $fanval -gt $MAX ] ; then let fanval=$MAX ; fi
630        echo "OK, using $fanval"
631}
632
633function SaveConfig()
634{
635        echo
636        echo "Saving configuration to $FCCONFIG..."
637        tmpfile=`mktemp -t pwmcfg.XXXXXXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1;  }
638        trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
639        echo "# Configuration file generated by pwmconfig, changes will be lost" >$tmpfile
640        echo -e "INTERVAL=$INTERVAL\nFCTEMPS=$FCTEMPS\nFCFANS=$FCFANS\nMINTEMP=$MINTEMP\nMAXTEMP=$MAXTEMP\nMINSTART=$MINSTART\nMINSTOP=$MINSTOP" >>$tmpfile
641        [ -n "$MINPWM" ] && echo "MINPWM=$MINPWM" >>$tmpfile
642        [ -n "$MAXPWM" ] && echo "MAXPWM=$MAXPWM" >>$tmpfile
643        mv $tmpfile $FCCONFIG
644        chmod +r $FCCONFIG
645        #check if file was written correctly
646        echo 'Configuration saved'
647}
648
649INTERVAL=10
650PS3='select (1-n): '
651DEFMINTEMP=0
652DEFMAXTEMP=60
653DEFMINSTART=150
654DEFMINSTOP=100
655
656function filter_cfgvar()
657{
658        echo "$1" | sed -e 's/ /\n/g' \
659                  | egrep "$2" \
660                  | sed -e 's/.*=//g'
661}
662
663# "select" won't repeat the list of options, so we enclose it in a
664# never-ending loop so that it starts over again with each iteration.
665# I admit it's not exactly nice, but I do not have a better idea to
666# keep usability at an acceptable level.
667while [ 1 ] ; do
668echo
669echo 'Select fan output to configure, or other action:'
670select pwms in $pwmactive "Change INTERVAL" "Just quit" "Save and quit" "Show configuration"; do
671        case $pwms in
672        "Change INTERVAL")
673                echo
674                echo "Current interval is $INTERVAL seconds."
675                echo -n "Enter the interval at which fancontrol should update PWM values (in s): "
676                read INTERVAL #check user input here
677                break ;;
678        "Just quit")
679                exit ;;
680        "Save and quit")
681                SaveConfig
682                exit ;;
683        "Show configuration")
684                echo
685                echo "Common Settings:"
686                echo "INTERVAL=$INTERVAL"
687                for pwmo in $pwmactive
688                do
689                        echo
690                        echo "Settings of ${pwmo}:"
691                        echo "  Depends on `filter_cfgvar "$FCTEMPS" "$pwmo"`"
692                        echo "  Controls `filter_cfgvar "$FCFANS" "$pwmo"`"
693                        echo "  MINTEMP=`filter_cfgvar "$MINTEMP" $pwmo`"
694                        echo "  MAXTEMP=`filter_cfgvar "$MAXTEMP" "$pwmo"`"
695                        echo "  MINSTART=`filter_cfgvar "$MINSTART" "$pwmo"`"
696                        echo "  MINSTOP=`filter_cfgvar "$MINSTOP" "$pwmo"`"
697                        XMINP=`filter_cfgvar "$MINPWM" "$pwmo"`
698                        [ -n "$XMINP" ] && echo "  MINPWM=$XMINP"
699                        XMAXP=`filter_cfgvar "$MAXPWM" "$pwmo"`
700                        [ -n "$XMAXP" ] && echo "  MAXPWM=$XMAXP"
701                done
702                echo
703                break ;;
704
705        "`echo ${pwmactive} |sed -e 's/ /\n/g' | egrep "${pwms}"`" )
706                pwmsed=`echo ${pwms} | sed -e 's/\//\\\\\//g'` #escape / for sed
707                echo
708                if [ -n "$SYSFS" ]
709                then
710                        echo 'Devices:'
711                        print_devices ""
712                        echo
713                fi
714                echo 'Current temperature readings are as follows:'
715                for j in $TEMPS
716                do
717                        # this will return the first field if there's only one (sysfs)
718                        S=`cat $j | cut -d' ' -f3`
719                        if [ -n "$SYSFS" ]
720                        then
721                                let S="$S / 1000"
722                        fi
723                        echo "$j        $S"
724                done
725                FAN=`echo $fanactive|cut -d' ' -f$REPLY`
726                FCFANS="`echo $FCFANS | sed -e "s/${pwmsed}[^ ]* *//g"` ${pwms}=$FAN"
727                echo
728                echo "Select a temperature sensor as source for ${pwms}:"
729                select tempss in $TEMPS "None (Do not affect this PWM output)"; do
730                        if [ "$tempss" = "None (Do not affect this PWM output)" ]
731                        then
732                       
733                                break;
734                        else
735                                if [ "$FCTEMPS" = "" ]
736                                then
737                                        FCTEMPS="${pwms}=${tempss}"
738                                else
739                                        FCTEMPS="`echo $FCTEMPS | sed -e "s/${pwmsed}[^ ]* *//g"` ${pwms}=${tempss}"
740                                fi
741                        fi
742                        echo
743                        echo 'Enter the low temperature (degree C)'
744                        echo -n "below which the fan should spin at minimum speed ($DEFMINTEMP): "
745                        read XMT
746                        if [ "$XMT" = "" ]
747                        then
748                                XMT=$DEFMINTEMP
749                        fi
750                        if [ "$MINTEMP" = "" ]
751                        then
752                                MINTEMP="${pwms}=${XMT}"
753                        else
754                                MINTEMP="`echo $MINTEMP | sed -e "s/${pwmsed}[^ ]* *//g"` ${pwms}=${XMT}"
755                        fi
756                        echo
757                        echo 'Enter the high temperature (degree C)'
758                        echo -n "over which the fan should spin at maximum speed ($DEFMAXTEMP): "
759                        read XMT
760                        if [ "$XMT" = "" ]
761                        then
762                                XMT=$DEFMAXTEMP
763                        fi
764                        if [ "$MAXTEMP" = "" ]
765                        then
766                                MAXTEMP="${pwms}=${XMT}"
767                        else
768                                MAXTEMP="`echo $MAXTEMP | sed -e "s/${pwmsed}[^ ]* *//g"` ${pwms}=${XMT}"
769                        fi
770                        echo
771                        echo "Enter the minimum PWM value (0-$MAX)"
772                        echo -n "at which the fan STOPS spinning (press t to test) ($DEFMINSTOP): "
773                        read XMSTOP
774                        if [ "$XMSTOP" = "" ]
775                        then
776                                XMSTOP=$DEFMINSTOP
777                        fi
778                        if [ "$XMSTOP" = "t" -o "$XMSTOP" = "T" ]
779                        then
780                                TestMinStop
781                                XMSTOP=$fanval
782                        fi
783                        if [ "$MINSTOP" = "" ]
784                        then
785                                MINSTOP="${pwms}=${XMSTOP}"
786                        else
787                                MINSTOP="`echo $MINSTOP | sed -e "s/${pwmsed}[^ ]* *//g"` ${pwms}=${XMSTOP}"
788                        fi
789                        echo
790                        echo "Enter the minimum PWM value ($XMSTOP-$MAX)"
791                        echo -n "at which the fan STARTS spinning (press t to test) ($DEFMINSTART): "
792                        read XMSTART
793                        if [ "$XMSTART" = "" ]
794                        then
795                                XMSTART=$DEFMINSTART
796                        fi
797                        if [ "$XMSTART" = "t" -o "$XMSTART" = "T" ]
798                        then
799                                TestMinStart $XMSTOP
800                                XMSTART=$fanval
801                        fi
802                        if [ "$MINSTART" = "" ]
803                        then
804                                MINSTART="${pwms}=${XMSTART}"
805                        else
806                                MINSTART="`echo $MINSTART | sed -e "s/${pwmsed}[^ ]* *//g"` ${pwms}=${XMSTART}"
807                        fi
808                        echo
809                        echo "Enter the PWM value (0-$XMSTOP) to use when the temperature"
810                        echo -n "is below the low temperature limit (0): "
811                        read XMINP
812                        if [ -n "$XMINP" ]
813                        then
814                                if [ "$MINPWM" = "" ]
815                                then
816                                        MINPWM="${pwms}=${XMINP}"
817                                else
818                                        MINPWM="`echo $MINPWM | sed -e "s/${pwmsed}[^ ]* *//g"` ${pwms}=${XMINP}"
819                                fi
820                        fi
821                        echo
822                        echo "Enter the PWM value ($XMSTOP-$MAX) to use when the temperature"
823                        echo -n "is over the high temperature limit ($MAX): "
824                        read XMAXP
825                        if [ -n "$XMAXP" ]
826                        then
827                                if [ "$MAXPWM" = "" ]
828                                then
829                                        MAXPWM="${pwms}=${XMAXP}"
830                                else
831                                        MAXPWM="`echo $MAXPWM | sed -e "s/${pwmsed}[^ ]* *//g"` ${pwms}=${XMAXP}"
832                                fi
833                        fi
834                        echo
835                        break;
836                done
837                break ;;
838       
839        *)
840                echo "No such option. Enter a number."
841                break ;;
842        esac
843done
844done
Note: See TracBrowser for help on using the browser.