This patch for SUSE 10.0 changes the lm_sensors service script to also start and
stop the fan control, if fan control is configured. If fan control is not
configured, this patch has no effect. To configure fan control, read the
documentation of package sensors, and run pwmconfig (as root).

Replace /usr/sbin/fancontrol with the rewritten fancontrol script.
Ignore the older sensors-fancontrol.diff.

Volker Kuhlmann, 8 Jan, 4 Feb 2006



--- /etc/init.d/lm_sensors.orig	2005-09-13 12:34:49.000000000 +1200
+++ /etc/init.d/lm_sensors	2006-01-08 13:16:57.000000000 +1300
@@ -46,6 +46,8 @@
 
 CONFIG=/etc/sysconfig/lm_sensors
 PSENSORS=/usr/bin/sensors
+FANCONFIG=/etc/fancontrol
+PFAN=/usr/sbin/fancontrol
 
 # Source function library.
 . /etc/rc.status
@@ -59,14 +61,33 @@
 		/sbin/modprobe $module &>/dev/null
 		rc_status
 	done
-	rc_status -v && touch /var/lock/subsys/sensors
+	rc_status && touch /var/lock/subsys/sensors
 	/usr/bin/sensors -s &> /dev/null
+
+	# Start fan control, if configured
+	if [ -s "$FANCONFIG" -a -x "$PFAN" ]; then
+	    echo -n "starting fan control: "
+	    "$PFAN" >/dev/null &
+	    echo $! >> /var/lock/subsys/sensors-fan
+	fi
+
+	rc_status -v
 }
 
 stop() {
 	echo -n $"Shutting down sensors: "
 	test -r "$CONFIG" && . "$CONFIG"
 
+	# Stop fan control, if it was started
+	if [ -s /var/lock/subsys/sensors-fan ]; then
+	    echo -n "stopping fan control: "
+	    pid="`cat /var/lock/subsys/sensors-fan`"
+	    kill -TERM "$pid"
+	    rm /var/lock/subsys/sensors-fan
+	    sleep 1 # wait for fancontrol to terminate (any better way?)
+	    true
+	fi
+
 	for i in ${!MODULE_*} ; do
 		eval module=\$$i
 		/sbin/modprobe -r $module &>/dev/null
