- Some improvements to the lsb-retcodes and service-default-off patches

from a review by upstream
This commit is contained in:
Hans de Goede 2008-02-26 14:09:27 +00:00
parent a3f3fddc23
commit 4bd3dbf08e
5 changed files with 159 additions and 63 deletions

View File

@ -1,30 +0,0 @@
diff -up lm_sensors-3.0.1/prog/detect/sensors-detect.foo lm_sensors-3.0.1/prog/detect/sensors-detect
--- lm_sensors-3.0.1/prog/detect/sensors-detect.foo 2008-01-22 13:22:47.000000000 +0100
+++ lm_sensors-3.0.1/prog/detect/sensors-detect 2008-02-11 13:42:04.000000000 +0100
@@ -5943,6 +5943,15 @@ EOT
if (-x "/sbin/insserv" && -f "/etc/init.d/lm_sensors") {
system("/sbin/insserv", "/etc/init.d/lm_sensors");
+ } elsif (-x "/sbin/chkconfig" && -f "/etc/init.d/lm_sensors") {
+ system("/sbin/chkconfig", "lm_sensors", "on");
+ if (-x "/sbin/service") {
+ if (-f "/var/lock/subsys/lm_sensors") {
+ system("/sbin/service", "lm_sensors", "restart");
+ } else {
+ system("/sbin/service", "lm_sensors", "start");
+ }
+ }
} else {
print "You should now start the lm_sensors service to load the required\n".
"kernel modules.\n\n";
diff -up lm_sensors-3.0.1/prog/init/lm_sensors.init.foo lm_sensors-3.0.1/prog/init/lm_sensors.init
--- lm_sensors-3.0.1/prog/init/lm_sensors.init.foo 2007-04-27 14:34:17.000000000 +0200
+++ lm_sensors-3.0.1/prog/init/lm_sensors.init 2008-02-11 13:08:58.000000000 +0100
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# chkconfig: 2345 26 74
+# chkconfig: - 26 74
# description: sensors is used for monitoring motherboard sensor values.
# config: /etc/sysconfig/lm_sensors
#

View File

@ -1,30 +0,0 @@
--- lm_sensors/prog/init/lm_sensors.init 2008-02-07 11:37:22.000000000 -0500
+++ lm_sensors/prog/init/lm_sensors.init 2008-02-07 11:41:04.000000000 -0500
@@ -40,15 +40,15 @@
# Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
# support for sensors.
- [ -e /proc/sys/dev/sensors ] || exit 0
+ [ -e /proc/sys/dev/sensors ] || exit 6
# If sensors was not already running, unload the module...
[ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc >/dev/null 2>&1
fi
CONFIG=/etc/sysconfig/lm_sensors
-[ -r "$CONFIG" ] || exit 0
-grep '^MODULE_' $CONFIG >/dev/null 2>&1 || exit 0
+[ -r "$CONFIG" ] || exit 6
+grep '^MODULE_' $CONFIG >/dev/null 2>&1 || exit 6
# Load config file
. "$CONFIG"
@@ -147,7 +147,7 @@
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|condrestart}"
- exit 1
+ exit 3
esac
exit $RETVAL

View File

@ -0,0 +1,116 @@
--- lm_sensors-3.0.1/prog/init/lm_sensors.init 2008-02-26 14:37:51.000000000 +0100
+++ lm_sensors-3.0.1.new/prog/init/lm_sensors.init 2008-02-26 14:25:13.000000000 +0100
@@ -28,31 +28,6 @@
# in order as normal shell variables with the special names:
# MODULE_1, MODULE_2, MODULE_3, etc.
-if grep -q sysfs /proc/mounts; then
- WITHSYS=1
-else
- WITHSYS=0
-fi
-
-if [ $WITHSYS == "0" ]; then
- # If sensors isn't supported by the kernel, try loading the module...
- [ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc >/dev/null 2>&1
-
- # 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/lm_sensors ] || /sbin/modprobe -r i2c-proc >/dev/null 2>&1
-fi
-
-CONFIG=/etc/sysconfig/lm_sensors
-[ -r "$CONFIG" ] || exit 0
-grep '^MODULE_' $CONFIG >/dev/null 2>&1 || exit 0
-
-# Load config file
-. "$CONFIG"
-
PSENSORS=/usr/local/bin/sensors
if [ ! -x $PSENSORS ]; then
@@ -65,7 +40,47 @@
RETVAL=0
prog="lm_sensors"
+# This functions checks if sensor support is compiled into the kernel, if
+# sensors are configured, and loads the config file
+check_sensors() {
+ if grep -q sysfs /proc/mounts; then
+ WITHSYS=1
+ else
+ WITHSYS=0
+ fi
+
+ if [ $WITHSYS == "0" ]; then
+ # If sensors isn't supported by the kernel, try loading the module...
+ [ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc >/dev/null 2>&1
+
+ # Don't bother if /proc/sensors still doesn't exist, kernel doesn't have
+ # support for sensors.
+ if ! [ -e /proc/sys/dev/sensors ]; then
+ echo -n "Starting $prog: kernel does not have sensors support"
+ echo_failure
+ echo
+ exit 5
+ fi
+
+ # If sensors was not already running, unload the module...
+ [ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc >/dev/null 2>&1
+ fi
+
+ CONFIG=/etc/sysconfig/lm_sensors
+ if ! [ -r "$CONFIG" ] || ! grep '^MODULE_' $CONFIG >/dev/null 2>&1; then
+ echo -n "Starting $prog: not configured, run sensors-detect"
+ echo_warning
+ echo
+ exit 6
+ fi
+
+ # Load config file
+ . "$CONFIG"
+}
+
start() {
+ check_sensors
+
echo -n "Starting $prog: loading module "
modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
@@ -89,6 +104,8 @@
}
stop() {
+ check_sensors
+
echo -n "Stopping $prog: "
modules=`grep \^MODULE_ $CONFIG | wc -l | tr -d ' '`
@@ -116,12 +133,14 @@
dostatus() {
$PSENSORS
RETVAL=$?
+ if [ $RETVAL -ne 0 ]; then
+ RETVAL=3
+ fi
}
restart() {
stop
start
- RETVAL=$?
}
condrestart() {
@@ -147,7 +166,7 @@
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|condrestart}"
- exit 1
+ exit 3
esac
exit $RETVAL

View File

@ -0,0 +1,36 @@
--- lm_sensors-3.0.1/prog/init/lm_sensors.init.default-off 2007-04-27 14:34:17.000000000 +0200
+++ lm_sensors-3.0.1/prog/init/lm_sensors.init 2008-02-26 14:55:58.000000000 +0100
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# chkconfig: 2345 26 74
+# chkconfig: - 26 74
# description: sensors is used for monitoring motherboard sensor values.
# config: /etc/sysconfig/lm_sensors
#
--- lm_sensors-3.0.1/prog/detect/sensors-detect.default-off 2008-01-22 13:22:47.000000000 +0100
+++ lm_sensors-3.0.1/prog/detect/sensors-detect 2008-02-26 15:00:07.000000000 +0100
@@ -5673,6 +5673,11 @@ sub main
exit -1;
}
+ if (-x "/sbin/service" && -f "/etc/init.d/lm_sensors" &&
+ -f "/var/lock/subsys/lm_sensors") {
+ system("/sbin/service", "lm_sensors", "stop");
+ }
+
initialize_kernel_version();
initialize_conf;
initialize_proc_pci;
@@ -5943,6 +5948,11 @@ EOT
if (-x "/sbin/insserv" && -f "/etc/init.d/lm_sensors") {
system("/sbin/insserv", "/etc/init.d/lm_sensors");
+ } elsif (-x "/sbin/chkconfig" && -f "/etc/init.d/lm_sensors") {
+ system("/sbin/chkconfig", "lm_sensors", "on");
+ if (-x "/sbin/service") {
+ system("/sbin/service", "lm_sensors", "start");
+ }
} else {
print "You should now start the lm_sensors service to load the required\n".
"kernel modules.\n\n";

View File

@ -1,14 +1,14 @@
Name: lm_sensors
Version: 3.0.1
Release: 2%{?dist}
Release: 3%{?dist}
URL: http://www.lm-sensors.org/
Source: http://dl.lm-sensors.org/lm-sensors/releases/%{name}-%{version}.tar.bz2
Source1: lm_sensors.sysconfig
# these 2 were taken from PLD-linux, Thanks!
Source2: sensord.sysconfig
Source3: sensord.init
Patch0: lm_sensors-2.10.4-service-default-off.patch
Patch1: lm_sensors-3.0.0-lsb-retcode.patch
Patch0: lm_sensors-3.0.1-service-default-off.patch
Patch1: lm_sensors-3.0.1-lsb-retcodes.patch
Patch2: lm_sensors-3.0.1-sensors-detect-special-chips.patch
Summary: Hardware monitoring tools
Group: Applications/System
@ -167,6 +167,10 @@ fi
%changelog
* Tue Feb 26 2008 Hans de Goede <j.w.r.degoede@hhs.nl> 3.0.1-3
- Some improvements to the lsb-retcodes and service-default-off patches
from a review by upstream
* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 3.0.1-2
- Autorebuild for GCC 4.3