]> git.pld-linux.org Git - packages/lm_sensors.git/blob - sensors.init
4c396036d3dd0035004cefd2ee60b81878c8139f
[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                 _modprobe single die "i2c-$BUS"
31                 _modprobe single die "$CHIP"
32
33                 if [ "$SENSORS_SET" = "1" ]; then
34                         sensors -s
35                 fi
36                 
37                 msg_starting "sensors daemon"
38                 daemon sensord \
39                         $([ -n "$INTERVAL" ] && echo "-i $INTERVAL") \
40                         $([ -n "$LOG_INTERVAL" ] && echo "-l $LOG_INTERVAL") \
41                         -f daemon
42                 
43                 RET=$?
44                 [ $RET -eq 0 ] && touch /var/lock/subsys/sensors
45         else
46                 msg_already_running "sensors daemon"
47                 exit 1
48         fi
49         touch /var/lock/subsys/sensors
50         ;;
51   stop)
52         if [ -f /var/lock/subsys/sensors ]; then
53                 msg_stopping "sensors daemon"
54                 killproc sensord
55                 
56                 # remove kernel modules
57                 /sbin/rmmod $CHIP >/dev/null 2>&1 
58                 /sbin/rmmod i2c-$BUS >/dev/null 2>&1 
59                 
60                 rm -f /var/lock/subsys/sensors
61         else
62                 msg_not_running "sensors daemon"
63                 exit 1
64         fi
65         ;;
66   status)
67         status sensord
68         sensors
69         ;;
70   restart)
71         $0 stop
72         $0 start
73         ;;
74   *)
75         msg_usage "$0 {start|stop|status|restart}"
76         exit 1
77 esac
78
79 exit $RET
This page took 0.046411 seconds and 2 git commands to generate.