Changeset 5770
- Timestamp:
- 09/16/09 17:57:53 (4 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 4 modified
-
CHANGES (modified) (1 diff)
-
prog/pwm/fancontrol (modified) (4 diffs)
-
prog/pwm/fancontrol.8 (modified) (3 diffs)
-
prog/pwm/pwmconfig (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/CHANGES
r5769 r5770 5 5 libsensors: Support upcoming sysfs path to i2c adapters 6 6 fancontrol: Check that all referenced sysfs files exist 7 Check that all devices match the configuration file 7 8 pwmconfig: Exit immediately if not root 9 Save device paths and names in configuration file 8 10 sensors.conf.default: Encourage user to not modify this file 9 11 sensors-detect: Refer to tmp401 driver if TMP411 is detected -
lm-sensors/trunk/prog/pwm/fancontrol
r5766 r5770 4 4 # Supported Linux kernel versions: 2.6.5 and later 5 5 # 6 # Version 0. 696 # Version 0.70 7 7 # 8 8 # Usage: fancontrol [CONFIGFILE] 9 9 # 10 10 # Dependencies: 11 # bash, egrep, sed, cut, sleep, lm_sensors :)11 # bash, egrep, sed, cut, sleep, readlink, lm_sensors :) 12 12 # 13 13 # Please send any questions, comments or success stories to … … 56 56 # grep configuration from file 57 57 INTERVAL=`egrep '^INTERVAL=.*$' $1 | sed -e 's/INTERVAL=//g'` 58 DEVPATH=`egrep '^DEVPATH=.*$' $1 | sed -e 's/DEVPATH= *//g'` 59 DEVNAME=`egrep '^DEVNAME=.*$' $1 | sed -e 's/DEVNAME= *//g'` 58 60 FCTEMPS=`egrep '^FCTEMPS=.*$' $1 | sed -e 's/FCTEMPS=//g'` 59 61 MINTEMP=`egrep '^MINTEMP=.*$' $1 | sed -e 's/MINTEMP=//g'` … … 153 155 } 154 156 157 function DevicePath() 158 { 159 if [ -h "$1/device" ] 160 then 161 readlink -f "$1/device" | sed -e 's/^\/sys\///' 162 fi 163 } 164 165 function DeviceName() 166 { 167 if [ -r "$1/name" ] 168 then 169 cat "$1/name" | sed -e 's/[[:space:]=]/_/g' 170 elif [ -r "$1/device/name" ] 171 then 172 cat "$1/device/name" | sed -e 's/[[:space:]=]/_/g' 173 fi 174 } 175 176 function ValidateDevices() 177 { 178 local OLD_DEVPATH="$1" OLD_DEVNAME="$2" outdated=0 179 local entry device name path 180 181 for entry in $OLD_DEVPATH 182 do 183 device=`echo "$entry" | sed -e 's/=[^=]*$//'` 184 path=`echo "$entry" | sed -e 's/^[^=]*=//'` 185 186 if [ "`DevicePath "$device"`" != "$path" ] 187 then 188 echo "Device path of $device has changed" 189 outdated=1 190 fi 191 done 192 193 for entry in $OLD_DEVNAME 194 do 195 device=`echo "$entry" | sed -e 's/=[^=]*$//'` 196 name=`echo "$entry" | sed -e 's/^[^=]*=//'` 197 198 if [ "`DeviceName "$device"`" != "$name" ] 199 then 200 echo "Device name of $device has changed" 201 outdated=1 202 fi 203 done 204 205 return $outdated 206 } 207 155 208 # Check that all referenced sysfs files exist 156 209 function CheckFiles { … … 233 286 cd $DIR 234 287 288 # Check for configuration change 289 if [ -z "$DEVPATH" -o -z "$DEVNAME" ] 290 then 291 echo "Configuration is too old, please run pwmconfig again" 292 exit 1 293 fi 294 if ! ValidateDevices "$DEVPATH" "$DEVNAME" 295 then 296 echo "Configuration appears to be outdated, please run pwmconfig again" 297 exit 1 298 fi 235 299 CheckFiles || exit 1 236 300 -
lm-sensors/trunk/prog/pwm/fancontrol.8
r5765 r5770 39 39 \fBfancontrol\fP will be executed 40 40 .TP 41 .B DEVPATH 42 Maps hwmon class devices to physical devices. This lets \fBfancontrol\fP 43 check that the configuration file is still up-to-date. 44 .TP 45 .B DEVNAME 46 Records hwmon class device names. This lets \fBfancontrol\fP check that 47 the configuration file is still up-to-date. 48 .TP 41 49 .B FCTEMPS 42 50 Maps PWM outputs to temperature sensors so \fBfancontrol\fP knows which … … 45 53 .TP 46 54 .B FCFANS 47 FCFANS records the association between a PWM and a fan.55 Records the association between a PWM output and a fan input. 48 56 Then \fBfancontrol\fP can check the fan speed and restart it if it 49 57 stops unexpectedly. … … 93 101 editing the config file directly following the rules above. 94 102 95 Upon starting, fancontrol will make sure that all referenced sysfs files 96 do exist. If not, it will quit immediately, upon the assumption that the 97 configuration file may be out-of-sync with the loaded kernel drivers. 103 Upon starting, fancontrol will make sure that all referenced devices 104 do exist and match what they were at configuration time, and that all 105 referenced sysfs files do exist. If not, it will quit immediately, upon 106 the assumption that the configuration file may be out-of-sync with the 107 loaded kernel drivers. 98 108 99 109 .SH THE ALGORITHM -
lm-sensors/trunk/prog/pwm/pwmconfig
r5767 r5770 540 540 fi 541 541 542 function DevicePath() 543 { 544 if [ -h "$1/device" ] 545 then 546 readlink -f "$1/device" | sed -e 's/^\/sys\///' 547 fi 548 } 549 550 function DeviceName() 551 { 552 if [ -r "$1/name" ] 553 then 554 cat "$1/name" | sed -e 's/[[:space:]=]/_/g' 555 elif [ -r "$1/device/name" ] 556 then 557 cat "$1/device/name" | sed -e 's/[[:space:]=]/_/g' 558 fi 559 } 560 561 function ValidateDevices() 562 { 563 local OLD_DEVPATH="$1" OLD_DEVNAME="$2" outdated=0 564 local entry device name path 565 566 for entry in $OLD_DEVPATH 567 do 568 device=`echo "$entry" | sed -e 's/=[^=]*$//'` 569 path=`echo "$entry" | sed -e 's/^[^=]*=//'` 570 571 if [ "`DevicePath "$device"`" != "$path" ] 572 then 573 echo "Device path of $device has changed" 574 outdated=1 575 fi 576 done 577 578 for entry in $OLD_DEVNAME 579 do 580 device=`echo "$entry" | sed -e 's/=[^=]*$//'` 581 name=`echo "$entry" | sed -e 's/^[^=]*=//'` 582 583 if [ "`DeviceName "$device"`" != "$name" ] 584 then 585 echo "Device name of $device has changed" 586 outdated=1 587 fi 588 done 589 590 return $outdated 591 } 592 542 593 function AskPath() 543 594 { … … 567 618 function LoadConfig() 568 619 { 620 local OLD_DEVPATH OLD_DEVNAME 621 569 622 # Nothing to do 570 623 if [ ! -f "$1" ] … … 576 629 echo "Loading configuration from $1 ..." 577 630 INTERVAL=`egrep '^INTERVAL=.*$' $1 | sed -e 's/INTERVAL= *//g'` 631 OLD_DEVPATH=`egrep '^DEVPATH=.*$' $1 | sed -e 's/DEVPATH= *//g'` 632 OLD_DEVNAME=`egrep '^DEVNAME=.*$' $1 | sed -e 's/DEVNAME= *//g'` 578 633 FCTEMPS=`egrep '^FCTEMPS=.*$' $1 | sed -e 's/FCTEMPS= *//g'` 579 634 FCFANS=`egrep '^FCFANS=.*$' $1 | sed -e 's/FCFANS= *//g'` … … 586 641 587 642 # Check for configuration change 588 local item 589 for item in $FCFANS 590 do 591 if [ ! -f "`echo $item | sed -e 's/=.*$//'`" ] 592 then 593 echo "Configuration appears to be outdated, discarded" 594 ClearConfig 595 return 0 596 fi 597 done 643 if ! ValidateDevices "$OLD_DEVPATH" "$OLD_DEVNAME" 644 then 645 echo "Configuration appears to be outdated, discarded" 646 ClearConfig 647 return 0 648 fi 598 649 } 599 650 … … 676 727 } 677 728 729 # Remember the path and name of each device with at least one 730 # reference (pwm, temp or fan) in the configuration file. 731 # This function sets globals DEVPATH and DEVNAME as a side effect. 732 function RememberDevices() 733 { 734 local used entry device name path tempfandev pwmdev 735 DEVPATH="" 736 DEVNAME="" 737 738 for device in $DEVICES 739 do 740 device=`echo "$device" | sed -e 's/\/.*$//'` 741 742 used=0 743 for entry in $1 $2 744 do 745 pwmdev=`echo "$entry" | sed -e 's/\/.*$//'` 746 tempfandev=`echo "$entry" | sed -e 's/^[^=]*=//' -e 's/\/.*$//'` 747 748 if [ "$device" = "$pwmdev" -o "$device" = "$tempfandev" ] 749 then 750 used=1 751 fi 752 done 753 if [ "$used" -eq 0 ] 754 then 755 continue 756 fi 757 758 # Record the device path and name. This lets the fancontrol 759 # script check that they didn't change. If they did, then the 760 # configuration file can no longer be trusted. 761 path=`DevicePath "$device"` 762 if [ -z "$DEVPATH" ] 763 then 764 DEVPATH="$device=$path" 765 else 766 DEVPATH="$DEVPATH $device=$path" 767 fi 768 769 name=`DeviceName "$device"` 770 if [ -z "$DEVNAME" ] 771 then 772 DEVNAME="$device=$name" 773 else 774 DEVNAME="$DEVNAME $device=$name" 775 fi 776 done 777 } 778 678 779 function SaveConfig() 679 780 { 781 RememberDevices "$FCTEMPS" "$FCFANS" 782 680 783 echo 681 784 echo "Saving configuration to $FCCONFIG..." … … 684 787 echo "# Configuration file generated by pwmconfig, changes will be lost" >$tmpfile 685 788 echo "INTERVAL=$INTERVAL" >>$tmpfile 789 echo "DEVPATH=$DEVPATH" >>$tmpfile 790 echo "DEVNAME=$DEVNAME" >>$tmpfile 686 791 echo "FCTEMPS=$FCTEMPS" >>$tmpfile 687 792 echo "FCFANS=$FCFANS" >>$tmpfile
