Changeset 5765

Show
Ignore:
Timestamp:
09/08/09 18:52:29 (4 years ago)
Author:
khali
Message:

Check that all referenced sysfs files exist before starting. If not,
quilt immediately. Better no fan control than fan control using an
out-of-sync configuration file.

Location:
lm-sensors/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r5761 r5765  
    44SVN-HEAD 
    55  libsensors: Support upcoming sysfs path to i2c adapters 
     6  fancontrol: Check that all referenced sysfs files exist 
    67  pwmconfig: Exit immediately if not root 
    78  sensors.conf.default: Encourage user to not modify this file 
  • lm-sensors/trunk/prog/pwm/fancontrol

    r5764 r5765  
    153153} 
    154154 
     155# Check that all referenced sysfs files exist 
     156function CheckFiles { 
     157        local outdated=0 
     158 
     159        let fcvcount=0 
     160        while (( $fcvcount < ${#AFCPWM[@]} )) # go through all pwm outputs 
     161        do 
     162                pwmo=${AFCPWM[$fcvcount]} 
     163                if [ ! -w $pwmo ] 
     164                then 
     165                        echo "Error: file $pwmo doesn't exist" 
     166                        outdated=1 
     167                fi 
     168                let fcvcount=$fcvcount+1 
     169        done 
     170 
     171        let fcvcount=0 
     172        while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs 
     173        do 
     174                tsen=${AFCTEMP[$fcvcount]} 
     175                if [ ! -r $tsen ] 
     176                then 
     177                        echo "Error: file $tsen doesn't exist" 
     178                        outdated=1 
     179                fi 
     180                let fcvcount=$fcvcount+1 
     181        done 
     182 
     183        let fcvcount=0 
     184        while (( $fcvcount < ${#AFCFAN[@]} )) # go through all fan inputs 
     185        do 
     186                fan=${AFCFAN[$fcvcount]} 
     187                if [ ! -r $fan ] 
     188                then 
     189                        echo "Error: file $fan doesn't exist" 
     190                        outdated=1 
     191                fi 
     192                let fcvcount=$fcvcount+1 
     193        done 
     194 
     195        if [ $outdated -eq 1 ] 
     196        then 
     197                echo 
     198                echo "At least one referenced file is missing. Either some" 
     199                echo "required kernel modules haven't been loaded, or your" 
     200                echo "configuration file is outdated. In the latter case," 
     201                echo "you should run pwmconfig again." 
     202        fi 
     203 
     204        return $outdated 
     205} 
     206 
    155207if [ -f "$1" ] 
    156208then 
     
    181233fi 
    182234cd $DIR 
     235 
     236CheckFiles || exit 1 
    183237 
    184238if [ -f "$PIDFILE" ] 
  • lm-sensors/trunk/prog/pwm/fancontrol.8

    r5717 r5765  
    1 .TH FANCONTROL 8 "January 2009" "lm-sensors 3" 
     1.TH FANCONTROL 8 "September 2009" "lm-sensors 3" 
    22.SH NAME 
    33fancontrol \- automated software based fan speed regulation 
     
    9393editing the config file directly following the rules above. 
    9494 
     95Upon starting, fancontrol will make sure that all referenced sysfs files 
     96do exist. If not, it will quit immediately, upon the assumption that the 
     97configuration file may be out-of-sync with the loaded kernel drivers. 
     98 
    9599.SH THE ALGORITHM 
    96100