mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 06:15:15 +00:00
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. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5765 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -3,6 +3,7 @@ lm-sensors CHANGES file
|
||||
|
||||
SVN-HEAD
|
||||
libsensors: Support upcoming sysfs path to i2c adapters
|
||||
fancontrol: Check that all referenced sysfs files exist
|
||||
pwmconfig: Exit immediately if not root
|
||||
sensors.conf.default: Encourage user to not modify this file
|
||||
sensors-detect: Refer to tmp401 driver if TMP411 is detected
|
||||
|
@@ -152,6 +152,58 @@ function LoadConfig {
|
||||
echo
|
||||
}
|
||||
|
||||
# Check that all referenced sysfs files exist
|
||||
function CheckFiles {
|
||||
local outdated=0
|
||||
|
||||
let fcvcount=0
|
||||
while (( $fcvcount < ${#AFCPWM[@]} )) # go through all pwm outputs
|
||||
do
|
||||
pwmo=${AFCPWM[$fcvcount]}
|
||||
if [ ! -w $pwmo ]
|
||||
then
|
||||
echo "Error: file $pwmo doesn't exist"
|
||||
outdated=1
|
||||
fi
|
||||
let fcvcount=$fcvcount+1
|
||||
done
|
||||
|
||||
let fcvcount=0
|
||||
while (( $fcvcount < ${#AFCTEMP[@]} )) # go through all temp inputs
|
||||
do
|
||||
tsen=${AFCTEMP[$fcvcount]}
|
||||
if [ ! -r $tsen ]
|
||||
then
|
||||
echo "Error: file $tsen doesn't exist"
|
||||
outdated=1
|
||||
fi
|
||||
let fcvcount=$fcvcount+1
|
||||
done
|
||||
|
||||
let fcvcount=0
|
||||
while (( $fcvcount < ${#AFCFAN[@]} )) # go through all fan inputs
|
||||
do
|
||||
fan=${AFCFAN[$fcvcount]}
|
||||
if [ ! -r $fan ]
|
||||
then
|
||||
echo "Error: file $fan doesn't exist"
|
||||
outdated=1
|
||||
fi
|
||||
let fcvcount=$fcvcount+1
|
||||
done
|
||||
|
||||
if [ $outdated -eq 1 ]
|
||||
then
|
||||
echo
|
||||
echo "At least one referenced file is missing. Either some"
|
||||
echo "required kernel modules haven't been loaded, or your"
|
||||
echo "configuration file is outdated. In the latter case,"
|
||||
echo "you should run pwmconfig again."
|
||||
fi
|
||||
|
||||
return $outdated
|
||||
}
|
||||
|
||||
if [ -f "$1" ]
|
||||
then
|
||||
LoadConfig $1
|
||||
@@ -181,6 +233,8 @@ then
|
||||
fi
|
||||
cd $DIR
|
||||
|
||||
CheckFiles || exit 1
|
||||
|
||||
if [ -f "$PIDFILE" ]
|
||||
then
|
||||
echo "File $PIDFILE exists, is fancontrol already running?"
|
||||
|
@@ -1,4 +1,4 @@
|
||||
.TH FANCONTROL 8 "January 2009" "lm-sensors 3"
|
||||
.TH FANCONTROL 8 "September 2009" "lm-sensors 3"
|
||||
.SH NAME
|
||||
fancontrol \- automated software based fan speed regulation
|
||||
|
||||
@@ -92,6 +92,10 @@ You have to play with the temperature values a bit to get happy. For initial
|
||||
setup I recommend using the \fBpwmconfig\fP script. Small changes can be made by
|
||||
editing the config file directly following the rules above.
|
||||
|
||||
Upon starting, fancontrol will make sure that all referenced sysfs files
|
||||
do exist. If not, it will quit immediately, upon the assumption that the
|
||||
configuration file may be out-of-sync with the loaded kernel drivers.
|
||||
|
||||
.SH THE ALGORITHM
|
||||
|
||||
\fBfancontrol\fP first reads its configuration, writes it to arrays and loops its
|
||||
|
Reference in New Issue
Block a user