#!/bin/bash . /etc/rc.conf . /etc/rc.d/functions PID=`pidof -o %PPID /sbin/apcupsd` case "$1" in start) stat_busy "Starting APCUPSD Daemon" [ -z "$PID" ] && /sbin/apcupsd -f /etc/apcupsd/apcupsd.conf if [ $? -gt 0 ]; then stat_fail else add_daemon apcupsd stat_done fi ;; stop) stat_busy "Stopping APCUPSD Daemon" [ ! -z "$PID" ] && kill $PID &> /dev/null if [ $? -gt 0 ]; then stat_fail else rm_daemon apcupsd stat_done fi ;; restart) $0 stop sleep 2 $0 start ;; status) /sbin/apcaccess status ;; *) echo "usage: $0 {start|stop|restart|status}" esac exit 0