]>
Commit | Line | Data |
---|---|---|
2d79e510 JB |
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 | # See how we were called. | |
24 | case "$1" in | |
25 | start) | |
26 | # Check if the service is already running? | |
27 | if [ ! -f /var/lock/subsys/alarmwatch ]; then | |
28 | if [ -z "$CHIPS" ]; then | |
9b1a8270 | 29 | nls "alarmwatch not configured (CHIPS not set), cannot start." |
2d79e510 JB |
30 | exit 1 |
31 | fi | |
32 | if [ "$SENSORS_SETUP" = "yes" ]; then | |
33 | # setup sensors limits, etc. | |
34 | sensors -s | |
35 | fi | |
36 | # read from sensors to clear out any alarms caused by previous limits... | |
37 | sensors > /dev/null | |
38 | ||
39 | # show "Starting %s service" <service> | |
40 | msg_starting alarmwatch | |
41 | daemon alarmwatch -p "$PIDFILE" $CHIPS $ALARMOPTIONS | |
42 | RETVAL=$? | |
43 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/alarmwatch | |
44 | else | |
45 | # show "%s service is already running." <service> | |
46 | msg_already_running alarmwatch | |
47 | exit 1 | |
48 | fi | |
49 | ;; | |
50 | stop) | |
51 | # Stop daemons. | |
52 | # show "Stopping %s service" <service> | |
53 | if [ -f /var/lock/subsys/alarmwatch ]; then | |
54 | msg_stopping alarmwatch | |
55 | killproc alarmwatch | |
56 | RETVAL=$? | |
57 | rm -f /var/lock/subsys/alarmwatch $PIDFILE | |
58 | else | |
59 | # show "%s service is not running." <service> | |
60 | msg_not_running alarmwatch | |
61 | exit 1 | |
62 | fi | |
63 | ;; | |
64 | restart|reload|force-reload) | |
65 | $0 stop | |
66 | $0 start | |
67 | ;; | |
68 | status) | |
69 | status alarmwatch | |
70 | RETVAL=$? | |
71 | ;; | |
72 | *) | |
73 | # show "Usage: %s {start|stop|status|restart|reload|force-reload}" $0 | |
74 | msg_usage "$0 {start|stop|status|restart|reload|force-reload}" | |
75 | exit 1 | |
76 | esac | |
77 | ||
78 | exit $RETVAL | |
79 | ||
80 | # This must be last line ! | |
81 | # vi:syntax=sh:tw=78:ts=8:sw=4 |