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

Revision 5063, 18.9 KB (checked in by khali, 5 years ago)

Warn about outputs found in automatic mode.

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