prog/init/lm_sensors.init: reduce verbosity, MAKEDEV, usage
PATCH 1/1 prog/init/lm_sensors.init: reduce verbosity, MAKEDEV, usage
Skipped content of type multipart/mixed-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20041207/65d50703/attachment.bin
PATCH 1/1 prog/init/lm_sensors.init: reduce verbosity, MAKEDEV,
This patch has me thinking...
What do people think about changing the format of the sysconfig/lm_sensors config file from
MODULE_0=i2c-i801
MODULE_1=i2c-isa
MODULE_2=lm85
MODULE_3îprom
MODULE_4=w83781d
to
BUSES="i2c-i801 i2c-isa"
MODULES="lm85 eeprom w83781d"
If we did this, then we could get rid of the confusing and obscure backticks and eval in the module loading loop, replacing it with something simple like:
for module in $MODULES ; do
echo -n __$module__
modprobe $moduledone
Which seems much clearer to me.
This would also mean that users would no longer have to edit variable names to keep them sequential when adding, removing or re-ordering modules.
If I hear agreement, I'll work up a patch. We'll need to modify sensors-detect to generate the new format.
:v)
Quoted 79 lines · Axel Thimm
Hi,
the attached patch is partly including some patching by Red Hat, which are distribution independent.
It exits early on absence of config files, or empty config files (no MODULE_* entries) to avoid noise at startup of
lm_sensorsunconfigured systems.There is also a MAKEDEV in the start command. This may be required for proper udev operation.
It also fixes a couple of minor other things like to output of the usage ($0 instead of fixed "sensors.init" etc).
------------------------------------------------------------------------
Index: prog/init/lm_sensors.init
=================================>RCS file:/home/cvs/lm_sensors2/prog/init/lm_sensors.init,vretrieving revision 1.6
diff -u -d -r1.6 lm_sensors.initinit/lm_sensors.init +0
-0@@ -47,6 +47,12 @@fi
CONFIG=/etc/sysconfig/lm_sensors
+[ -r "$CONFIG" ] || exit 0init/lm_sensors.init +5
-0+egrep '^MODULE_' $CONFIG &>/dev/null || exit 0 + +# Load config file +. "$CONFIG" +PSENSORS=/usr/local/bin/sensors
if [ ! -x $PSENSORS ]; then
init/lm_sensors.init +0
-0@@ -57,16 +63,17 @@.
/etc/init.d/functionsRETVAL=0
+prog="lm_sensors"
start(){init/lm_sensors.init +2
-2- echo -n $"Starting up sensors: " - test -r "$CONFIG" && . "$CONFIG" + echo -n $"Starting $prog: starting module " + /sbin/MAKEDEV i2cmodules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '` i=0 while [ $i -lt $modules ] ; do module=`eval echo '$'MODULE_$i`init/lm_sensors.init +1
-1- echo starting module __${module}__ + echo -n "__${module}__ "/sbin/modprobe $module &>/dev/null i=`expr $i + 1` doneinit/lm_sensors.init +2
-3@@ -83,8 +90,7 @@ } stop() { - echo -n $"Shutting down sensors: " - test -r "$CONFIG" && . "$CONFIG" + echo -n $"Stopping $prog: " modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '` i=`expr $modules`@@ -141,7 +147,7 @@ condrestart ;; *) - echo "Usage: sensors.init {start|stop|status|restart|reload|condrestart}" + echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" exit 1esac
Signature · 4 lines
Philip Pokorny, Director of Engineering Tel: 415-954-2823 Fax: 415-954-2899 Toll Free: 888-PENGUIN PENGUIN COMPUTING, INC. www.penguincomputing.com
PATCH 1/1 prog/init/lm_sensors.init: reduce verbosity, MAKEDEV,
In reply to Axel ThimmHi Philip,
Quoted 11 lines
This patch has me thinking...
What do people think about changing the format of the sysconfig/lm_sensors config file from
MODULE_0=i2c-i801
MODULE_1=i2c-isa
MODULE_2=lm85
MODULE_3îprom
MODULE_4=w83781d
Quoted 4 lines
to
BUSES="i2c-i801 i2c-isa"
MODULES="lm85 eeprom w83781d"
The names you pick are confusing. Bus drivers are modules too. BUSES and CHIPS would be better.
Quoted 10 lines
If we did this, then we could get rid of the confusing and obscure backticks and eval in the module loading loop, replacing it with something simple like:
for module in $MODULES ; do
echo -n __$module__ modprobe $moduledone
Which seems much clearer to me.
Agreed. However, I wonder why things were done that way in the first place. Were we following some Red Hat standard? I have no Red Hat-like system to verify that. If there is no standard to follow, any code simplification is welcome.
Thanks,
PATCH 1/1 prog/init/lm_sensors.init: reduce verbosity, MAKEDEV,
In reply to Axel ThimmHi Axel,
Quoted 6 lines
the attached patch is partly including some patching by Red Hat, which are distribution independent.
It exits early on absence of config files, or empty config files (no MODULE_* entries) to avoid noise at startup of
lm_sensorsunconfigured systems.
Sounds sane to me.
Quoted 2 lines
There is also a MAKEDEV in the start command. This may be required for proper udev operation.
Doesn't sound good to me. For one thing not all systems may have /sbin/MAKEDEV, for another what is fine for udev might not be fine for devfs or static /dev systems. Also, I thought that udev was totally dynamic so I don't understand why we would have to create the device files. Last, /dev/i2c* files are not needed for proper operation of the hardware monitoring modules, only for sensors-detect and dump tools.
Quoted 2 lines
It also fixes a couple of minor other things like to output of the usage ($0 instead of fixed "sensors.init" etc).
Sounds fine.
More comments inline:
CONFIG=/etc/sysconfig/lm_sensors
+[ -r "$CONFIG" ] || exit 0
+egrep '^MODULE_' $CONFIG &>/dev/null || exit 0
Why egrep and not simply grep? I'd also suggest -q instead of &>/dev/null. BTW, what's the difference between ">" and "&>"? The latter is not documented in my sh man page (">&" is).
- echo -n $"Starting up sensors: "
- test -r "$CONFIG" && . "$CONFIG"
+ echo -n $"Starting $prog: starting module "
What is the leading $ for, BTW?
From a technical point of view, we are not starting modules, but loading them.
- echo starting module __${module}__
+ echo -n "__${module}__ "
Do we need these extra underscores at all? Looks ugly IMHO.
Thanks,
--
Jean Delvare