]> git.pld-linux.org Git - packages/nut.git/blame - nut.init
- explicitly specify augeas lenses dir instead of relying on installed packages
[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#
f57bb155 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
be0db874 21RETVAL=0
eca6ebe0
SZ
22# See how we are called.
23case "$1" in
24 start)
25 # Check if the service is already running?
26 if [ ! -f /var/lock/subsys/ups ]; then
b9f08db8 27 show "Starting UPS drivers"
c32c067c 28 daemon /usr/sbin/upsdrvctl start
cc6f774b
JR
29 RETVALDRV=$?
30 msg_starting "UPS network daemon"
18d52994 31 daemon /usr/sbin/upsd $UPSD_OPTIONS
b9f08db8 32 RETVAL=$?
33 if [ $RETVAL -eq 0 ]; then
3132bf7d 34 touch /var/lock/subsys/ups
cc6f774b 35 RETVAL=$RETVALDRV
3132bf7d 36 fi
eca6ebe0 37 else
b9f08db8 38 msg_already_running "UPS drivers and network daemon"
eca6ebe0
SZ
39 fi
40 ;;
41 stop)
b9f08db8 42 if [ -f /var/lock/subsys/ups ]; then
eca6ebe0 43 msg_stopping "UPS daemon"
793a77da 44 /usr/sbin/upsd -c stop
c32c067c 45 run_cmd "Stopping UPS drivers" /usr/sbin/upsdrvctl stop
eca6ebe0
SZ
46 rm -f /var/lock/subsys/ups
47 else
b9f08db8 48 msg_not_running "UPS daemon"
eca6ebe0
SZ
49 fi
50 ;;
51 restart)
52 $0 stop
53 $0 start
be0db874 54 exit $?
eca6ebe0 55 ;;
be0db874 56 reload|force-reload)
4257d08d 57 if [ -f /var/lock/subsys/ups ]; then
58 show "Reloading UPS drivers"
c32c067c
AM
59 /usr/sbin/upsdrvctl stop
60 /usr/sbin/upsdrvctl start
be0db874 61 [ $? -ne 0 ] && RETVAL=7
4257d08d 62 msg_reloading "UPS network daemon"
793a77da 63 /usr/sbin/upsd -c reload
be0db874 64 [ $? -ne 0 ] && RETVAL=7
4257d08d 65 else
be0db874 66 msg_not_running "UPS daemon" >&2
67 exit 7
4257d08d 68 fi
b9f08db8 69 ;;
7b1ed25c 70 powerdown)
793a77da 71 show "Switching the power off"; busy
c32c067c 72 /usr/sbin/upsdrvctl shutdown
7b1ed25c
JK
73 sleep 60
74 fail
793a77da 75 ;;
eca6ebe0
SZ
76 status)
77 status upsd
be0db874 78 RETVAL=$?
eca6ebe0
SZ
79 ;;
80 *)
7b1ed25c 81 msg_usage "$0 {start|stop|restart|reload|force-reload|status|powerdown}"
be0db874 82 exit 3
ea3b71f3 83esac
eca6ebe0 84
b9f08db8 85exit $RETVAL
This page took 0.055322 seconds and 5 git commands to generate.