Sophie

Sophie

distrib > Mandriva > 10.2 > x86_64 > by-pkgid > 3789899296447b88ecc8161c9eeda636 > files > 1

lm_sensors-2.9.0-4.1.102mdk.src.rpm

#!/bin/sh
#
# sensors	This shell script takes care of starting and stopping
#               sensord.
#
# description: sensors is a sensors daemon which can be used to alert you in the
#               event of a hardware health monitoring alarm
#

# chkconfig: 2345 05 97
# Source function library.
. /etc/rc.d/init.d/functions

# It uses a config file /etc/sysconfig/lm_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 for 
# kernel 2.4
[ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc &>/dev/null

# Don't bother if neither /proc/sensors nor /sys/bus exist - we eitehr
# have 2.4 kernel without sensors support or 2.6 kernel without sysfs
# mounted
# For 2.6 we have no better checks - /sys/bus/i2c appears only when 
# adapter module has been loaded
[ -e /proc/sys/dev/sensors -o -d /sys/bus ] || exit 0

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

CONFIG=/etc/sysconfig/lm_sensors

[ -r $CONFIG ] || exit 0

# Check if sensors files are around

[ -f /usr/sbin/sensord ] || exit 0
[ -f /usr/bin/sensors ] || exit 0

# See how we were called.
case "$1" in
  start)
	echo -n $"Loading sensors modules: "
	test -r "$CONFIG" && . "$CONFIG"

        modules=`grep \^MODULE_ $CONFIG | wc -l`
        i=0
        while [ $i -lt $modules ] ; do
                module=`eval echo '$'MODULE_$i`
		/sbin/modprobe $module &>/dev/null
		i=`expr $i + 1`
	done
	echo
	# Set Alarm
	sensors -s && sleep 2
        # Start daemons.
        echo -n $"Starting sensord: "
        daemon sensord -i 1m -l 30m
        echo
	touch /var/lock/subsys/lm_sensors
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down sensord: "
	killproc sensord
        echo

	echo -n $"Removing sensors modules: "
	test -r "$CONFIG" && . "$CONFIG"

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

	rm -f /var/lock/subsys/lm_sensors
        ;;
  status)
	status sensord
	;;
  restart|reload)
	$0 stop
	$0 start
	;;
  condrestart)
        [ -e /var/lock/subsys/lm_sensors ] && $0 restart || :
	;;
  *)
        echo "Usage: sensors {start|stop|restart|reload|status}"
        exit 1
esac

exit 0