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

Revision 5061, 18.3 KB (checked in by khali, 5 years ago)

Really hide errors on sysfs writes.
Deal gracefully with read-only pwm_enable files.

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