]> git.pld-linux.org Git - packages/nut.git/blame - nut.init
- massive attack s/pld.org.pl/pld-linux.org/
[packages/nut.git] / nut.init
CommitLineData
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
b9f08db8 8# it's status available to other programs
eca6ebe0
SZ
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
4257d08d 25if [ -n "$BIND_ADDRESS" ] || [ -n "$TCP_PORT" ]; then
26 # Check that networking is up.
27 if is_yes "${NETWORKING}"; then
28 if [ ! -f /var/lock/subsys/network ]; then
29 msg_network_down ntp
30 exit 1
31 fi
32 else
33 exit 0
34 fi
35fi
36
37
eca6ebe0
SZ
38# See how we are called.
39case "$1" in
40 start)
41 # Check if the service is already running?
42 if [ ! -f /var/lock/subsys/ups ]; then
b9f08db8 43 show "Starting UPS drivers"
3132bf7d 44 daemon /usr/lib/nut/upsdrvctl start
b9f08db8 45 RETVAL=$?
46 if [ $RETVAL -eq 0 ]; then
3132bf7d
TO
47 msg_starting "UPS network daemon"
48 daemon "upsd $OPTIONS"
49 RETVAL=$?
50 touch /var/lock/subsys/ups
51 fi
eca6ebe0 52 else
b9f08db8 53 msg_already_running "UPS drivers and network daemon"
54 exit 1
eca6ebe0
SZ
55 fi
56 ;;
57 stop)
b9f08db8 58 if [ -f /var/lock/subsys/ups ]; then
eca6ebe0
SZ
59 msg_stopping "UPS daemon"
60 killproc upsd
3132bf7d
TO
61 show "Stopping UPS drivers"
62 daemon /usr/lib/nut/upsdrvctl stop
bb94ceb4 63 RETVAL=$?
eca6ebe0
SZ
64 rm -f /var/lock/subsys/ups
65 else
b9f08db8 66 msg_not_running "UPS daemon"
4257d08d 67 exit 1
eca6ebe0
SZ
68 fi
69 ;;
70 restart)
71 $0 stop
72 $0 start
73 ;;
bb94ceb4 74 reload)
4257d08d 75 if [ -f /var/lock/subsys/ups ]; then
76 show "Reloading UPS drivers"
77 daemon /usr/lib/nut/upsdrvctl reload
78 msg_reloading "UPS network daemon"
79 daemon upsd -c reload
80 else
81 msg_not_running "UPS daemon"
82 exit 1
83 fi
b9f08db8 84 ;;
eca6ebe0 85 force-reload)
b9f08db8 86 $0 reload
eca6ebe0
SZ
87 exit $?
88 ;;
89 status)
90 status upsd
8ecf50f9 91 /usr/lib/nut/upsdrvctl status
eca6ebe0
SZ
92 ;;
93 *)
b9f08db8 94 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
eca6ebe0
SZ
95 exit 1
96 ;;
97esac
eca6ebe0 98
b9f08db8 99exit $RETVAL
This page took 0.0757 seconds and 4 git commands to generate.