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