]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # | |
3 | # alarmwatch watches for lm_sensors alarms | |
4 | # | |
5 | # chkconfig: 2345 32 68 | |
6 | # | |
7 | # description: watches lm_sensors and beeps on aparms | |
8 | # | |
9 | # $Id$ | |
10 | ||
11 | # Source function library | |
12 | . /etc/rc.d/init.d/functions | |
13 | ||
14 | # Set defaults | |
15 | CHIPS="" | |
16 | PIDFILE=/var/run/alarmwatch.pid | |
17 | SENSORS_SETUP=no | |
18 | ALARMOPTIONS="" | |
19 | ||
20 | # Get service config - may override defaults | |
21 | [ -f /etc/sysconfig/alarmwatch ] && . /etc/sysconfig/alarmwatch | |
22 | ||
23 | RETVAL=0 | |
24 | # See how we were called. | |
25 | case "$1" in | |
26 | start) | |
27 | # Check if the service is already running? | |
28 | if [ ! -f /var/lock/subsys/alarmwatch ]; then | |
29 | if [ -z "$CHIPS" ]; then | |
30 | nls "alarmwatch not configured (CHIPS not set), cannot start." | |
31 | exit 6 | |
32 | fi | |
33 | if [ "$SENSORS_SETUP" = "yes" ]; then | |
34 | # setup sensors limits, etc. | |
35 | sensors -s | |
36 | fi | |
37 | # read from sensors to clear out any alarms caused by previous limits... | |
38 | sensors > /dev/null | |
39 | msg_starting alarmwatch | |
40 | daemon alarmwatch -p "$PIDFILE" $CHIPS $ALARMOPTIONS | |
41 | RETVAL=$? | |
42 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/alarmwatch | |
43 | else | |
44 | msg_already_running alarmwatch | |
45 | fi | |
46 | ;; | |
47 | stop) | |
48 | # Stop daemons. | |
49 | if [ -f /var/lock/subsys/alarmwatch ]; then | |
50 | msg_stopping alarmwatch | |
51 | killproc alarmwatch | |
52 | rm -f /var/lock/subsys/alarmwatch $PIDFILE | |
53 | else | |
54 | msg_not_running alarmwatch | |
55 | fi | |
56 | ;; | |
57 | restart|force-reload) | |
58 | $0 stop | |
59 | $0 start | |
60 | RETVAL=$? | |
61 | ;; | |
62 | status) | |
63 | status alarmwatch | |
64 | RETVAL=$? | |
65 | ;; | |
66 | *) | |
67 | msg_usage "$0 {start|stop|restart|force-reload|status}" | |
68 | exit 3 | |
69 | esac | |
70 | ||
71 | exit $RETVAL | |
72 | ||
73 | # This must be last line ! | |
74 | # vi:syntax=sh:tw=78:ts=8:sw=4 |