]> git.pld-linux.org Git - packages/lm_sensors.git/blobdiff - sensors.init
- use functions
[packages/lm_sensors.git] / sensors.init
index e79a7c5206452edd52a4b61179c9ae97649679d4..f86f47fb16ad4b1e81bb301acd6b2ac926863397 100644 (file)
@@ -2,7 +2,7 @@
 #
 # sensors:     Hardware sensors monitoring daemon
 #
-# Version:      $Revision$
+# Version:     $Revision$
 #
 # chkconfig:   2345 32 68
 # description: Starts and stops hardware sensors monitoring daemon.
 . /etc/rc.d/init.d/functions
 
 # Get service config
-if [ -f /etc/sysconfig/sensors ] ; then
-        . /etc/sysconfig/sensors
+if [ -f /etc/sysconfig/sensors ]; then
+       . /etc/sysconfig/sensors
 fi
 
-# See how we were called.
-case "$1" in
-  start)
+start() {
+       if [ ! -f /var/lock/subsys/sensors_modules ]; then
+               msg_starting "sensors daemon"; fail
+               nls "sensors_modules services not started" >&2
+               exit 6
+       fi
+       
        # Check if the service is already running?
        if [ ! -f /var/lock/subsys/sensors ]; then
-               if [ -z "$BUS" ] || [ -z "$CHIP" ]; then 
-                       # sensors not configured                
-                       exit 1
-               fi
-               
-               # insert modules
-               _modprobe single die "i2c-$BUS"
-               _modprobe single die "$CHIP"
-
-               if [ "$SENSORS_SET" = "1" ]; then
-                       sensors -s
-               fi
-               
                msg_starting "sensors daemon"
                daemon sensord \
                        $([ -n "$INTERVAL" ] && echo "-i $INTERVAL") \
                        $([ -n "$LOG_INTERVAL" ] && echo "-l $LOG_INTERVAL") \
+                       $([ -n "$RRD_LOGFILE" ] && echo "-r $RRD_LOGFILE") \
+                       $([ -n "$RRD_INTERVAL" ] && echo "-t $RRD_INTERVAL") \
                        -f daemon
-               
-               RET=$?
-               [ $RET -eq 0 ] && touch /var/lock/subsys/sensors
+
+               RETVAL=$?
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sensors
+               touch /var/lock/subsys/sensors
        else
-               msg_Already_Running "sensors daemon"
-               exit 1
+               msg_already_running "sensors daemon"
        fi
-       touch /var/lock/subsys/sensors
-       ;;
-  stop)
+}
+
+stop() {
        if [ -f /var/lock/subsys/sensors ]; then
                msg_stopping "sensors daemon"
                killproc sensord
-               
-               # remove kernel modules
-               /sbin/rmmod $CHIP >/dev/null 2>&1 
-               /sbin/rmmod i2c-$BUS >/dev/null 2>&1 
-               
                rm -f /var/lock/subsys/sensors
        else
-               msg_Not_Running "sensors daemon"
-               exit 1
+               msg_not_running "sensors daemon"
        fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
        ;;
   status)
-       status sensord
+       status sensors sensord
+       RETVAL=$?
+       sensors
        ;;
-  restart)
-       $0 stop
-       $0 start
+  restart|force-reload)
+       stop
+       start
        ;;
   *)
-       msg_Usage "$0 {start|stop|status|restart}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       exit 3
 esac
 
-exit $RET
+exit $RETVAL
This page took 0.041127 seconds and 4 git commands to generate.