Skip to contentSkip to conversation

prog/init/lm_sensors.init

DISCUSSION Sebastian Mika 2 participants 3 messages May 19, 2005

lore
Share & tools
lore
#0 lore raw

Hi,

probably I am not the first to note, but this script contained some bugs in the start and stop functions (version lm_sensors-2.6.4)

start: The increment in the loop happend after the loading, i.e. first we try to load MODULE_0. But these variables start with MODULE_1

stop: At least on my debian system the line
"modules=grep \^MODULE_ $CONFIG | wc -l"
evaluates to " 4" (a space before 4).

Regards,
Sebastian Mika

start() {
	echo -n $"Starting up sensors: "
	test -r "$CONFIG" && . "$CONFIG"

        modules=`grep \^MODULE_ $CONFIG | wc -l`
        i=0
        while [ $i -lt $modules ] ; do
	    i=`expr $i + 1`
	    module=`eval echo '$'MODULE_$i`
	    /sbin/modprobe $module &>/dev/null
	done

	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/sensors
	echo
}
stop() {
	echo -n $"Shutting down sensors: "
	test -r "$CONFIG" && . "$CONFIG"

        modules=`grep \^MODULE_ $CONFIG | wc -l`
        i=`expr $modules`
        while [ $i -ge 0 ] ; do
                module=`eval echo '$'MODULE_$i`
      		/sbin/modprobe -r $module &>/dev/null
		i=`expr $i - 1`
	done
	/sbin/modprobe -r i2c-proc &>/dev/null

	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/sensors
	echo
}
Signature · 4 lines
Sebastian Mika             http://www.first.fraunhofer.de/~mika/
Fraunhofer - First
Kekulestr. 7                                      Tel: +49 (30) 6392 1906
12489 Berlin, Germany                   Fax: +49 (30) 6392 1805
#1 lore raw

Hi,

as requested by Albert Cranford, please find attached the outputs of lm_sensors.init {start|stop} and also the automagically generated /etc/sysconfig/lm_sensors.

The suspicious line is 22 in res_start.out (since the numbering in the sysconfig file starts with 1 - see the trivial fix below) and line 19-22 in res_stop.out (also a trivial fix below).

Sorry that I forgot to mention that the code pieces appended in my first mail were ment to contain a fix for both problems.

Regards,
Sebastian Mika.

Quoted 63 lines · you

Try putting a set -x right after the #!/bin/sh line then
send the result output to a file. Send the file to the list for analysis. Ex:
prog/init/lm_sensors.init 2>&1|tee res.out

Albert

Quoted 55 lines · Sebastian Mika

Hi,

probably I am not the first to note, but this script contained some bugs in the start and stop functions (version lm_sensors-2.6.4)

start: The increment in the loop happend after the loading, i.e. first we try to load MODULE_0. But these variables start with MODULE_1

stop: At least on my debian system the line
"modules=grep \^MODULE_ $CONFIG | wc -l"
evaluates to " 4" (a space before 4).

Regards,
Sebastian Mika

start() {
        echo -n $"Starting up sensors: "
        test -r "$CONFIG" && . "$CONFIG"

        modules=`grep \^MODULE_ $CONFIG | wc -l`
        i=0
        while [ $i -lt $modules ] ; do
            i=`expr $i + 1`
            module=`eval echo '$'MODULE_$i`
            /sbin/modprobe $module &>/dev/null
        done

        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/sensors
        echo
}
stop() {
        echo -n $"Shutting down sensors: "
        test -r "$CONFIG" && . "$CONFIG"

        modules=`grep \^MODULE_ $CONFIG | wc -l`
        i=`expr $modules`
        while [ $i -ge 0 ] ; do
                module=`eval echo '$'MODULE_$i`
                /sbin/modprobe -r $module &>/dev/null
                i=`expr $i - 1`
        done
        /sbin/modprobe -r i2c-proc &>/dev/null

        RETVAL=$?
        [ $RETVAL -eq 0 ] && rm -f /var/lock/sensors
        echo
}

--
Sebastian Mika http://www.first.fraunhofer.de/~mika/
Fraunhofer - First
Kekulestr. 7 Tel: +49 (30) 6392 1906
12489 Berlin, Germany Fax: +49 (30) 6392 1805

Signature · 4 lines
Sebastian Mika             http://www.first.fraunhofer.de/~mika/
Fraunhofer - First
Kekulestr. 7                                      Tel: +49 (30) 6392 1906
12489 Berlin, Germany                   Fax: +49 (30) 6392 1805
#2 lore raw
In reply to Sebastian Mika

Well, and now I forgot to append the files. Here they are.

Quoted 4 lines · you

Try putting a set -x right after the #!/bin/sh line then
send the result output to a file. Send the file to the list for analysis. Ex:
prog/init/lm_sensors.init 2>&1|tee res.out

Signature · 55 lines
Sebastian Mika             http://www.first.fraunhofer.de/~mika/
Fraunhofer - First
Kekulestr. 7                                      Tel: +49 (30) 6392 1906
12489 Berlin, Germany                   Fax: +49 (30) 6392 1805

-------------- next part --------------
A non-text attachment was scrubbed...
Name: res_start.out
Type: text/x-diff
Size: 1161 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20020827/ba55863b/res_start.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: res_stop.out
Type: text/x-diff
Size: 1225 bytes
Desc: not available
Url : http://lists.lm-sensors.org/pipermail/lm-sensors/attachments/20020827/ba55863b/res_stop.bin
-------------- next part --------------
#    /etc/sysconfig/sensors - Defines modules loaded by /etc/rc.d/init.d/lm_sensors
#    Copyright (c) 1998 - 2001  Frodo Looijaard <[email protected]>
#
#    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
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# See also the lm_sensors homepage at:
#     http://www2.lm-sensors.nu/~lm78/index.html
#
# This file is used by /etc/rc.d/init.d/lm_sensors and defines the modules to
# be loaded/unloaded. This file is sourced into /etc/rc.d/init.d/lm_sensors.
#
# The format of this file is a shell script that simply defines the modules
# in order as normal variables with the special names:
#    MODULE_1, MODULE_2, MODULE_3, etc.
#
# List the modules that are to be loaded for your system
#
# Generated by sensors-detect on Mon Aug 26 16:38:36 2002
MODULE_1=i2c-piix4
MODULE_2=i2c-isa
MODULE_3=w83781d
MODULE_4îprom