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

Revision 5320, 19.4 KB (checked in by khali, 6 years ago)

Coding-style cleanups.

  • 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{
517        echo -n 'What should be the path to your fancontrol config file (/etc/fancontrol)? '
518
519        read FCCONFIG
520        if [ "$FCCONFIG" = "" ]
521        then
522                FCCONFIG="/etc/fancontrol"
523        fi
524}
525
526AskPath
527
528function ClearConfig()
529{
530        FCTEMPS=""
531        FCFANS=""
532        MINTEMP=""
533        MAXTEMP=""
534        MINSTART=""
535        MINSTOP=""
536        MINPWM=""
537        MAXPWM=""
538}
539
540function LoadConfig()
541{
542        # Nothing to do
543        if [ ! -f "$1" ]
544        then
545                ClearConfig
546                return 0
547        fi
548
549        echo "Loading configuration from $1 ..."
550        INTERVAL=`egrep '^INTERVAL=.*$' $1 | sed -e 's/INTERVAL= *//g'`
551        FCTEMPS=`egrep '^FCTEMPS=.*$' $1 | sed -e 's/FCTEMPS= *//g'`
552        FCFANS=`egrep '^FCFANS=.*$' $1 | sed -e 's/FCFANS= *//g'`
553        MINTEMP=`egrep '^MINTEMP=.*$' $1 | sed -e 's/MINTEMP= *//g'`
554        MAXTEMP=`egrep '^MAXTEMP=.*$' $1 | sed -e 's/MAXTEMP= *//g'`
555        MINSTART=`egrep '^MINSTART=.*$' $1 | sed -e 's/MINSTART= *//g'`
556        MINSTOP=`egrep '^MINSTOP=.*$' $1 | sed -e 's/MINSTOP= *//g'`
557        MINPWM=`egrep '^MINPWM=.*$' $1 | sed -e 's/MINPWM= *//g'`
558        MAXPWM=`egrep '^MAXPWM=.*$' $1 | sed -e 's/MAXPWM= *//g'`
559
560        # Check for configuration change
561        local item
562        for item in $FCFANS
563        do
564                if [ ! -f "`echo $item | sed -e 's/=.*$//'`" ]
565                then
566                        echo "Configuration appears to be outdated, discarded"
567                        ClearConfig
568                        return 0
569                fi
570        done
571}
572
573LoadConfig $FCCONFIG
574
575function TestMinStart()
576{
577        echo
578        echo 'Now we increase the PWM value in 10-unit-steps.'
579        echo 'Let the fan stop completely, then press return until the'
580        echo "fan starts spinning. Then enter 'y'."
581        echo 'We will use this value +20 as the starting speed.'
582        let fanok=0
583        let fanval=0
584
585        pwmenable $pwms
586        until [ "$fanok" = "1" ]
587        do
588                let fanval=fanval+10
589                if [ $fanval -gt 240 ] ; then let fanval=$MAX ; let fanok=1 ; fi
590                echo -n "Setting $pwms to $fanval..."
591                pwmset $pwms $fanval
592                read FANTEST
593                if [ "$FANTEST" != "" ] ; then let fanok=1 ; fi
594        done
595        pwmdisable $pwms
596
597        let fanval=fanval+20
598        if [ $fanval -gt 240 ] ; then let fanval=$MAX ; fi
599        echo "OK, using $fanval"
600}
601
602function TestMinStop()
603{
604        echo
605        echo 'Now we decrease the PWM value in 10-unit-steps.'
606        echo 'Let the fan reach full speed, then press return until the'
607        echo "fan stops spinning. Then enter 'y'."
608        echo 'We will use this value +20 as the minimum speed.'
609        let fanok=0
610        let fanval=$MAX
611
612        pwmenable $pwms
613        until [ "$fanok" = "1" ]
614        do
615                let fanval=fanval-10
616                if [ $fanval -lt 0 ] ; then let fanval=0 ; let fanok=1 ; fi
617                echo -n "Setting $pwms to $fanval..."
618                pwmset $pwms $fanval
619                read FANTEST
620                if [ "$FANTEST" != "" ] ; then let fanok=1 ; fi
621        done
622        pwmdisable $pwms
623
624        let fanval=fanval+20
625        if [ $fanval -gt $MAX ] ; then let fanval=$MAX ; fi
626        echo "OK, using $fanval"
627}
628
629function SaveConfig()
630{
631        echo
632        echo "Saving configuration to $FCCONFIG..."
633        tmpfile=`mktemp -t pwmcfg.XXXXXXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1;  }
634        trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
635        echo "# Configuration file generated by pwmconfig, changes will be lost" >$tmpfile
636        echo -e "INTERVAL=$INTERVAL\nFCTEMPS=$FCTEMPS\nFCFANS=$FCFANS\nMINTEMP=$MINTEMP\nMAXTEMP=$MAXTEMP\nMINSTART=$MINSTART\nMINSTOP=$MINSTOP" >>$tmpfile
637        [ -n "$MINPWM" ] && echo "MINPWM=$MINPWM" >>$tmpfile
638        [ -n "$MAXPWM" ] && echo "MAXPWM=$MAXPWM" >>$tmpfile
639        mv $tmpfile $FCCONFIG
640        chmod +r $FCCONFIG
641        #check if file was written correctly
642        echo 'Configuration saved'
643}
644
645INTERVAL=10
646PS3='select (1-n): '
647DEFMINTEMP=0
648DEFMAXTEMP=60
649DEFMINSTART=150
650DEFMINSTOP=100
651
652# "select" won't repeat the list of options, so we enclose it in a
653# never-ending loop so that it starts over again with each iteration.
654# I admit it's not exactly nice, but I do not have a better idea to
655# keep usability at an acceptable level.
656while [ 1 ] ; do
657echo
658echo 'Select fan output to configure, or other action:'
659select pwms in $pwmactive "Change INTERVAL" "Just quit" "Save and quit" "Show configuration"; do
660        case $pwms in
661        "Change INTERVAL")
662                echo
663                echo "Current interval is $INTERVAL seconds."
664                echo -n "Enter the interval at which fancontrol should update PWM values (in s): "
665                read INTERVAL #check user input here
666                break ;;
667        "Just quit")
668                exit ;;
669        "Save and quit")
670                SaveConfig
671                exit ;;
672        "Show configuration")
673                echo
674                echo "Common Settings:"
675                echo "INTERVAL=$INTERVAL"
676                for pwmo in $pwmactive
677                do
678                        echo
679                        echo "Settings of ${pwmo}:"
680                        echo "  Depends on `echo $FCTEMPS |sed -e 's/ /\n/g' |egrep \"${pwmo}\" |sed -e 's/.*=//g'`"
681                        echo "  Controls `echo $FCFANS |sed -e 's/ /\n/g' |egrep \"${pwmo}\" |sed -e 's/.*=//g'`"
682                        echo "  MINTEMP=`echo $MINTEMP |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`"
683                        echo "  MAXTEMP=`echo $MAXTEMP |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`"
684                        echo "  MINSTART=`echo $MINSTART |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`"
685                        echo "  MINSTOP=`echo $MINSTOP |sed -e \"s/ /\n/g\" |egrep \"${pwmo}\" |sed -e \"s/.*=//g\"`"
686                        XMINP=`echo $MINPWM | sed -e "s/ /\n/g" | egrep "${pwmo}" | sed -e "s/.*=//g"`
687                        [ -n "$XMINP" ] && echo "  MINPWM=$XMINP"
688                        XMAXP=`echo $MAXPWM | sed -e "s/ /\n/g" | egrep "${pwmo}" | sed -e "s/.*=//g"`
689                        [ -n "$XMAXP" ] && echo "  MAXPWM=$XMAXP"
690                done
691                echo
692                break ;;
693
694        "`echo ${pwmactive} |sed -e 's/ /\n/g' | egrep \"${pwms}\"`" )
695                pwmsed=`echo ${pwms} | sed -e 's/\//\\\\\//g'` #escape / for sed
696                echo
697                if [ -n "$SYSFS" ]
698                then
699                        echo 'Devices:'
700                        print_devices ""
701                        echo
702                fi
703                echo 'Current temperature readings are as follows:'
704                for j in $TEMPS
705                do
706                        # this will return the first field if there's only one (sysfs)
707                        S=`cat $j | cut -d' ' -f3`
708                        if [ -n "$SYSFS" ]
709                        then
710                                let S="$S / 1000"
711                        fi
712                        echo "$j        $S"
713                done
714                FAN=`echo $fanactive|cut -d' ' -f$REPLY`
715                FCFANS="`echo $FCFANS | sed -e "s/${pwmsed}[^ ]* *//g\"` ${pwms}=$FAN"
716                echo
717                echo "Select a temperature sensor as source for ${pwms}:"
718                select tempss in $TEMPS "None (Do not affect this PWM output)"; do
719                        if [ "$tempss" = "None (Do not affect this PWM output)" ]
720                        then
721                       
722                                break;
723                        else
724                                if [ "$FCTEMPS" = "" ]
725                                then
726                                        FCTEMPS="${pwms}=${tempss}"
727                                else
728                                        FCTEMPS="`echo $FCTEMPS | sed -e "s/${pwmsed}[^ ]* *//g\"` ${pwms}=${tempss}"
729                                fi
730                        fi
731                        echo
732                        echo 'Enter the low temperature (degree C)'
733                        echo -n "below which the fan should spin at minimum speed ($DEFMINTEMP): "
734                        read XMT
735                        if [ "$XMT" = "" ]
736                        then
737                                XMT=$DEFMINTEMP
738                        fi
739                        if [ "$MINTEMP" = "" ]
740                        then
741                                MINTEMP="${pwms}=${XMT}"
742                        else
743                                MINTEMP="`echo $MINTEMP | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMT}"
744                        fi
745                        echo
746                        echo 'Enter the high temperature (degree C)'
747                        echo -n "over which the fan should spin at maximum speed ($DEFMAXTEMP): "
748                        read XMT
749                        if [ "$XMT" = "" ]
750                        then
751                                XMT=$DEFMAXTEMP
752                        fi
753                        if [ "$MAXTEMP" = "" ]
754                        then
755                                MAXTEMP="${pwms}=${XMT}"
756                        else
757                                MAXTEMP="`echo $MAXTEMP | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMT}"
758                        fi
759                        echo
760                        echo "Enter the minimum PWM value (0-$MAX)"
761                        echo -n "at which the fan STARTS spinning (press t to test) ($DEFMINSTART): "
762                        read XMV
763                        if [ "$XMV" = "" ]
764                        then
765                                XMV=$DEFMINSTART
766                        fi
767                        if [ "$XMV" = "t" -o "$XMV" = "T" ]
768                        then
769                                TestMinStart
770                                XMV=$fanval
771                        fi
772                        if [ "$MINSTART" = "" ]
773                        then
774                                MINSTART="${pwms}=${XMV}"
775                        else
776                                MINSTART="`echo $MINSTART | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMV}"
777                        fi
778                        echo
779                        echo "Enter the minimum PWM value (0-$MAX)"
780                        echo -n "at which the fan STOPS spinning (press t to test) ($DEFMINSTOP): "
781                        read XMV
782                        if [ "$XMV" = "" ]
783                        then
784                                XMV=$DEFMINSTOP
785                        fi
786                        if [ "$XMV" = "t" -o "$XMV" = "T" ]
787                        then
788                                TestMinStop
789                                XMV=$fanval
790                        fi
791                        if [ "$MINSTOP" = "" ]
792                        then
793                                MINSTOP="${pwms}=${XMV}"
794                        else
795                                MINSTOP="`echo $MINSTOP | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMV}"
796                        fi
797                        echo
798                        echo "Enter the PWM value (0-$XMV) to use when the temperature"
799                        echo -n "is below the low temperature limit (0): "
800                        read XMINP
801                        if [ -n "$XMINP" ]
802                        then
803                                if [ "$MINPWM" = "" ]
804                                then
805                                        MINPWM="${pwms}=${XMINP}"
806                                else
807                                        MINPWM="`echo $MINPWM | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMINP}"
808                                fi
809                        fi
810                        echo
811                        echo "Enter the PWM value ($XMV-$MAX) to use when the temperature"
812                        echo -n "is over the high temperature limit ($MAX): "
813                        read XMAXP
814                        if [ -n "$XMAXP" ]
815                        then
816                                if [ "$MAXPWM" = "" ]
817                                then
818                                        MAXPWM="${pwms}=${XMAXP}"
819                                else
820                                        MAXPWM="`echo $MAXPWM | sed -e \"s/${pwmsed}[^ ]* *//g\"` ${pwms}=${XMAXP}"
821                                fi
822                        fi
823                        echo
824                        break;
825                done
826                break ;;
827       
828        *)
829                echo "No such option. Enter a number."
830                break ;;
831        esac
832done
833done
Note: See TracBrowser for help on using the browser.