Changeset 2177

Show
Ignore:
Timestamp:
12/14/03 20:19:52 (9 years ago)
Author:
mds
Message:

improvements

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/prog/pwm/pwmconfig

    r2048 r2177  
    1 # 
    2 # pwmconfig v0.5 
     1#!/bin/bash 
     2# 
     3# pwmconfig v0.6 
    34# Tests the pwm outputs of sensors and configures fancontrol 
    45# 
     
    137138        PLOT= 
    138139 
    139         type gnuplot > /dev/null 2>&1 
     140        type $PLOTTER > /dev/null 2>&1 
    140141        if [ $? -eq 0 ] 
    141142        then 
    142                 echo -n "    Would you like to generate a graphical plot using $PLOTTER (y) ? " 
     143                echo -n "    Would you like to generate a graphical plot using $PLOTTER (y)? " 
    143144                read X 
    144145                if [ "$X" = "y" -o "$X" = "Y" -o "$X" = "" ] 
     
    248249                                echo "    Fan $j has not returned to speed, please investigate!" 
    249250                        else 
    250                                 echo -n "    Would you like to generate a detailed correlation (y) ? " 
     251                                echo -n "Would you like to generate a detailed correlation (y)? " 
    251252                                read X 
    252253                                if [ "$X" = "y" -o "$X" = "Y" -o "$X" = "" ] 
     
    261262        done 
    262263        echo 
    263                 if [ "$pwmactivecount" = "0" ] 
    264                 then 
    265                         echo "No correlations were detected, there is either no fan connected to the output of $i, or the connected fan has no rpm-signal connected to one of the tested fan sensors. (Note: not all motherboards have the pwm outputs connected to the fan connectors, check out the hardware database on http://www.almico.com/forumindex.php)" 
    266                         echo 
    267                         echo -n "  Did you see/hear a fan stopping during the above test (y)?" 
    268                         read X 
    269                         if [ "$X" = "y" -o "$X" = "Y" -o "$X" = "" ] 
    270                         then 
    271                                 pwmactive="$i ${pwmactive}" 
    272                         fi 
    273                 fi 
     264        if [ "$pwmactivecount" = "0" ] 
     265        then 
     266                echo "No correlations were detected." 
     267                echo "There is either no fan connected to the output of $i," 
     268                echo "or the connected fan has no rpm-signal connected to one of" 
     269                echo "the tested fan sensors. (Note: not all motherboards have" 
     270                echo "the pwm outputs connected to the fan connectors," 
     271                echo "check out the hardware database on http://www.almico.com/forumindex.php)" 
     272                echo 
     273                echo -n "Did you see/hear a fan stopping during the above test (n)? " 
     274                read X 
     275                if [ "$X" = "y" -o "$X" = "Y" ] 
     276                then 
     277                        pwmactive="$i ${pwmactive}" 
     278                fi 
     279                echo 
     280        fi 
    274281done 
    275282 
     
    279286echo 
    280287echo 'The fancontrol script can automatically respond to temperature changes' 
    281 echo 'of your system by changing fanspeeds. Do you want to set up its' 
    282 echo 'configuration file now? (y)' 
     288echo 'of your system by changing fanspeeds.' 
     289echo -n 'Do you want to set up its configuration file now (y)? ' 
    283290 
    284291read X 
     
    296303 
    297304function AskPath { 
    298         echo 'What should be the path to your fancontrol config file? (/etc/fancontrol)' 
     305        echo -n 'What should be the path to your fancontrol config file (/etc/fancontrol)? ' 
    299306 
    300307        read X 
     
    307314                FCCONFIG=$X 
    308315        else 
    309                 echo "$X does not exist, shall I create it now? (y)" 
     316                echo -n "$X does not exist, shall I create it now (y)? " 
    310317                read Y 
    311318                if [ "$Y" = "y" -o "$Y" = "Y" -o "$Y" = "" ] 
     
    337344function TestMinStart { 
    338345        echo 
    339         echo 'Now we increase the PWM value in 10-unit-steps. Let the fan stop completely, then press return until the fan starts spinning, we will use this value +20 to be safe.' 
     346        echo 'Now we increase the PWM value in 10-unit-steps.' 
     347        echo 'Let the fan stop completely, then press return until the' 
     348        echo 'fan starts spinning. We will use this value +20 to be safe.' 
    340349        let fanok=0 
    341350        let fanval=0 
     
    343352        do 
    344353                let fanval=fanval+10 
     354                if [ $fanval -gt 240 ] ; then let fanval=255 ; let fanok=1 ; fi 
    345355                echo -n "Setting $pwms to $fanval..." 
    346356                echo $fanval > $pwms 
     
    349359        done 
    350360        let fanval=fanval+20 
    351         if (( $fanval > 240 )) ; then let fanval=255 ; fi 
     361        if [ $fanval -gt 240 ] ; then let fanval=255 ; fi 
    352362        echo "OK, using $fanval" 
    353363        echo 255 > $pwms 
     
    356366function TestMinStop { 
    357367        echo 
    358         echo 'Now we decrease the PWM value in 10-unit-steps, Let the fan has reach full speed, then press return until the fan stops spinning, we will use this value +20 as the minimum speed.' 
     368        echo 'Now we decrease the PWM value in 10-unit-steps.' 
     369        echo 'Let the fan reach full speed, then press return until the' 
     370        echo 'fan stops spinning. We will use this value +20 as the minimum speed.' 
    359371        let fanok=0 
    360372        let fanval=255 
     
    362374        do 
    363375                let fanval=fanval-10 
    364                 if (( $fanval < 0 )) ; then fanval=0 ; fi 
     376                if [ $fanval -lt 0 ] ; then let fanval=0 ; let fanok=1 ; fi 
    365377                echo -n "Setting $pwms to $fanval..." 
    366378                echo $fanval > $pwms 
     
    369381        done 
    370382        let fanval=fanval+20 
    371         if (( $fanval > 255 )) ; then let fanval=255 ; fi 
     383        if [ $fanval -gt 255 ] ; then let fanval=255 ; fi 
    372384        echo "OK, using $fanval" 
    373385        echo 255 > $pwms 
     
    388400 
    389401INTERVAL=10 
     402PS3='select (1-n): ' 
     403DEFMINTEMP=0 
     404DEFMAXTEMP=60 
     405DEFMINSTART=150 
     406DEFMINSTOP=100 
    390407 
    391408#the section below has a high potential for usability improvements 
    392409echo 
    393 echo 'Select fan output to configure:' 
     410echo 'Select fan output to configure, or other action:' 
    394411select pwms in $pwmactive "Change INTERVAL" "Just quit" "Save and quit" "Show configuration"; do 
    395412        case $pwms in 
    396413        "Change INTERVAL") 
    397414                echo 
    398                 echo "Enter the interval at which fancontrol should update PWM values (in s):" 
     415                echo "Current interval is $INTERVAL seconds." 
     416                echo -n "Enter the interval at which fancontrol should update PWM values (in s):" 
    399417                read INTERVAL ;; #check user input here 
    400418        "Just quit") 
     
    419437                echo ;; 
    420438 
    421         "`echo ${pwmactive} |sed -e \"s/ /\n/g\" | egrep \"${pwms}\"`" ) 
     439        "`echo ${pwmactive} |sed -e 's/ /\n/g' | egrep \"${pwms}\"`" ) 
    422440                pwmsed=`echo ${pwms} | sed -e 's/\//\\\\\//g'` #escape / for sed 
    423441                echo 
     
    437455                        fi 
    438456                        echo 
    439                         echo 'Enter the minimum temperature at which the fan should be switched off:' 
     457                        echo 'Enter the low temperature (C)' 
     458                        echo -n "at which the fan should be switched off ($DEFMINTEMP): " 
    440459                        read XMT 
     460                        if [ "$XMT" = "" ] 
     461                        then 
     462                                XMT=$DEFMINTEMP 
     463                        fi 
    441464                        if [ "$MINTEMP" = "" ] 
    442465                        then 
     
    446469                        fi 
    447470                        echo 
    448                         echo 'Enter the maximum temperature at which the fan should be switched to full speed:' 
     471                        echo 'Enter the high temperature (C)' 
     472                        echo -n "at which the fan should be switched to full speed ($DEFMAXTEMP): " 
    449473                        read XMT 
     474                        if [ "$XMT" = "" ] 
     475                        then 
     476                                XMT=$DEFMAXTEMP 
     477                        fi 
    450478                        if [ "$MAXTEMP" = "" ] 
    451479                        then 
     
    455483                        fi 
    456484                        echo 
    457                         echo 'Enter the minimum PWM value at which the fan STARTS spinning (press return to test):' 
     485                        echo 'Enter the minimum PWM value (0-255)' 
     486                        echo -n "at which the fan STARTS spinning (press t to test) ($DEFMINSTART): " 
    458487                        read XMV 
    459488                        if [ "$XMV" = "" ] 
     489                        then 
     490                                XMV=$DEFMINSTART 
     491                        fi 
     492                        if [ "$XMV" = "t" -o "$XMV" = "T" ] 
    460493                        then 
    461494                                TestMinStart 
     
    469502                        fi 
    470503                        echo 
    471                         echo 'Enter the minimum PWM value at which the fan STOPS spinning (press return to test):' 
     504                        echo 'Enter the minimum PWM value (0-255)' 
     505                        echo -n "at which the fan STOPS spinning (press t to test) ($DEFMINSTOP): " 
    472506                        read XMV 
    473507                        if [ "$XMV" = "" ] 
     508                        then 
     509                                XMV=$DEFMINSTOP 
     510                        fi 
     511                        if [ "$XMV" = "t" -o "$XMV" = "T" ] 
    474512                        then 
    475513                                TestMinStop 
     
    486524         
    487525        *) 
    488                 echo "No such option, press RETURN to show menu" ;; 
     526                grep $pwm 
     527 
     528                echo "No such option. Enter a number." ;; 
    489529        esac 
    490530done