#!/bin/sh # # ups NUT - Network UPS Tools daemon # # chkconfig: 2345 10 90 # # description: The ups daemon monitors an UPS and makes information about # it's status available to other programs # processname: upsd # config: /etc/ups/ # Source function library. . /etc/rc.d/init.d/functions # Get network config . /etc/sysconfig/network # Get config. [ -f /etc/sysconfig/ups ] && . /etc/sysconfig/ups [ -n "$PORT" ] && OPTIONS="-p $PORT" [ -n "$TCP_PORT" ] && OPTIONS="-t $TCP_PORT" [ -n "$BIND_ADDRESS" ] && OPTIONS="$OPTIONS -i $BIND_ADDRESS" # See how we are called. case "$1" in start) # Check if the service is already running? if [ ! -f /var/lock/subsys/ups ]; then msg_starting "UPS network daemon" daemon "upsd $OPTIONS" RETVAL=$? touch /var/lock/subsys/ups else msg_Already_Running "UPS drivers and network daemon" fi ;; stop) if [ -f /var/lock/subsys/ups ]; then msg_stopping "UPS daemon" killproc upsd RETVAL=$? rm -f /var/lock/subsys/ups else msg_Not_Running "UPS daemon" fi ;; restart) $0 stop $0 start ;; reload) msg_reloading "UPS network daemon" daemon upsd -c reload ;; force-reload) $0 restart exit $? ;; status) status upsd upsdrvctl status ;; *) msg_Usage "$0 {start|stop|status|restart|reload|force-reload}" exit 1 ;; esac exit $RETVAL