]>
Commit | Line | Data |
---|---|---|
2d79e510 JB |
1 | #!/bin/sh |
2 | # | |
3 | # alarmwatch watches for lm_sensors alarms | |
4 | # | |
5e152178 | 5 | # chkconfig: 2345 32 68 |
2d79e510 JB |
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 | ||
fd4fd3df | 23 | RETVAL=0 |
2d79e510 JB |
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 | |
5e152178 | 30 | nls "alarmwatch not configured (CHIPS not set), cannot start." |
fd4fd3df | 31 | exit 6 |
2d79e510 JB |
32 | fi |
33 | if [ "$SENSORS_SETUP" = "yes" ]; then | |
5e152178 | 34 | # setup sensors limits, etc. |
35 | sensors -s | |
2d79e510 JB |
36 | fi |
37 | # read from sensors to clear out any alarms caused by previous limits... | |
38 | sensors > /dev/null | |
2d79e510 JB |
39 | msg_starting alarmwatch |
40 | daemon alarmwatch -p "$PIDFILE" $CHIPS $ALARMOPTIONS | |
41 | RETVAL=$? | |
42 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/alarmwatch | |
43 | else | |
2d79e510 | 44 | msg_already_running alarmwatch |
2d79e510 | 45 | fi |
5e152178 | 46 | ;; |
2d79e510 | 47 | stop) |
5e152178 | 48 | # Stop daemons. |
2d79e510 JB |
49 | if [ -f /var/lock/subsys/alarmwatch ]; then |
50 | msg_stopping alarmwatch | |
51 | killproc alarmwatch | |
2d79e510 JB |
52 | rm -f /var/lock/subsys/alarmwatch $PIDFILE |
53 | else | |
2d79e510 | 54 | msg_not_running alarmwatch |
4a8ed216 | 55 | fi |
5e152178 | 56 | ;; |
fd4fd3df | 57 | restart|force-reload) |
5e152178 | 58 | $0 stop |
2d79e510 | 59 | $0 start |
fd4fd3df | 60 | RETVAL=$? |
5e152178 | 61 | ;; |
2d79e510 JB |
62 | status) |
63 | status alarmwatch | |
64 | RETVAL=$? | |
5e152178 | 65 | ;; |
2d79e510 | 66 | *) |
fd4fd3df | 67 | msg_usage "$0 {start|stop|restart|force-reload|status}" |
68 | exit 3 | |
2d79e510 JB |
69 | esac |
70 | ||
71 | exit $RETVAL | |
72 | ||
73 | # This must be last line ! | |
74 | # vi:syntax=sh:tw=78:ts=8:sw=4 |