517 lines
16 KiB
Plaintext
517 lines
16 KiB
Plaintext
--- Makefile
|
||
+++ Makefile 2007-08-01 00:00:00.000000000 +0200
|
||
@@ -45,8 +45,8 @@ LINUX_HEADERS := $(LINUX)/include
|
||
# may be used mistakenly. Note: This should point to the directory
|
||
# *above* the linux/ subdirectory, so to /usr/local/include in the
|
||
# above example.
|
||
-I2C_HEADERS := /usr/local/include
|
||
-#I2C_HEADERS := $(LINUX_HEADERS)
|
||
+#I2C_HEADERS := /usr/local/include
|
||
+I2C_HEADERS := $(LINUX_HEADERS)
|
||
|
||
ifneq ($(MAKECMDGOALS),user)
|
||
ifneq ($(MAKECMDGOALS),user_install)
|
||
@@ -75,7 +75,7 @@ DEBUG := 0
|
||
DESTDIR :=
|
||
|
||
# This is the prefix that will be used for almost all directories below.
|
||
-PREFIX := /usr/local
|
||
+PREFIX := /usr
|
||
|
||
# Your C compiler
|
||
CC := gcc
|
||
@@ -97,7 +97,7 @@ ifeq (,$(findstring /2.4., $(MODPREF)))
|
||
else
|
||
SYSFS_SUPPORT :=
|
||
endif
|
||
-#SYSFS_SUPPORT := 1
|
||
+SYSFS_SUPPORT := 1
|
||
|
||
# Prevent 2.6+ users from using improper targets, as this won't work.
|
||
ifeq (,$(findstring /2.4., $(MODPREF)))
|
||
@@ -141,7 +141,7 @@ LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
|
||
|
||
# You should not need to change this. It is the base directory under which the
|
||
# manual pages will be installed.
|
||
-MANDIR := $(PREFIX)/man
|
||
+MANDIR := $(PREFIX)/share/man
|
||
|
||
MACHINE := $(shell uname -m)
|
||
|
||
@@ -216,7 +216,7 @@ ifeq ($(DEBUG),1)
|
||
ALL_CPPFLAGS += -DDEBUG
|
||
ALL_CFLAGS += -O -g
|
||
else
|
||
-ALL_CFLAGS += -O2
|
||
+ALL_CFLAGS += $(RPM_OPT_FLAGS)
|
||
endif
|
||
|
||
ifeq ($(WARN),1)
|
||
--- prog/detect/sensors-detect
|
||
+++ prog/detect/sensors-detect 2007-08-01 15:19:55.706591921 +0200
|
||
@@ -5416,7 +5416,7 @@ sub generate_modprobes
|
||
$modprobes .= "# I2C adapter drivers\n" if $nr;
|
||
for ($i = 0; $i < $nr; $i++) {
|
||
foreach $adap (@i2c_adapters) {
|
||
- next unless exists $adap->{nr_later} and $adap->{nr_later} == $i;
|
||
+ next unless exists $adap->{driver} and $adap->{nr_later} == $i;
|
||
if ($adap->{driver} eq "UNKNOWN") {
|
||
$modprobes .= "# modprobe unknown adapter ".$adap->{name}."\n";
|
||
} elsif ($adap->{driver} eq "DISABLED") {
|
||
@@ -5448,6 +5448,19 @@ sub generate_modprobes
|
||
next if not @{$chip->{detected}};
|
||
if ($chip->{driver} eq "to-be-written") {
|
||
$modprobes .= "# no driver for $chip->{detected}[0]{chipname} yet\n";
|
||
+ } elsif ($chip->{driver} eq "w83627hf") {
|
||
+ my $check = 0;
|
||
+ open MODPROBE, "modprobe -l w83627hf|" or die "can not execute modprobe\n";
|
||
+ while (<MODPROBE>) {
|
||
+ $check = /^.*w83627hf.*$/;
|
||
+ }
|
||
+ close MODPROBE;
|
||
+ if ($check) {
|
||
+ $modprobes .= "modprobe $chip->{driver}\n";
|
||
+ } else {
|
||
+ $modprobes .= "# no driver for ".$chip->{detected}[0]{chipname}." using w83781d\n";
|
||
+ $modprobes .= "modprobe w83781d\n"
|
||
+ }
|
||
} else {
|
||
# need the * for 2.4 kernels, won't necessarily be an exact match
|
||
open(local *INPUTFILE, "modprobe -l $chip->{driver}\\* 2>/dev/null |");
|
||
@@ -5789,6 +5802,8 @@ EOT
|
||
print "Copy prog/init/lm_sensors.init to /etc/init.d/lm_sensors\n".
|
||
"for initialization at boot time.\n"
|
||
unless -f "/etc/init.d/lm_sensors";
|
||
+ system("/sbin/insserv", "/etc/init.d/lm_sensors")
|
||
+ if -f "/etc/init.d/lm_sensors";
|
||
}
|
||
}
|
||
|
||
--- prog/init/README
|
||
+++ prog/init/README 2007-08-01 00:00:00.000000000 +0200
|
||
@@ -10,7 +10,7 @@ The script lm_sensors.init is a nice sta
|
||
On RH and other RH-based systems (MDK, notably) use this sort of startup
|
||
mechanism (i.e. SVR4-based), as opposed to the everything-in-one-script
|
||
(/etc/rc or /etc/rc.local) like the BSD-based systems do.
|
||
-The lm_sensors.init file should be copied to /etc/rc.d/init.d/lm_sensors.
|
||
+The lm_sensors.init file should be copied to /etc/init.d/lm_sensors.
|
||
For more information see the top of the file.
|
||
It requires the /etc/sysconfig/lm_sensors file, which identifies
|
||
the correct modules.
|
||
@@ -27,10 +27,10 @@ by Marc Rieffel <marc@paracel.com>.
|
||
----------------
|
||
|
||
The script sensord.init also loads the modules, and then
|
||
-starts the sensord daemon. See the directory ../sensord for
|
||
+starts the sensord daemon. See the manual page sensord(8) for
|
||
more information on the daemon.
|
||
|
||
-The sensord.init file should be copied to /etc/rc.d/init.d/sensord.
|
||
+The sensord.init file should be copied to /etc/init.d/sensord.
|
||
For more information see the top of the file.
|
||
|
||
To configure this service one should put appropriate "alias i2c-bus-0 xxx"
|
||
--- prog/init/lm_sensors.init.suse
|
||
+++ prog/init/lm_sensors.init.suse 2007-08-01 15:21:17.447299679 +0200
|
||
@@ -1,19 +1,15 @@
|
||
#!/bin/sh
|
||
#
|
||
### BEGIN INIT INFO
|
||
-# Provides: lm_sensors
|
||
-# Required-Start: $local_fs
|
||
-# X-UnitedLinux-Should-Start:
|
||
-# Required-Stop: $local_fs
|
||
-# X-UnitedLinux-Should-Stop:
|
||
-# Default-Start: 3 4 5
|
||
-# Default-Stop: 0 1 2 6
|
||
-# Short-Description: LM Sensors
|
||
-# Description: LM Sensors for hardware monitoring
|
||
+# Provides: sensors
|
||
+# Required-Start: $remote_fs
|
||
+# Required-Stop: $remote_fs
|
||
+# Default-Start: 2 3 5
|
||
+# Default-Stop:
|
||
+# Short-Description: Load and configure hardware monitoring drivers
|
||
+# Description: sensors is used for monitoring motherboard sensor values.
|
||
+# Config file is /etc/sysconfig/lm_sensors
|
||
### END INIT INFO
|
||
-# chkconfig: 2345 26 74
|
||
-# description: sensors is used for monitoring motherboard sensor values.
|
||
-# config: /etc/sysconfig/lm_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
|
||
@@ -40,115 +36,91 @@
|
||
# 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-proc &>/dev/null
|
||
+[ -e /sys/bus/i2c/devices ] || /sbin/modprobe i2c-dev &>/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
|
||
-
|
||
+[ -e /sys/bus/i2c/devices ] || exit 0
|
||
+
|
||
# If sensors was not already running, unload the module...
|
||
-[ -e /var/lock/subsys/lm_sensors ] || /sbin/modprobe -r i2c-proc &>/dev/null
|
||
+[ -e /var/lock/subsys/sensors ] || /sbin/modprobe -r i2c-dev &>/dev/null
|
||
|
||
CONFIG=/etc/sysconfig/lm_sensors
|
||
-PSENSORS=/usr/local/bin/sensors
|
||
+PSENSORS=/usr/bin/sensors
|
||
+FANCONFIG=/etc/fancontrol
|
||
+PFAN=/usr/sbin/fancontrol
|
||
|
||
# Source function library.
|
||
-#. /etc/init.d/functions
|
||
-
|
||
-# Shell functions sourced from /etc/rc.status:
|
||
-# rc_check check and set local and overall rc status
|
||
-# rc_status check and set local and overall rc status
|
||
-# rc_status -v ditto but be verbose in local rc status
|
||
-# rc_status -v -r ditto and clear the local rc status
|
||
-# rc_status -s display "skipped" and exit with status 3
|
||
-# rc_status -u display "unused" and exit with status 3
|
||
-# rc_failed set local and overall rc status to failed
|
||
-# rc_failed <num> set local and overall rc status to <num>
|
||
-# rc_reset clear local rc status (overall remains)
|
||
-# rc_exit exit appropriate to overall rc status
|
||
-# rc_active checks whether a service is activated by symlinks
|
||
-# rc_splash arg sets the boot splash screen to arg (if active)
|
||
. /etc/rc.status
|
||
|
||
-# Reset status of this service
|
||
-rc_reset
|
||
-
|
||
-# Return values acc. to LSB for all commands but status:
|
||
-# 0 - success
|
||
-# 1 - generic or unspecified error
|
||
-# 2 - invalid or excess argument(s)
|
||
-# 3 - unimplemented feature (e.g. "reload")
|
||
-# 4 - user had insufficient privileges
|
||
-# 5 - program is not installed
|
||
-# 6 - program is not configured
|
||
-# 7 - program is not running
|
||
-# 8--199 - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
|
||
-#
|
||
-# Note that starting an already running service, stopping
|
||
-# or restarting a not-running service as well as the restart
|
||
-# with force-reload (in case signaling is not supported) are
|
||
-# considered a success.
|
||
-
|
||
-RETVAL=0
|
||
-
|
||
start() {
|
||
- echo -n $"Starting up sensors: "
|
||
+ echo -n "Starting up sensors"
|
||
+ unset ${!MODULE_*}
|
||
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}__
|
||
+ for i in ${!MODULE_*} ; do
|
||
+ eval module=\$$i
|
||
/sbin/modprobe $module &>/dev/null
|
||
- i=`expr $i + 1`
|
||
+ rc_status
|
||
done
|
||
- $PSENSORS -s
|
||
+ rc_status
|
||
|
||
- RETVAL=$?
|
||
- if [ $RETVAL -eq 0 ] && touch /var/lock/subsys/lm_sensors ; then
|
||
- rc_status -v
|
||
+ /usr/bin/sensors -s &> /dev/null
|
||
+ rc_status
|
||
+
|
||
+ # Start fan control, if configured
|
||
+ if test -s "$FANCONFIG" -a -x "$PFAN" ; then
|
||
+ echo -n ", starting fan control: "
|
||
+ /sbin/startproc -q "$PFAN"
|
||
+ rc_status
|
||
else
|
||
- rc_status -v
|
||
+ echo -n ": "
|
||
fi
|
||
+
|
||
+ rc_status -v && touch /var/lock/subsys/sensors
|
||
}
|
||
|
||
stop() {
|
||
- echo -n $"Shutting down sensors: "
|
||
+ echo -n "Shutting down sensors"
|
||
+ unset ${!MODULE_*}
|
||
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`
|
||
+ # Stop fan control, if it was started
|
||
+ if test -s /var/run/fancontrol.pid ; then
|
||
+ echo -n ", stopping fan control: "
|
||
+ /sbin/killproc -TERM "$PFAN"
|
||
+ rc_status
|
||
+ else
|
||
+ echo -n ": "
|
||
+ fi
|
||
+
|
||
+ for i in ${!MODULE_*} ; do
|
||
+ eval module=\$$i
|
||
/sbin/modprobe -r $module &>/dev/null
|
||
- i=`expr $i - 1`
|
||
+ rc_status
|
||
done
|
||
- /sbin/modprobe -r i2c-proc &>/dev/null
|
||
|
||
- RETVAL=$?
|
||
- if [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/lm_sensors ; then
|
||
- rc_status -v
|
||
- else
|
||
- rc_status -v
|
||
- fi
|
||
+ rc_status -v && rm -f /var/lock/subsys/sensors
|
||
}
|
||
|
||
dostatus() {
|
||
- $PSENSORS
|
||
- RETVAL=$?
|
||
+ $PSENSORS
|
||
+ rc_status
|
||
}
|
||
|
||
restart() {
|
||
stop
|
||
start
|
||
- RETVAL=$?
|
||
+ rc_status
|
||
}
|
||
|
||
condrestart() {
|
||
[ -e /var/lock/subsys/lm_sensors ] && restart || :
|
||
}
|
||
|
||
+# Reset status of this service
|
||
+rc_reset
|
||
+
|
||
# See how we were called.
|
||
case "$1" in
|
||
start)
|
||
@@ -163,12 +135,12 @@ case "$1" in
|
||
restart|reload)
|
||
restart
|
||
;;
|
||
- condrestart)
|
||
+ try-restart)
|
||
condrestart
|
||
;;
|
||
*)
|
||
- echo "Usage: sensors.init {start|stop|status|restart|reload|condrestart}"
|
||
+ echo "Usage: lm_sensors {start|stop|status|restart|reload|try-restart}"
|
||
exit 1
|
||
esac
|
||
|
||
-exit $RETVAL
|
||
+rc_exit
|
||
--- prog/init/sensord.init
|
||
+++ prog/init/sensord.init 2007-08-01 00:00:00.000000000 +0200
|
||
@@ -1,130 +1,84 @@
|
||
-#!@BASH@
|
||
+#!/bin/bash
|
||
#
|
||
-# @INITRDDIR@/sensord
|
||
-#
|
||
-# sensord This shell script takes care of starting and stopping
|
||
-# sensord, the lm_sensors hardware health monitoring daemon.
|
||
-#
|
||
-# Here is the sensors service for SysV init, based on lm_sensors-2.5.5-sensors
|
||
-# from Mandrake lm_sensors source RPM. It is modified according to recommendations
|
||
-# for RedHat initscripts. The drivers starting part is taken from alsasound
|
||
-# service. To configure this service one should put appropriate "alias i2c-bus-0
|
||
-# xxx" and "alias i2c-sensors-chip-0 xxx" in /etc/modules.conf. The rest should be
|
||
-# self explaining.
|
||
-#
|
||
-# You put it into /etc/rc.d/init.d/, you make a symlink (probably using
|
||
-# chkconfig, ntsysv, tksysv or serviceconf program) named S95xxx and K05xxx
|
||
-# into /etc/rc#.d (where # is the number of runlevel), and sensors service
|
||
-# (which starts lm_sensors modules, runs sensors -s and starts sensord)
|
||
-# will be started automatically at startup/reboot and stopped at shutdown.
|
||
-# One could also start/stop service manually.
|
||
-#
|
||
-# This service was tested for RedHat 7.2 only.
|
||
-# Jakub Nar<61>bski, Poland
|
||
+# /etc/init.d/sensord
|
||
#
|
||
+### BEGIN INIT INFO
|
||
+# Provides: sensors
|
||
+# Required-Start: $remote_fs
|
||
+# Required-Stop: $remote_fs
|
||
+# Default-Start: 2 3 5
|
||
+# Default-Stop:
|
||
+# Short-Description: Hardware monitoring daemon
|
||
+# Description: This shell script takes care of starting and stopping
|
||
+# sensord, the lm_sensors hardware health monitoring daemon.
|
||
+### END INIT INFO
|
||
|
||
-# chkconfig: 2345 05 95
|
||
-# processname: sensord
|
||
-# config: @SYSCONFDIR@/sensors.conf
|
||
-# pidfile: /var/run/sensord.pid
|
||
-# description: Sensors is a sensors daemon which can be used to alert you \
|
||
-# in the event of a hardware health monitoring alarm.
|
||
|
||
# Source function library.
|
||
-. @INITRDDIR@/functions
|
||
-
|
||
-# Set default return value to 0 (success)
|
||
-RETVAL=0
|
||
-# Add @SBINDIR@ (sensord) and @BINDIR@ (sensors) to PATH if necessary
|
||
-echo "$PATH" | grep -q @SBINDIR@ || PATH=$PATH:@SBINDIR@
|
||
-echo "$PATH" | grep -q @BINDIR@ || PATH=$PATH:@BINDIR@
|
||
-export PATH
|
||
+. /etc/rc.status
|
||
|
||
# Modules to load from modules.conf (modules configuration)
|
||
-i2c_bus_drivers=<3D>modprobe -c | \
|
||
- awk <20>/^[[:space:]]*alias[[:space:]]+i2c-bus-[[:digit:]]/ { print $3 }<7D><>
|
||
-i2c_chip_drivers=<3D>modprobe -c | \
|
||
- awk <20>/^[[:space:]]*alias[[:space:]]+i2c-sensors-chip-[[:digit:]]/ { print $3
|
||
-}<7D><>
|
||
+i2c_bus_drivers=`modprobe -c | \
|
||
+ awk '/^[[:space:]]*alias[[:space:]]+i2c-bus-[[:digit:]]/ { print $3 }'`
|
||
+i2c_chip_drivers=`modprobe -c | \
|
||
+ awk '/^[[:space:]]*alias[[:space:]]+i2c-sensors-chip-[[:digit:]]/ { print $3 }'`
|
||
|
||
# Configuration of sensord
|
||
interval=1m # interval between scanning for sensor alarms
|
||
log_interval=30m # interval between logging all sensor readings
|
||
|
||
-# Check that we use kernel for which lm_sensors-drivers was installed
|
||
-[ <20>uname -r<> = @MVERSION@ ] || exit 0
|
||
-
|
||
# Check that lm_sensors is installed.
|
||
-[ -x @SBINDIR@/sensord ] || exit 0
|
||
-[ -x @BINDIR@/sensors ] || exit 0
|
||
-
|
||
-echo_status()
|
||
-{
|
||
- if [ $1 -eq 0 ]; then
|
||
- echo_success
|
||
- else
|
||
- echo_failure
|
||
- fi
|
||
- echo
|
||
-}
|
||
+[ -x /usr/sbin/sensord ] || exit 0
|
||
+[ -x /usr/bin/sensors ] || exit 0
|
||
|
||
start()
|
||
{
|
||
# Start modules
|
||
echo "Starting I2C bus (adapter) drivers: "
|
||
for driver in $i2c_bus_drivers; do
|
||
- echo -n "Starting I2C driver: $driver "
|
||
- /sbin/modprobe <20>echo $driver<65>
|
||
- echo_status $?
|
||
+ /sbin/modprobe $driver &> /dev/null
|
||
+ rc_status
|
||
done
|
||
+ rc_status -v
|
||
+
|
||
echo "Starting I2C chip (sensors) drivers: "
|
||
for driver in $i2c_chip_drivers; do
|
||
- echo -n "Starting I2C driver: $driver "
|
||
- /sbin/modprobe $(echo $driver)
|
||
- echo_status $?
|
||
+ /sbin/modprobe $driver &> /dev/null
|
||
+ rc_status
|
||
done
|
||
+ rc_status -v
|
||
+
|
||
# Set Alarm
|
||
echo -n "Configuring sensors: "
|
||
- sensors -s && sleep 2
|
||
+ sensors -s
|
||
+ rc_status && sleep 2
|
||
+ rc_status -v
|
||
+
|
||
echo_status $?
|
||
# Start daemons.
|
||
echo -n $"Starting sensord: "
|
||
- daemon sensord -i $interval -l $log_interval
|
||
- RETVAL=$?
|
||
-
|
||
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sensord
|
||
-
|
||
- echo
|
||
- return $RETVAL
|
||
+ startproc /usr/sbin/sensord -i $interval -l $log_interval
|
||
+ rc_status -v && touch /var/lock/subsys/sensord
|
||
}
|
||
|
||
stop()
|
||
{
|
||
# Stop daemons.
|
||
echo -n $"Shutting down sensord: "
|
||
- killproc sensord
|
||
- RETVAL=$?
|
||
+ killproc /usr/sbin/sensord
|
||
+ rc_status -v
|
||
|
||
- echo
|
||
# Remove modules
|
||
- drivers=<3D>echo "$i2c_chip_drivers $i2c_bus_drivers" | \
|
||
- tr -s "[:space:]\n" " "<22>
|
||
- echo -n "Removing I2C drivers: $drivers"
|
||
- /sbin/modprobe -r -q $drivers
|
||
- echo_status $?
|
||
-
|
||
- echo
|
||
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/sensord
|
||
-
|
||
- return $RETVAL
|
||
+ echo -n "Removing I2C drivers: " $i2c_chip_drivers $i2c_bus_drivers
|
||
+ /sbin/modprobe -r -q $i2c_chip_drivers $i2c_bus_drivers
|
||
+ rc_status -v && rm -f /var/lock/subsys/sensord
|
||
}
|
||
|
||
reload()
|
||
{
|
||
# Reread configuration file
|
||
sensors -s
|
||
-
|
||
- return $?
|
||
+ rc_status
|
||
}
|
||
|
||
# See how we were called.
|
||
@@ -135,9 +89,6 @@ case "$1" in
|
||
stop)
|
||
stop
|
||
;;
|
||
- status)
|
||
- status sensord
|
||
- ;;
|
||
restart)
|
||
stop
|
||
start
|
||
@@ -145,11 +96,11 @@ case "$1" in
|
||
reload)
|
||
reload
|
||
;;
|
||
- condrestart)
|
||
+ try-restart)
|
||
[ -e /var/lock/subsys/sensord ] && restart || :
|
||
;;
|
||
*)
|
||
- echo "Usage: sensord {start|stop|restart|reload|condrestart|status}"
|
||
+ echo "Usage: sensord {start|stop|restart|reload|try-restart|status}"
|
||
exit 1
|
||
;;
|
||
esac
|