diff --git a/CHANGES b/CHANGES index f3ff016b..43014dc5 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,9 @@ SVN-HEAD Parse the configuration file in C locale Late compute statements override early ones Support virtual hwmon devices (#2309) + pwmconfig: Don't create the configuration file before it's needed + Don't preserve configuration file customizations + Fix permissions of the configuration file sensors-detect: Add SMSC SCH5027D detection Do not access I/O ports on PPC Move south bridge sensor detection to the right section diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig index 5916652a..820c6d20 100755 --- a/prog/pwm/pwmconfig +++ b/prog/pwm/pwmconfig @@ -9,7 +9,7 @@ # Verify that all fans are running at normal speed after this # program has exited!!! # -# Copyright (C) 2007 Jean Delvare +# Copyright (C) 2007-2008 Jean Delvare # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -501,32 +501,34 @@ fi function AskPath { echo -n 'What should be the path to your fancontrol config file (/etc/fancontrol)? ' - read X - if [ "$X" = "y" -o "$X" = "Y" -o "$X" = "" ] + read FCCONFIG + if [ "$FCCONFIG" = "" ] then - X=/etc/fancontrol - fi - if [ -f $X ] - then - FCCONFIG=$X - else - echo -n "$X does not exist, shall I create it now (y)? " - read Y - if [ "$Y" = "y" -o "$Y" = "Y" -o "$Y" = "" ] - then - touch $X - chmod 0660 $X - chown root.root $X - FCCONFIG=$X - else - AskPath - fi + FCCONFIG="/etc/fancontrol" fi } AskPath +function ClearConfig { + FCTEMPS="" + FCFANS="" + MINTEMP="" + MAXTEMP="" + MINSTART="" + MINSTOP="" + MINPWM="" + MAXPWM="" +} + function LoadConfig { + # Nothing to do + if [ ! -f "$1" ] + then + ClearConfig + return 0 + fi + echo "Loading configuration from $1 ..." INTERVAL=`egrep '^INTERVAL=.*$' $1 | sed -e 's/INTERVAL= *//g'` FCTEMPS=`egrep '^FCTEMPS=.*$' $1 | sed -e 's/FCTEMPS= *//g'` @@ -545,14 +547,7 @@ function LoadConfig { if [ ! -f "`echo $item | sed -e 's/=.*$//'`" ] then echo "Configuration appears to be outdated, discarded" - FCTEMPS="" - FCFANS="" - MINTEMP="" - MAXTEMP="" - MINSTART="" - MINSTOP="" - MINPWM="" - MAXPWM="" + ClearConfig return 0 fi done @@ -611,11 +606,12 @@ function SaveConfig { echo "Saving configuration to $FCCONFIG..." tmpfile=`mktemp -t pwmcfg.XXXXXXXXXX` || { echo "$0: Cannot create temporary file" >&2; exit 1; } trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15 - egrep -v '(INTERVAL|FCTEMPS|FCFANS|MAXTEMP|MINTEMP|MINSTART|MINSTOP|MINPWM|MAXPWM)' $FCCONFIG >$tmpfile + echo "# Configuration file generated by pwmconfig, changes will be lost" >$tmpfile echo -e "INTERVAL=$INTERVAL\nFCTEMPS=$FCTEMPS\nFCFANS=$FCFANS\nMINTEMP=$MINTEMP\nMAXTEMP=$MAXTEMP\nMINSTART=$MINSTART\nMINSTOP=$MINSTOP" >>$tmpfile [ -n "$MINPWM" ] && echo "MINPWM=$MINPWM" >>$tmpfile [ -n "$MAXPWM" ] && echo "MAXPWM=$MAXPWM" >>$tmpfile mv $tmpfile $FCCONFIG + chmod +r $FCCONFIG #check if file was written correctly echo 'Configuration saved' }