#!/bin/sh
# -*- Shell-script -*-
# Time-stamp: <00/02/02 07:44:36 lm_sensors wbosse@berlin.snafu.de> 
#
# chkconfig: 345 85 15
# description: (un)Load kernel modules of LM Sensors package.
#
# The modprobe/rmmod statements must correspond to the hardware configuration.
# /usr/sbin/sensors-detect may be used to determine to req. modules and their
# parameters.

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

# See how we were called.
case "$1" in
  start)
	msg='Loading LM sensors modules'
	echo -n "$msg: "
	(
	  modprobe i2c-isa
          modprobe i2c-piix4
          modprobe w83781d
          modprobe eeprom
	)
	if [ $? = 0 ] ; then
	  success "$msg"
	  echo
	  echo -n "Starting LM sensord: "
          daemon sensord
        else 
          failure "$msg"
        fi
	echo
	;;
  stop)
	echo -n "Shutting down LM sensord: "
	killproc sensord
	echo
	msg='Remove LM sensors modules'
	echo -n "$msg: "
	(
	  rmmod i2c-isa
          rmmod i2c-piix4
          rmmod w83781d
          rmmod eeprom
	)
	if [ $? = 0 ] ; then
	  success "$msg"
        else 
          failure "$msg"
        fi
	echo
	;;
  status)
        status sensord
        ;;
  reload)
	$0 stop
	$0 start
	;;
  *)
	echo "Usage: $0 {start|stop|status|reload}"
	exit 1
esac

exit 0
