]>
Commit | Line | Data |
---|---|---|
ec1d83db JR |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright 1999 American Power Conversion, All Rights Reserved | |
4 | # | |
5 | # Revision History: | |
6 | # msamson 01Apr99 For Linux, we have to remove upsoff.cmd, because we cannot | |
7 | # remove this file once all filesystems have been unmounted | |
8 | # in our shutdown script. | |
9 | # msamson 04Oct99 Incorporated standard init fixes from Redhat | |
10 | # (pjones@redhat.com) | |
11 | # | |
2f9b1e08 | 12 | # chkconfig: 2345 98 92 |
13 | # description: Uninterruptable Power Supply Monitoring Daemon | |
ec1d83db JR |
14 | # |
15 | # | |
16 | ||
17 | # Source function library. | |
18 | . /etc/rc.d/init.d/functions | |
19 | ||
20 | # Source networking configuration. | |
21 | . /etc/sysconfig/network | |
22 | ||
23 | # Demon specified configuration. | |
24 | [ -f /etc/sysconfig/upsd ] && . /etc/sysconfig/upsd | |
25 | ||
26 | PWRCHUTE=/usr/lib/powerchute | |
27 | export PWRCHUTE | |
28 | TMPDIR=/tmp | |
29 | export TMPDIR | |
30 | ||
31 | if [ -r /upsoff.cmd ]; then | |
32 | rm -f /upsoff.cmd | |
33 | fi | |
34 | ||
deeb1085 | 35 | RETVAL=0 |
ec1d83db JR |
36 | # See how we were called. |
37 | case "$1" in | |
38 | start) | |
39 | # Check if the service is already running? | |
40 | if [ ! -f /var/lock/subsys/upsd ]; then | |
41 | msg_starting UPSd | |
42 | cd $PWRCHUTE | |
43 | daemon upsd | |
44 | RETVAL=$? | |
2f9b1e08 | 45 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/upsd |
ec1d83db | 46 | else |
2f9b1e08 | 47 | msg_already_running UPSd |
ec1d83db JR |
48 | fi |
49 | ;; | |
50 | stop) | |
51 | if [ -f /var/lock/subsys/upsd ]; then | |
52 | msg_stopping UPSd | |
53 | killproc upsd | |
54 | rm -f /var/lock/subsys/upsd >/dev/null 2>&1 | |
55 | else | |
2f9b1e08 | 56 | msg_not_running UPSd |
ec1d83db JR |
57 | fi |
58 | ;; | |
59 | status) | |
60 | status upsd | |
deeb1085 | 61 | exit $? |
ec1d83db | 62 | ;; |
deeb1085 | 63 | restart|force-reload) |
ec1d83db JR |
64 | $0 stop |
65 | $0 start | |
66 | exit $? | |
67 | ;; | |
68 | *) | |
deeb1085 | 69 | msg_usage "$0 {start|stop|restart|force-reload|status}" |
70 | exit 3 | |
ec1d83db JR |
71 | esac |
72 | ||
73 | exit $RETVAL |