Bug 128397 - init script won't work
init script won't work
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: lm_sensors (Show other bugs)
2
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Phil Knirsch
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2004-07-22 11:40 EDT by Mark Lucia
Modified: 2015-03-04 20:14 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-10-18 12:06:00 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mark Lucia 2004-07-22 11:40:31 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040510

Description of problem:
The lm_sensors init script, as written cannot work. With the exception
of checking the /proc fs for /proc/sys/dev/sensors (which isn't there
in 2.6) this script works.

#!/bin/sh
#
# chkconfig: 2345 26 74
# description: sensors is used for monitoring motherboard sensor values.
# config: /etc/sysconfig/sensors
#
#    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

# It uses a config file /etc/sysconfig/sensors that contains the
modules to
# be loaded/unloaded. That file is sourced into this one.

# The format of that file a shell script that simply defines the modules 
# in order as normal shell variables with the special names:
#    MODULE_1, MODULE_2, MODULE_3, etc.

# If sensors isn't supported by the kernel, try loading the module...
[ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c_sensor &>/dev/null

# Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
# support for sensors.
#[ -e /proc/sys/dev/sensors ] || exit 0

# If sensors was not already running, unload the module...
#[ -e /var/lock/subsys/sensors ] || /sbin/modprobe -r i2c-proc &>/dev/null

CONFIG=/etc/sysconfig/lm_sensors
PSENSORS=/usr/bin/sensors

# Source function library.
. /etc/init.d/functions

RETVAL=0

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

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

	RETVAL=$?
	if [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sensors ; then
		echo_success
		echo
	else
		echo_failure
		echo
	fi
}

stop() {
	echo -n $"Shutting down sensors: "
	test -r "$CONFIG" && . "$CONFIG"

        modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
        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_sensor &>/dev/null

	RETVAL=$?
	if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sensors ; then
		echo_success
		echo
	else
		echo_failure
		echo
	fi
}

dostatus() {
        $PSENSORS
	RETVAL=$?
}

restart() {
	stop
	start
	RETVAL=$?
}

condrestart() {
	[ -e /var/lock/subsys/sensors ] && restart || :
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	dostatus
	;;
  restart|reload)
	restart
	;;
  condrestart)
	condrestart
	;;
  *)
	echo "Usage: sensors.init {start|stop|status|restart|reload|condrestart}"
	exit 1
esac

exit $RETVAL


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. /etc/rc.d/init.s/lm_sensors
2.
3.
    

Additional info:

Someone needs to fix the couple of lines I commected out, or give me a
clue where sensors now lives in /proc
Comment 1 Phil Knirsch 2004-10-18 12:06:00 EDT
Has been fixed in latest versions of lm_sensors.

Read ya, Phil

Note You need to log in before you can comment on or make changes to this bug.