#!/bin/sh . /etc/rc.conf . /etc/rc.d/functions # If sensors isn't supported by the kernel, try loading the module... [ -e /proc/sys/dev/sensors ] || /sbin/modprobe i2c-proc >/dev/null 2>&1 # 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/run/lm_sensors ] || /sbin/modprobe -r i2c-proc >/dev/null 2>&1 CONFIG=/etc/sysconfig/lm_sensors [ -r "$CONFIG" ] || exit 0 grep '^MODULE_' $CONFIG >/dev/null 2>&1 || exit 0 # Load config file . "$CONFIG" PSENSORS=/usr/bin/sensors RETVAL=0 start() { stat_busy "Uruchamiam lm_sensors... " modules=`grep '^MODULE_' $CONFIG | wc -l | tr -d ' '` i=0 while [ $i -lt $modules ] ; do module=`echo MODULE_$i` MOD=`sed -n "/^$module/s/^.*=//p" $CONFIG` lsmod | grep $MOD >/dev/null || /sbin/modprobe $MOD >/dev/null 2>&1 i=`expr $i + 1` done $PSENSORS -s RETVAL=$? if [ $RETVAL -eq 0 ] && touch /var/run/lm_sensors.pid ; then add_daemon lm_sensors stat_done else stat_fail fi } stop() { stat_busy "Zatrzymuję lm_sensors... " modules=`grep '^MODULE_' $CONFIG | wc -l | tr -d ' '` i=0 while [ $i -lt $modules ] ; do module=`echo MODULE_$i` MOD=`sed -n "/^$module/s/^.*=//p" $CONFIG` lsmod | grep $MOD >/dev/null && /sbin/modprobe -r $MOD >/dev/null 2>&1 i=`expr $i + 1` done /sbin/modprobe -r i2c-proc >/dev/null 2>&1 RETVAL=$? if [ $RETVAL -eq 0 ] && rm -f /var/run/lm_sensors.pid ; then rm_daemon lm_sensors stat_done else stat_fail fi } dostatus() { $PSENSORS RETVAL=$? } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) dostatus ;; restart|reload) stop sleep 1 start RETVAL=$? ;; condrestart) if [ -e /var/run/lm_sensors.pid ]; then stop sleep 1 start else : fi ;; *) echo "UŻycie: $0 {start|stop|status|restart|reload|condrestart}" exit 1 ;; esac exit $RETVAL