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

Revision 5318, 19.5 KB (checked in by khali, 5 years ago)

Fix MINSTOP and MINSTART test functions. PWM must be enabled for the duration
of the test, and disabled again afterwards. Bug reported by Philippe Roubach.

  • 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                echo "Note: If you had $PLOTTER installed, I could generate a graphical plot."
335        fi
336
337        if [ "$PLOT" = "y" ]
338        then
339                TMP1=`mktemp -t pwmtest1.XXXXXXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1; }
340                TMP2=`mktemp -t pwmtest2.XXXXXXXXXX` || { rm -f $TMP1 ; echo "$0: Cannot create temporary file" >&2; exit 1; }
341                echo "set xlabel \"PWM: $P\"" > $TMP1
342                echo "set ylabel \"FAN: $F (RPM)\"" >> $TMP1
343                echo 'set nokey' >> $TMP1
344                echo 'set xrange [0:255]' >> $TMP1
345                echo "plot \"$TMP2\" with lines" >> $TMP1
346                echo 'pause -1 "    Hit return to continue..."' >> $TMP1
347                > $TMP2
348        fi
349
350        let pwm=$MAX
351        pwmenable $P
352        while [ $pwm -ge 0 ]
353        do
354                pwmset $P $pwm 
355                sleep $PDELAY
356                if [ $? -ne 0 ]
357                then
358                        pwmdisable $P   
359                        echo '^C received, aborting...'
360                        rm -f $TMP1 $TMP2
361                        exit 1
362                fi             
363                # this will return the first field if there's only one (sysfs)
364                S=`cat $F | cut -d' ' -f2`
365                echo "    PWM $pwm FAN $S"
366                if [ "$PLOT" = "y" ]
367                then
368                        echo "$pwm $S" >> $TMP2
369                fi
370                if [ "$S" = "0" -o "$S" = "-1" ]
371                then
372                        pwmdisable $P   
373                        echo "    Fan Stopped at PWM = $pwm"
374                        if [ $pwm -eq $MAX ]
375                        then
376                                echo "    This fan appears to stop when the PWM is enabled;"
377                                echo "    perhaps the fan input shares a pin with the PWM output"
378                                echo "    on the sensor chip."
379                                echo "    You cannot control this fan with this PWM output."
380                                rm -f $TMP1 $TMP2
381                                echo
382                                return 0
383                        fi
384                        break
385                fi
386                if [ $pwm -lt $STEP2_BELOW ]
387                then
388                        let pwm=$pwm-$STEP2
389                else
390                        let pwm=$pwm-$STEP
391                fi
392        done
393        pwmdisable $P   
394        if [ "$PLOT" = "y" ]
395        then
396                $PLOTTER  $TMP1
397                rm -f $TMP1 $TMP2
398        fi
399        echo
400}
401
402for i in $GOODPWM
403do
404        echo Testing pwm control $i ...
405        pwmenable $i
406        if [ $? -ne 0 ]
407        then
408                echo "Manual control mode not supported, skipping."
409                continue
410        fi
411        pwmset $i 0
412        sleep $DELAY
413        if [ $? -ne 0 ]
414        then
415                pwmdisable $i
416                echo '^C received, restoring PWM and aborting...'
417                exit 1
418        fi             
419        let pwmactivecount=0
420        let count=1
421        for j in $GOODFAN
422        do
423                OS=`echo $SPEEDS | cut -d' ' -f$count`
424                # this will return the first field if there's only one (sysfs)
425                S=`cat $j | cut -d' ' -f2`
426                echo "  $j ... speed was $OS now $S"
427                pwmdisable $i
428                let threshold=2*$OS/3
429                if [ $S -lt $threshold ]
430                then
431                        echo "    It appears that fan $j"
432                        echo "    is controlled by pwm $i"
433#
434# a PWM can control more than one fan....
435#
436                        if [ $pwmactivecount -eq 0 ]
437                        then
438                                let pwmactivecount=1
439                                pwmactive="$i ${pwmactive}"
440                                fanactive="$j ${fanactive}"
441                        else
442                                fanactive="$j+${fanactive}" #not supported yet by fancontrol
443                        fi
444                        sleep $DELAY
445                        if [ $? -ne 0 ]
446                        then
447                                echo '^C received, aborting...'
448                                exit 1
449                        fi             
450                        # this will return the first field if there's only one (sysfs)
451                        S=`cat $j | cut -d' ' -f2`
452                        if [ $S -lt $threshold ]
453                        then
454                                echo "    Fan $j has not returned to speed, please investigate!"
455                        else
456                                echo -n "Would you like to generate a detailed correlation (y)? "
457                                read X
458                                if [ "$X" = "y" -o "$X" = "Y" -o "$X" = "" ]
459                                then
460                                        pwmdetail $i $j
461                                fi
462                        fi
463                else
464                        echo "    no correlation"
465                fi
466                let count=count+1
467        done
468        echo
469        if [ "$pwmactivecount" = "0" ]
470        then
471                echo "No correlations were detected."
472                echo "There is either no fan connected to the output of $i,"
473                echo "or the connected fan has no rpm-signal connected to one of"
474                echo "the tested fan sensors. (Note: not all motherboards have"
475                echo "the pwm outputs connected to the fan connectors,"
476                echo "check out the hardware database on http://www.almico.com/forumindex.php)"
477                echo
478                echo -n "Did you see/hear a fan stopping during the above test (n)? "
479                read X
480                if [ "$X" = "y" -o "$X" = "Y" ]
481                then
482                        pwmactive="$i ${pwmactive}"
483                fi
484                echo
485        fi
486done
487
488
489echo 'Testing is complete.'
490echo 'Please verify that all fans have returned to their normal speed.'
491echo
492echo 'The fancontrol script can automatically respond to temperature changes'
493echo 'of your system by changing fanspeeds.'
494echo -n 'Do you want to set up its configuration file now (y)? '
495
496read X
497if [ "$X" = "n" -o "$X" = "N" ]
498then
499        exit
500fi
501
502if [ -n "$SYSFS" ]
503then
504        MATCH=$PREFIX/'temp[1-9]_input'
505else
506        MATCH=$PREFIX/'temp[1-9]'
507fi
508TEMPS=`echo $MATCH`
509if [ "$MATCH" = "$TEMPS" ]
510then
511        echo $0: 'There are no temperature-capable sensor modules installed'
512        exit 1
513fi
514
515function AskPath {
516        echo -n 'What should be the path to your fancontrol config file (/etc/fancontrol)? '
517
518        read FCCONFIG
519        if [ "$FCCONFIG" = "" ]
520        then
521                FCCONFIG="/etc/fancontrol"
522        fi
523}
524
525AskPath
526
527function ClearConfig {
528        FCTEMPS=""
529        FCFANS=""
530        MINTEMP=""
531        MAXTEMP=""
532        MINSTART=""
533        MINSTOP=""
534        MINPWM=""
535        MAXPWM=""
536}
537
538function LoadConfig {
539        # Nothing to do
540        if [ ! -f "$1" ]
541        then
542                ClearConfig
543                return 0
544        fi
545
546        echo "Loading configuration from $1 ..."
547        INTERVAL=`egrep '^INTERVAL=.*$' $1 | sed -e 's/INTERVAL= *//g'`
548        FCTEMPS=`egrep '^FCTEMPS=.*$' $1 | sed -e 's/FCTEMPS= *//g'`
549        FCFANS=`egrep '^FCFANS=.*$' $1 | sed -e 's/FCFANS= *//g'`
550        MINTEMP=`egrep '^MINTEMP=.*$' $1 | sed -e 's/MINTEMP= *//g'`
551        MAXTEMP=`egrep '^MAXTEMP=.*$' $1 | sed -e 's/MAXTEMP= *//g'`
552        MINSTART=`egrep '^MINSTART=.*$' $1 | sed -e 's/MINSTART= *//g'`
553        MINSTOP=`egrep '^MINSTOP=.*$' $1 | sed -e 's/MINSTOP= *//g'`
554        MINPWM=`egrep '^MINPWM=.*$' $1 | sed -e 's/MINPWM= *//g'`
555        MAXPWM=`egrep '^MAXPWM=.*$' $1 | sed -e 's/MAXPWM= *//g'`
556
557        # Check for configuration change
558        local item
559        for item in $FCFANS
560        do
561                if [ ! -f "`echo $item | sed -e 's/=.*$//'`" ]
562                then
563                        echo "Configuration appears to be outdated, discarded"
564                        ClearConfig
565                        return 0
566                fi
567        done
568}
569
570LoadConfig $FCCONFIG
571
572function TestMinStart {
573        echo
574        echo 'Now we increase the PWM value in 10-unit-steps.'
575        echo 'Let the fan stop completely, then press return until the'
576        echo "fan starts spinning. Then enter 'y'."
577        echo 'We will use this value +20 as the starting speed.'
578        let fanok=0
579        let fanval=0
580
581        pwmenable $pwms
582        until [ "$fanok" = "1" ]
583        do
584                let fanval=fanval+10
585                if [ $fanval -gt 240 ] ; then let fanval=$MAX ; let fanok=1 ; fi
586                echo -n "Setting $pwms to $fanval..."
587                pwmset $pwms $fanval
588                read FANTEST
589                if [ "$FANTEST" != "" ] ; then let fanok=1 ; fi
590        done
591        pwmdisable $pwms
592
593        let fanval=fanval+20
594        if [ $fanval -gt 240 ] ; then let fanval=$MAX ; fi
595        echo "OK, using $fanval"
596}
597
598function TestMinStop {
599        echo
600        echo 'Now we decrease the PWM value in 10-unit-steps.'
601        echo 'Let the fan reach full speed, then press return until the'
602        echo "fan stops spinning. Then enter 'y'."
603        echo 'We will use this value +20 as the minimum speed.'
604        let fanok=0
605        let fanval=$MAX
606
607        pwmenable $pwms
608        until [ "$fanok" = "1" ]
609        do
610                let fanval=fanval-10
611                if [ $fanval -lt 0 ] ; then let fanval=0 ; let fanok=1 ; fi
612                echo -n "Setting $pwms to $fanval..."
613                pwmset $pwms $fanval
614                read FANTEST
615                if [ "$FANTEST" != "" ] ; then let fanok=1 ; fi
616        done
617        pwmdisable $pwms
618
619        let fanval=fanval+20
620        if [ $fanval -gt $MAX ] ; then let fanval=$MAX ; fi
621        echo "OK, using $fanval"
622}
623
624function SaveConfig {
625        echo
626        echo "Saving configuration to $FCCONFIG..."
627        tmpfile=`mktemp -t pwmcfg.XXXXXXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1;  }
628        trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
629        echo "# Configuration file generated by pwmconfig, changes will be lost" >$tmpfile
630        echo -e "INTERVAL=$INTERVAL\nFCTEMPS=$FCTEMPS\nFCFANS=$FCFANS\nMINTEMP=$MINTEMP\nMAXTEMP=$MAXTEMP\nMINSTART=$MINSTART\nMINSTOP=$MINSTOP" >>$tmpfile
631        [ -n "$MINPWM" ] && echo "MINPWM=$MINPWM" >>$tmpfile
632        [ -n "$MAXPWM" ] && echo "MAXPWM=$MAXPWM" >>$tmpfile
633        mv $tmpfile $FCCONFIG
634        chmod +r $FCCONFIG
635        #check if file was written correctly
636        echo 'Configuration saved'
637}
638
639INTERVAL=10
640PS3='select (1-n): '
641DEFMINTEMP=0
642DEFMAXTEMP=60
643DEFMINSTART=150
644DEFMINSTOP=100
645
646# "select" won't repeat the list of options, so we enclose it in a
647# never-ending loop so that it starts over again with each iteration.
648# I admit it's not exactly nice, but I do not have a better idea to
649# keep usability at an acceptable level.
650while [ 1 ] ; do
651echo
652echo 'Select fan output to configure, or other action:'
653select pwms in $pwmactive "Change INTERVAL" "Just quit" "Save and quit" "Show configuration"; do
654        case $pwms in
655        "Change INTERVAL")
656                echo
657                echo "Current interval is $INTERVAL seconds."
658                echo -n "Enter the interval at which fancontrol should update PWM values (in s): "
659                read INTERVAL #check user input here
660                break ;;
661        "Just quit")
662                exit ;;
663        "Save and quit")
664                SaveConfig
665                exit ;;
666        "Show configuration")
667                echo
668                echo "Common Settings:"
669                echo "INTERVAL=$INTERVAL"
670                for pwmo in $pwmactive
671                do
672                        echo
673                        echo "Settings of ${pwmo}:"
674                        echo "  Depends on `echo $FCTEMPS |sed -e 's/ /\n/g' |egrep \"${pwmo}\" |sed -e 's/.*=//g'`"
675                        echo "  Controls `echo $FCFANS |sed -e 's/ /\n/g' |egrep \"${pwmo}\" |sed -e 's/.*=//g'`"
676                        echo "  MINTEMP=`echo $MINTEMP |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`"
677                        echo "  MAXTEMP=`echo $MAXTEMP |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`"
678                        echo "  MINSTART=`echo $MINSTART |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`"
679                        echo "  MINSTOP=`echo $MINSTOP |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`"
680                        XMINP=`echo $MINPWM | sed -e "s/ /\n/g" | egrep "${pwmo}" | sed -e "s/.*=//g"`
681                        [ -n "$XMINP" ] && echo "  MINPWM=$XMINP"
682                        XMAXP=`echo $MAXPWM | sed -e "s/ /\n/g" | egrep "${pwmo}" | sed -e "s/.*=//g"`
683                        [ -n "$XMAXP" ] && echo "  MAXPWM=$XMAXP"
684                done
685                echo
686                break ;;
687
688        "`echo ${pwmactive} |sed -e 's/ /\n/g' | egrep \"${pwms}\"`" )
689                pwmsed=`echo ${pwms} | sed -e 's/\//\\\\\//g'` #escape / for sed
690                echo
691                if [ -n "$SYSFS" ]
692                then
693                        echo 'Devices:'
694                        print_devices ""
695                        echo
696                fi
697                echo 'Current temperature readings are as follows:'
698                for j in $TEMPS
699                do
700                        # this will return the first field if there's only one (sysfs)
701                        S=`cat $j | cut -d' ' -f3`
702                        if [ -n "$SYSFS" ]
703                        then
704                                let S="$S / 1000"
705                        fi
706                        echo "$j        $S"
707                done
708                FAN=`echo $fanactive|cut -d' ' -f$REPLY`
709                FCFANS="`echo $FCFANS | sed -e "s/${pwmsed}[^ ]* *//g\"` ${pwms}=$FAN"
710                echo
711                echo "Select a temperature sensor as source for ${pwms}:"
712                select tempss in $TEMPS "None (Do not affect this PWM output)"; do
713                        if [ "$tempss" = "None (Do not affect this PWM output)" ]
714                        then
715                       
716                                break;
717                        else
718                                if [ "$FCTEMPS" = "" ]
719                                then
720                                        FCTEMPS="${pwms}=${tempss}"
721                                else
722                                        FCTEMPS="`echo $FCTEMPS | sed -e "s/${pwmsed}[^ ]* *//g\"` ${pwms}=${tempss}"
723                                fi
724                        fi
725                        echo
726                        echo 'Enter the low temperature (degree C)'
727                        echo -n "below which the fan should spin at minimum speed ($DEFMINTEMP): "
728                        read XMT
729                        if [ "$XMT" = "" ]
730                        then
731                                XMT=$DEFMINTEMP
732                        fi
733                        if [ "$MINTEMP" = "" ]
734                        then
735                                MINTEMP="${pwms}=${XMT}"
736                        else
737                                MINTEMP="`echo $MINTEMP | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMT}"
738                        fi
739                        echo
740                        echo 'Enter the high temperature (degree C)'
741                        echo -n "over which the fan should spin at maximum speed ($DEFMAXTEMP): "
742                        read XMT
743                        if [ "$XMT" = "" ]
744                        then
745                                XMT=$DEFMAXTEMP
746                        fi
747                        if [ "$MAXTEMP" = "" ]
748                        then
749                                MAXTEMP="${pwms}=${XMT}"
750                        else
751                                MAXTEMP="`echo $MAXTEMP | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMT}"
752                        fi
753                        echo
754                        echo "Enter the minimum PWM value (0-$MAX)"
755                        echo -n "at which the fan STARTS spinning (press t to test) ($DEFMINSTART): "
756                        read XMV
757                        if [ "$XMV" = "" ]
758                        then
759                                XMV=$DEFMINSTART
760                        fi
761                        if [ "$XMV" = "t" -o "$XMV" = "T" ]
762                        then
763                                TestMinStart
764                                XMV=$fanval
765                        fi
766                        if [ "$MINSTART" = "" ]
767                        then
768                                MINSTART="${pwms}=${XMV}"
769                        else
770                                MINSTART="`echo $MINSTART | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMV}"
771                        fi
772                        echo
773                        echo "Enter the minimum PWM value (0-$MAX)"
774                        echo -n "at which the fan STOPS spinning (press t to test) ($DEFMINSTOP): "
775                        read XMV
776                        if [ "$XMV" = "" ]
777                        then
778                                XMV=$DEFMINSTOP
779                        fi
780                        if [ "$XMV" = "t" -o "$XMV" = "T" ]
781                        then
782                                TestMinStop
783                                XMV=$fanval
784                        fi
785                        if [ "$MINSTOP" = "" ]
786                        then
787                                MINSTOP="${pwms}=${XMV}"
788                        else
789                                MINSTOP="`echo $MINSTOP | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMV}"
790                        fi
791                        echo
792                        echo "Enter the PWM value (0-$XMV) to use when the temperature"
793                        echo -n "is below the low temperature limit (0): "
794                        read XMINP
795                        if [ -n "$XMINP" ]
796                        then
797                                if [ "$MINPWM" = "" ]
798                                then
799                                        MINPWM="${pwms}=${XMINP}"
800                                else
801                                        MINPWM="`echo $MINPWM | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMINP}"
802                                fi
803                        fi
804                        echo
805                        echo "Enter the PWM value ($XMV-$MAX) to use when the temperature"
806                        echo -n "is over the high temperature limit ($MAX): "
807                        read XMAXP
808                        if [ -n "$XMAXP" ]
809                        then
810                                if [ "$MAXPWM" = "" ]
811                                then
812                                        MAXPWM="${pwms}=${XMAXP}"
813                                else
814                                        MAXPWM="`echo $MAXPWM | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMAXP}"
815                                fi
816                        fi
817                        echo
818                        break;
819                done
820                break ;;
821       
822        *)
823                echo "No such option. Enter a number."
824                break ;;
825        esac
826done
827done
Note: See TracBrowser for help on using the browser.