#!/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... [ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc &>/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 # 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 -le $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$Pmodules` while [ $i -ge 0 ] ; do module=`eval echo '$'MODULE_$i` /sbin/modprobe -r $module &>/dev/null i=`expr $i - 1` 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