]> git.pld-linux.org Git - packages/lm_sensors.git/blob - sensors.init
- new %%doc
[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 # See how we were called.
20 case "$1" in
21   start)
22         # Check if the service is already running?
23         if [ ! -f /var/lock/subsys/sensors ]; then
24                 if [ -z "$BUS" ] || [ -z "$CHIP" ]; then 
25                         # sensors not configured                
26                         exit 1
27                 fi
28                 
29                 # insert modules
30                 for i in $BUS; do
31                         _modprobe single die "i2c-$i"
32                 done
33                 for i in $CHIP; do
34                         _modprobe single die "$i"
35                 done
36
37                 if [ "$SENSORS_SET" = "1" ]; then
38                         sensors -s
39                 fi
40                 
41                 msg_starting "sensors daemon"
42                 daemon sensord \
43                         $([ -n "$INTERVAL" ] && echo "-i $INTERVAL") \
44                         $([ -n "$LOG_INTERVAL" ] && echo "-l $LOG_INTERVAL") \
45                         -f daemon
46                 
47                 RET=$?
48                 [ $RET -eq 0 ] && touch /var/lock/subsys/sensors
49         else
50                 msg_already_running "sensors daemon"
51                 exit 1
52         fi
53         touch /var/lock/subsys/sensors
54         ;;
55   stop)
56         if [ -f /var/lock/subsys/sensors ]; then
57                 msg_stopping "sensors daemon"
58                 killproc sensord
59                 
60                 # remove kernel modules
61                 for i in $CHIP; do
62                         /sbin/rmmod $i >/dev/null 2>&1
63                 done
64                 for i in $BUS; do
65                         /sbin/rmmod i2c-$BUS >/dev/null 2>&1
66                 done
67                 
68                 rm -f /var/lock/subsys/sensors
69         else
70                 msg_not_running "sensors daemon"
71                 exit 1
72         fi
73         ;;
74   status)
75         status sensord
76         sensors
77         ;;
78   restart)
79         $0 stop
80         $0 start
81         ;;
82   *)
83         msg_usage "$0 {start|stop|status|restart}"
84         exit 1
85 esac
86
87 exit $RET
This page took 0.058322 seconds and 3 git commands to generate.