]>
Commit | Line | Data |
---|---|---|
7ab74234 | 1 | #!/bin/sh |
2 | # | |
3 | # sensors: Hardware sensors monitoring daemon | |
4 | # | |
5 | # Version: $Revision$ | |
6 | # | |
9219070f | 7 | # chkconfig: 2345 32 68 |
7ab74234 | 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 | ||
7ab74234 | 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 | |
7ab74234 | 24 | if [ -z "$BUS" ] || [ -z "$CHIP" ]; then |
e1086432 JK |
25 | msg_starting "sensors daemon"; fail |
26 | nls "BUS or CHIP not configured in /etc/sysconfig/sensors" | |
11a93cac | 27 | exit 1 |
7ab74234 | 28 | fi |
29 | ||
30 | # insert modules | |
ff1b657b PG |
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 | |
09e9890d JB |
37 | |
38 | if [ "$SENSORS_SET" = "1" ]; then | |
39 | sensors -s | |
40 | fi | |
11a93cac | 41 | |
7ab74234 | 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 | |
eb9828bb | 51 | msg_already_running "sensors daemon" |
7ab74234 | 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 | |
ff1b657b PG |
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 | |
7ab74234 | 68 | |
69 | rm -f /var/lock/subsys/sensors | |
70 | else | |
eb9828bb | 71 | msg_not_running "sensors daemon" |
7ab74234 | 72 | exit 1 |
73 | fi | |
74 | ;; | |
75 | status) | |
e1086432 | 76 | status sensors sensord |
018b2f95 | 77 | sensors |
7ab74234 | 78 | ;; |
79 | restart) | |
80 | $0 stop | |
81 | $0 start | |
82 | ;; | |
83 | *) | |
eb9828bb | 84 | msg_usage "$0 {start|stop|status|restart}" |
7ab74234 | 85 | exit 1 |
86 | esac | |
87 | ||
88 | exit $RET |