- update initscript and sysconfig file - fix calls to open() for compatibility with the new glibc
139 lines
2.3 KiB
Bash
139 lines
2.3 KiB
Bash
#! /bin/bash
|
|
#
|
|
# chkconfig: - 26 74
|
|
# description: Network UPS Tools is a collection of programs which provide a common \
|
|
# interface for monitoring and administering UPS hardware.
|
|
|
|
# processname: upsd
|
|
# config: /etc/ups/
|
|
|
|
# Source function library.
|
|
if [ -f /etc/init.d/functions ]; then
|
|
. /etc/init.d/functions
|
|
elif [ -f /etc/rc.d/init.d/functions ]; then
|
|
. /etc/rc.d/init.d/functions
|
|
else
|
|
exit 0
|
|
fi
|
|
|
|
# Get config.
|
|
if [ -f /etc/sysconfig/ups ]; then
|
|
. /etc/sysconfig/ups
|
|
else
|
|
SERVER="no"
|
|
fi
|
|
|
|
start() {
|
|
if [ "$SERVER" = "yes" ]; then
|
|
echo -n $"Starting UPS driver controller: "
|
|
daemon /sbin/upsdrvctl start
|
|
RETVAL=$?
|
|
echo
|
|
|
|
prog="upsd"
|
|
echo -n $"Starting $prog: "
|
|
daemon /usr/sbin/upsd $UPSD_OPTIONS
|
|
if [ "$RETVAL" = 0 ]; then
|
|
RETVAL=$?
|
|
fi
|
|
echo
|
|
|
|
echo -n $"Starting UPS monitor (master): "
|
|
daemon /usr/sbin/upsmon
|
|
if [ "$RETVAL" = 0 ]; then
|
|
RETVAL=$?
|
|
fi
|
|
echo
|
|
else
|
|
echo -n $"Starting UPS monitor (slave): "
|
|
daemon /usr/sbin/upsmon
|
|
echo
|
|
fi
|
|
|
|
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/ups
|
|
}
|
|
|
|
stop() {
|
|
echo -n $"Stopping UPS monitor: "
|
|
killproc upsmon
|
|
echo
|
|
|
|
if [ "$SERVER" = "yes" ]; then
|
|
prog="upsd"
|
|
echo -n $"Stopping $prog: "
|
|
killproc upsd
|
|
RETVAL=$?
|
|
echo
|
|
|
|
echo -n $"Shutting down $MODEL: "
|
|
if [ "$MODEL" = "upsdrvctl" ]; then
|
|
/sbin/upsdrvctl stop
|
|
else
|
|
killproc $MODEL
|
|
fi
|
|
echo
|
|
fi
|
|
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/ups
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
reload() {
|
|
# FIXME: upsd and upsmon always return 0
|
|
# => can't tell if reload was successful
|
|
if [ "$SERVER" = "yes" ]; then
|
|
action "Reloading upsd:" /usr/sbin/upsd -c reload
|
|
RETVAL=$?
|
|
fi
|
|
action "Reloading upsmon:" /usr/sbin/upsmon -c reload
|
|
if [ "$RETVAL" = 0 ]; then
|
|
RETVAL=$?
|
|
fi
|
|
}
|
|
|
|
# See how we are called.
|
|
case "$1" in
|
|
start)
|
|
start ;;
|
|
|
|
stop)
|
|
stop ;;
|
|
|
|
restart)
|
|
restart ;;
|
|
|
|
try-restart)
|
|
[ -f /var/lock/subsys/ups ] && restart || :
|
|
;;
|
|
|
|
reload)
|
|
reload ;;
|
|
|
|
force-reload)
|
|
restart ;;
|
|
|
|
status)
|
|
if [ "$SERVER" = "yes" ]; then
|
|
if [ "$MODEL" = "upsdrvctl" ]; then
|
|
# show status of each configured driver
|
|
for MYMODEL in $(egrep '^[[:space:]]*driver' /etc/ups/ups.conf \
|
|
| sed 's/.*=[[:space:]]*//'); do
|
|
status $MYMODEL
|
|
done
|
|
else
|
|
status $MODEL
|
|
fi
|
|
status upsd
|
|
fi
|
|
status upsmon
|
|
;;
|
|
|
|
*)
|
|
echo $"Usage: $0 {start|stop|restart|try-restart|reload|force-reload|status}"
|
|
RETVAL=3
|
|
esac
|
|
|
|
exit $RETVAL
|