2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-02 23:35:57 +00:00

fancontrol: Output error messages to stderr

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6001 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2011-12-04 16:54:05 +00:00
parent bd21ec1ee4
commit 2c145550b5
2 changed files with 34 additions and 33 deletions

View File

@@ -3,6 +3,7 @@ lm-sensors CHANGES file
SVN HEAD SVN HEAD
fancontrol: Support setup where one PWM output controls several fans fancontrol: Support setup where one PWM output controls several fans
Output error messages to stderr
sensors-detect: Stop calling for PIIX5 SMBus testers sensors-detect: Stop calling for PIIX5 SMBus testers
Improve filtering of fake DMI data Improve filtering of fake DMI data
Print DMI system/product version if available Print DMI system/product version if available

View File

@@ -49,7 +49,7 @@ function LoadConfig {
echo "Loading configuration from $1 ..." echo "Loading configuration from $1 ..."
if [ ! -r "$1" ] if [ ! -r "$1" ]
then then
echo "Error: Can't read configuration file" echo "Error: Can't read configuration file" >&2
exit 1 exit 1
fi fi
@@ -70,13 +70,13 @@ function LoadConfig {
# Check whether all mandatory settings are set # Check whether all mandatory settings are set
if [[ -z ${INTERVAL} || -z ${FCTEMPS} || -z ${MINTEMP} || -z ${MAXTEMP} || -z ${MINSTART} || -z ${MINSTOP} ]] if [[ -z ${INTERVAL} || -z ${FCTEMPS} || -z ${MINTEMP} || -z ${MAXTEMP} || -z ${MINSTART} || -z ${MINSTOP} ]]
then then
echo "Some mandatory settings missing, please check your config file!" echo "Some mandatory settings missing, please check your config file!" >&2
exit 1 exit 1
fi fi
if [ "$INTERVAL" -le 0 ] if [ "$INTERVAL" -le 0 ]
then then
echo "Error in configuration file:" echo "Error in configuration file:" >&2
echo "INTERVAL must be at least 1" echo "INTERVAL must be at least 1" >&2
exit 1 exit 1
fi fi
@@ -90,8 +90,8 @@ function LoadConfig {
do do
if ! echo $fcv | egrep -q '=' if ! echo $fcv | egrep -q '='
then then
echo "Error in configuration file:" echo "Error in configuration file:" >&2
echo "FCTEMPS value is improperly formatted" echo "FCTEMPS value is improperly formatted" >&2
exit 1 exit 1
fi fi
@@ -110,32 +110,32 @@ function LoadConfig {
# verify the validity of the settings # verify the validity of the settings
if [ "${AFCMINTEMP[$fcvcount]}" -ge "${AFCMAXTEMP[$fcvcount]}" ] if [ "${AFCMINTEMP[$fcvcount]}" -ge "${AFCMAXTEMP[$fcvcount]}" ]
then then
echo "Error in configuration file (${AFCPWM[$fcvcount]}):" echo "Error in configuration file (${AFCPWM[$fcvcount]}):" >&2
echo "MINTEMP must be less than MAXTEMP" echo "MINTEMP must be less than MAXTEMP" >&2
exit 1 exit 1
fi fi
if [ "${AFCMAXPWM[$fcvcount]}" -gt 255 ] if [ "${AFCMAXPWM[$fcvcount]}" -gt 255 ]
then then
echo "Error in configuration file (${AFCPWM[$fcvcount]}):" echo "Error in configuration file (${AFCPWM[$fcvcount]}):" >&2
echo "MAXPWM must be at most 255" echo "MAXPWM must be at most 255" >&2
exit 1 exit 1
fi fi
if [ "${AFCMINSTOP[$fcvcount]}" -ge "${AFCMAXPWM[$fcvcount]}" ] if [ "${AFCMINSTOP[$fcvcount]}" -ge "${AFCMAXPWM[$fcvcount]}" ]
then then
echo "Error in configuration file (${AFCPWM[$fcvcount]}):" echo "Error in configuration file (${AFCPWM[$fcvcount]}):" >&2
echo "MINSTOP must be less than MAXPWM" echo "MINSTOP must be less than MAXPWM" >&2
exit 1 exit 1
fi fi
if [ "${AFCMINSTOP[$fcvcount]}" -lt "${AFCMINPWM[$fcvcount]}" ] if [ "${AFCMINSTOP[$fcvcount]}" -lt "${AFCMINPWM[$fcvcount]}" ]
then then
echo "Error in configuration file (${AFCPWM[$fcvcount]}):" echo "Error in configuration file (${AFCPWM[$fcvcount]}):" >&2
echo "MINSTOP must be greater than or equal to MINPWM" echo "MINSTOP must be greater than or equal to MINPWM" >&2
exit 1 exit 1
fi fi
if [ "${AFCMINPWM[$fcvcount]}" -lt 0 ] if [ "${AFCMINPWM[$fcvcount]}" -lt 0 ]
then then
echo "Error in configuration file (${AFCPWM[$fcvcount]}):" echo "Error in configuration file (${AFCPWM[$fcvcount]}):" >&2
echo "MINPWM must be at least 0" echo "MINPWM must be at least 0" >&2
exit 1 exit 1
fi fi
@@ -185,7 +185,7 @@ function ValidateDevices()
if [ "`DevicePath "$device"`" != "$path" ] if [ "`DevicePath "$device"`" != "$path" ]
then then
echo "Device path of $device has changed" echo "Device path of $device has changed" >&2
outdated=1 outdated=1
fi fi
done done
@@ -197,7 +197,7 @@ function ValidateDevices()
if [ "`DeviceName "$device"`" != "$name" ] if [ "`DeviceName "$device"`" != "$name" ]
then then
echo "Device name of $device has changed" echo "Device name of $device has changed" >&2
outdated=1 outdated=1
fi fi
done done
@@ -215,7 +215,7 @@ function CheckFiles {
pwmo=${AFCPWM[$fcvcount]} pwmo=${AFCPWM[$fcvcount]}
if [ ! -w $pwmo ] if [ ! -w $pwmo ]
then then
echo "Error: file $pwmo doesn't exist" echo "Error: file $pwmo doesn't exist" >&2
outdated=1 outdated=1
fi fi
let fcvcount=$fcvcount+1 let fcvcount=$fcvcount+1
@@ -227,7 +227,7 @@ function CheckFiles {
tsen=${AFCTEMP[$fcvcount]} tsen=${AFCTEMP[$fcvcount]}
if [ ! -r $tsen ] if [ ! -r $tsen ]
then then
echo "Error: file $tsen doesn't exist" echo "Error: file $tsen doesn't exist" >&2
outdated=1 outdated=1
fi fi
let fcvcount=$fcvcount+1 let fcvcount=$fcvcount+1
@@ -241,7 +241,7 @@ function CheckFiles {
do do
if [ ! -r $fan ] if [ ! -r $fan ]
then then
echo "Error: file $fan doesn't exist" echo "Error: file $fan doesn't exist" >&2
outdated=1 outdated=1
fi fi
done done
@@ -250,10 +250,10 @@ function CheckFiles {
if [ $outdated -eq 1 ] if [ $outdated -eq 1 ]
then then
echo echo >&2
echo "At least one referenced file is missing. Either some required kernel" echo "At least one referenced file is missing. Either some required kernel" >&2
echo "modules haven't been loaded, or your configuration file is outdated." echo "modules haven't been loaded, or your configuration file is outdated." >&2
echo "In the latter case, you should run pwmconfig again." echo "In the latter case, you should run pwmconfig again." >&2
fi fi
return $outdated return $outdated
@@ -277,13 +277,13 @@ elif echo "${AFCPWM[0]}" | egrep -q '^[1-9]*[0-9]-[0-9abcdef]{4}'
then then
DIR=/sys/bus/i2c/devices DIR=/sys/bus/i2c/devices
else else
echo "$0: Invalid path to sensors" echo "$0: Invalid path to sensors" >&2
exit 1 exit 1
fi fi
if [ ! -d $DIR ] if [ ! -d $DIR ]
then then
echo $0: 'No sensors found! (did you load the necessary modules?)' echo $0: 'No sensors found! (did you load the necessary modules?)' >&2
exit 1 exit 1
fi fi
cd $DIR cd $DIR
@@ -291,19 +291,19 @@ cd $DIR
# Check for configuration change # Check for configuration change
if [ -z "$DEVPATH" -o -z "$DEVNAME" ] if [ -z "$DEVPATH" -o -z "$DEVNAME" ]
then then
echo "Configuration is too old, please run pwmconfig again" echo "Configuration is too old, please run pwmconfig again" >&2
exit 1 exit 1
fi fi
if ! ValidateDevices "$DEVPATH" "$DEVNAME" if ! ValidateDevices "$DEVPATH" "$DEVNAME"
then then
echo "Configuration appears to be outdated, please run pwmconfig again" echo "Configuration appears to be outdated, please run pwmconfig again" >&2
exit 1 exit 1
fi fi
CheckFiles || exit 1 CheckFiles || exit 1
if [ -f "$PIDFILE" ] if [ -f "$PIDFILE" ]
then then
echo "File $PIDFILE exists, is fancontrol already running?" echo "File $PIDFILE exists, is fancontrol already running?" >&2
exit 1 exit 1
fi fi
echo $$ > "$PIDFILE" echo $$ > "$PIDFILE"
@@ -416,7 +416,7 @@ function UpdateFanSpeeds {
read one_fanval < ${one_fan} read one_fanval < ${one_fan}
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "Error reading Fan value from $DIR/$one_fan" echo "Error reading Fan value from $DIR/$one_fan" >&2
restorefans 1 restorefans 1
fi fi
@@ -473,7 +473,7 @@ function UpdateFanSpeeds {
echo $pwmval > $pwmo # write new value to pwm output echo $pwmval > $pwmo # write new value to pwm output
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "Error writing PWM value to $DIR/$pwmo" echo "Error writing PWM value to $DIR/$pwmo" >&2
restorefans 1 restorefans 1
fi fi
if [ "$DEBUG" != "" ] if [ "$DEBUG" != "" ]
@@ -492,7 +492,7 @@ do
pwmenable $pwmo pwmenable $pwmo
if [ $? -ne 0 ] if [ $? -ne 0 ]
then then
echo "Error enabling PWM on $DIR/$pwmo" echo "Error enabling PWM on $DIR/$pwmo" >&2
restorefans 1 restorefans 1
fi fi
let fcvcount=$fcvcount+1 let fcvcount=$fcvcount+1