1#! /bin/sh 2# 3# apcupsd This shell script takes care of starting and stopping 4# the apcupsd UPS monitoring daemon. 5# 6# chkconfig: 2345 20 99 7# description: apcupsd monitors power and takes action if necessary 8# 9# Update October 7th, 2001 - CPE 10# 11APCPID=@PIDDIR@/apcupsd.pid 12DISTVER="@DISTVER@" 13POWERFAILDIR=@PWRFAILDIR@ 14LOCKDIR=@LOCKDIR@ 15SBINDIR=@sbindir@ 16 17return=" Done." 18 19 20case "$1" in 21 start) 22 rm -f ${POWERFAILDIR}/powerfail 23 echo "Starting apcupsd power management ...\c" 24 ${SBINDIR}/apcupsd || return=" Failed." 25 touch ${LOCKDIR}/apcupsd 26 echo "$return" 27 ;; 28 stop) 29 echo "Stopping apcupsd power management ...\c" 30 if [ -f ${APCPID} ]; then 31 THEPID=`cat ${APCPID}` 32 kill ${THEPID} || return=" Failed." 33 rm -f ${APCPID} 34 else 35 return=" Failed." 36 fi 37 rm -f ${LOCKDIR}/apcupsd 38 echo "$return" 39 ;; 40 restart) 41 $0 stop 42 $0 start 43 ;; 44 status) 45 ${SBINDIR}/apcaccess status 46 ;; 47 *) 48 echo "Usage: $0 {start|stop|restart|status}" 49 exit 1 50esac 51 52exit 0 53