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