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

Revision 5180, 19.4 KB (checked in by khali, 7 years ago)

pwmconfig: Don't start if fancontrol is running.
fancontrol: Don't start if already running, delete fancontrol.pid at
exit time.
This closes ticket #2299.

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