]> git.pld-linux.org Git - packages/lm_sensors.git/blob - sensors.init
be3f415a6526fa59996cc01c5270ba4ed8fbd7c6
[packages/lm_sensors.git] / sensors.init
1 #!/bin/sh
2 #
3 # sensors:      Hardware sensors monitoring daemon
4 #
5 # Version:      $Revision$
6 #
7 # chkconfig:    2345 32 68
8 # description:  Starts and stops hardware sensors monitoring daemon.
9 # author:       Filip Kalinski <filon@pld.org.pl>
10
11 # Source function library.
12 . /etc/rc.d/init.d/functions
13
14 # Get service config
15 if [ -f /etc/sysconfig/sensors ]; then
16         . /etc/sysconfig/sensors
17 fi
18
19 RETVAL=0
20 # See how we were called.
21 case "$1" in
22   start)
23         # Check if the service is already running?
24         if [ ! -f /var/lock/subsys/sensors ]; then
25                 msg_starting "sensors daemon"
26                 if [ -z "$BUS" ] || [ -z "$CHIP" ]; then 
27                         fail
28                         nls "BUS or CHIP not configured in /etc/sysconfig/sensors" >&2
29                         exit 6
30                 fi
31
32                 # insert modules
33                 for i in $BUS; do
34                         _modprobe single die "i2c-$i"
35                 done
36                 for i in $CHIP; do
37                         _modprobe single die "$i"
38                 done
39
40                 if [ "$SENSORS_SET" = "1" ]; then
41                         sensors -s
42                 fi
43
44                 daemon sensord \
45                         $([ -n "$INTERVAL" ] && echo "-i $INTERVAL") \
46                         $([ -n "$LOG_INTERVAL" ] && echo "-l $LOG_INTERVAL") \
47                         $([ -n "$RRD_LOGFILE" ] && echo "-r $RRD_LOGFILE") \
48                         $([ -n "$RRD_INTERVAL" ] && echo "-t $RRD_INTERVAL") \
49                         -f daemon
50
51                 RETVAL=$?
52                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sensors
53                 touch /var/lock/subsys/sensors
54         else
55                 msg_already_running "sensors daemon"
56         fi
57         ;;
58   stop)
59         if [ -f /var/lock/subsys/sensors ]; then
60                 msg_stopping "sensors daemon"
61                 killproc sensord
62
63                 # remove kernel modules
64                 for i in $CHIP; do
65                         /sbin/rmmod $i >/dev/null 2>&1
66                 done
67                 for i in $BUS; do
68                         /sbin/rmmod i2c-$BUS >/dev/null 2>&1
69                 done
70
71                 rm -f /var/lock/subsys/sensors
72         else
73                 msg_not_running "sensors daemon"
74         fi
75         ;;
76   status)
77         status sensors sensord
78         RETVAL=$?
79         sensors
80         ;;
81   restart|force-reload)
82         $0 stop
83         $0 start
84         exit $?
85         ;;
86   *)
87         msg_usage "$0 {start|stop|restart|force-reload|status}"
88         exit 3
89 esac
90
91 exit $RETVAL
This page took 0.238906 seconds and 2 git commands to generate.