Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > 37e222326095a93978d54b1564dd9954 > files > 12

apcupsd-3.10.5-1mdk.ppc.rpm

#! /bin/sh
#
# apcupsd      This shell script takes care of starting and stopping
#	       the apcupsd UPS monitoring daemon.
#
# chkconfig: - 20 99
# description: apcupsd monitors power and takes action if necessary
#
APCPID=/var/run/apcupsd.pid

DISTVER=`cat /etc/mandrake-release | grep release | cut -f 5 -d ' '`

# Source function libarary
. /etc/rc.d/init.d/functions

if [ ! -x /sbin/apcupsd -o ! -r /etc/apcupsd/apcupsd.conf ]; then
    exit 0
fi

case "$1" in
    start)
       rm -f /etc/apcupsd/powerfail
       rm -f /etc/nologin
       gprintf "Starting UPS monitoring:" 
       if [ "${DISTVER}" = "5.2" ] ; then
	  /sbin/apcupsd -f /etc/apcupsd/apcupsd.conf
       else
	  /sbin/apcupsd -f /etc/apcupsd/apcupsd.conf && success || failure
       fi
       echo
       touch /var/lock/subsys/apcupsd
       ;;
    stop)
       gprintf "Shutting down UPS monitoring:"
       killproc apcupsd
       echo
       rm -f $APCPID
       rm -f /var/lock/subsys/apcupsd
       ;;
    restart|reload)
       $0 stop
       sleep 15
       $0 start
       ;;
    status)
       /sbin/apcaccess status
       ;;
    *)
       gprintf "Usage: %s {start|stop|restart|reload|status}\n" "$0"
       exit 1
       ;;
esac
exit 0