]> git.pld-linux.org Git - packages/nut.git/blob - nut.init
- fixed broken init
[packages/nut.git] / nut.init
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
30                 show "Starting UPS drivers"
31                 daemon /usr/lib/nut/upsdrvctl start
32                 if [ $? -eq 0 ]; then
33                         msg_starting "UPS network daemon"
34                         daemon "upsd $OPTIONS"
35                         RETVAL=$?
36                         touch /var/lock/subsys/ups
37                 fi
38         else
39                 msg_Already_Running "UPS drivers and network daemon"
40         fi
41         ;;
42   stop)
43         if [ -f /var/lock/subsys/ups ]; then
44                 msg_stopping "UPS daemon"
45                 killproc upsd
46                 show "Stopping UPS drivers"
47                 daemon /usr/lib/nut/upsdrvctl stop
48                 RETVAL=$?
49                 rm -f /var/lock/subsys/ups
50         else
51                 msg_Not_Running "UPS daemon"
52         fi
53         ;;
54   restart)
55         $0 stop
56         $0 start
57         ;;
58   reload)
59         msg_reloading "UPS drivers"
60         daemon /usr/lib/nut/upsdrvctl reload
61         msg_reloading "UPS network daemon"
62         daemon upsd -c reload
63         ;;
64   force-reload)
65         $0 restart
66         exit $?
67         ;;
68   status)
69         status upsd
70         /usr/lib/nut/upsdrvctl status
71         ;;
72   *)
73         msg_Usage "$0 {start|stop|status|restart|reload|force-reload}"
74         exit 1
75         ;;
76 esac 
77 exit $RETVAL
78
This page took 0.053901 seconds and 3 git commands to generate.