]>
Commit | Line | Data |
---|---|---|
eca6ebe0 SZ |
1 | #!/bin/sh |
2 | # | |
3 | # ups NUT - Network UPS Tools daemon | |
4 | # | |
5 | # chkconfig: 2345 10 90 | |
6 | # | |
7 | # description: The ups daemon monitors an UPS and makes information about | |
8 | # it's status available to other programs | |
9 | # processname: upsd | |
10 | # config: /etc/ups/ | |
11 | ||
12 | # Source function library. | |
13 | . /etc/rc.d/init.d/functions | |
14 | ||
15 | # Get network config | |
16 | . /etc/sysconfig/network | |
17 | ||
18 | # Get config. | |
19 | [ -f /etc/sysconfig/ups ] && . /etc/sysconfig/ups | |
20 | ||
21 | [ -n "$PORT" ] && OPTIONS="-p $PORT" | |
22 | [ -n "$TCP_PORT" ] && OPTIONS="-t $TCP_PORT" | |
23 | [ -n "$BIND_ADDRESS" ] && OPTIONS="$OPTIONS -i $BIND_ADDRESS" | |
24 | ||
25 | # See how we are called. | |
26 | case "$1" in | |
27 | start) | |
28 | # Check if the service is already running? | |
29 | if [ ! -f /var/lock/subsys/ups ]; then | |
d8ee969d TO |
30 | msg_starting "UPS network daemon" |
31 | daemon "upsd $OPTIONS" | |
32 | RETVAL=$? | |
33 | touch /var/lock/subsys/ups | |
eca6ebe0 | 34 | else |
bb94ceb4 | 35 | msg_Already_Running "UPS drivers and network daemon" |
eca6ebe0 SZ |
36 | fi |
37 | ;; | |
38 | stop) | |
39 | if [ -f /var/lock/subsys/ups ]; then | |
40 | msg_stopping "UPS daemon" | |
41 | killproc upsd | |
bb94ceb4 | 42 | RETVAL=$? |
eca6ebe0 SZ |
43 | rm -f /var/lock/subsys/ups |
44 | else | |
45 | msg_Not_Running "UPS daemon" | |
46 | fi | |
47 | ;; | |
48 | restart) | |
49 | $0 stop | |
50 | $0 start | |
51 | ;; | |
bb94ceb4 | 52 | reload) |
bb94ceb4 AM |
53 | msg_reloading "UPS network daemon" |
54 | daemon upsd -c reload | |
55 | ;; | |
eca6ebe0 SZ |
56 | force-reload) |
57 | $0 restart | |
58 | exit $? | |
59 | ;; | |
60 | status) | |
61 | status upsd | |
8ecf50f9 | 62 | /usr/lib/nut/upsdrvctl status |
eca6ebe0 SZ |
63 | ;; |
64 | *) | |
65 | msg_Usage "$0 {start|stop|status|restart|reload|force-reload}" | |
66 | exit 1 | |
67 | ;; | |
68 | esac | |
69 | exit $RETVAL | |
70 |