Attention: All pages of this wiki depend on the pages that come before it, in order as they are listed on the Main Page. Please check for Dependencies.
Please also look at What You Need to Know Before Using This Wiki

/etc/init.d/apcupsd

From COCNM
Jump to navigation Jump to search
#! /bin/sh
#
# apcupsd
#     Start the APC UPS daemon to monitor power status.
#
# Modified for Debian GNU/Linux by Leon Breedt <ljb@debian.org>
# Last update: Wed Jul 14 15:14:50 SAST 1999
# Further modifications by Gordon Morehouse <spambox@evernex.com>
# Last update: Sun Apr 08 19:07 PDT 2001 
# Add lsbtags by Bob Miller <bob@computerisms.ca>
# Last update: 2013/08/25
### BEGIN INIT INFO
# Provides:          apcupsd
# Required-Start:     $all
# Required-Stop:    $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 6
# Short-Description: System Monitoring
# Description:       Monitor System Statistics and Report to Nagios Server
### END INIT INFO

DAEMONPID=/var/run/apcupsd.pid
DAEMON=/sbin/apcupsd

test -x $DAEMON || exit 0

set -e

case "$1" in
  start)
    echo -n "Starting APC UPS power management: "
    rm -f /etc/apcupsd/powerfail
    if [ ! -f /etc/nologin.boot -a -f /etc/nologin ]; then
       rm -f /etc/nologin
    fi
    if [ "`pidof apcupsd`" = "" ]
    then
        start-stop-daemon --start --quiet --pidfile $DAEMONPID --exec $DAEMON 
        echo "apcupsd."
    else
        echo ""
        echo "A copy of the daemon is still running.  If you just stopped it,"
        echo "please wait about 5 seconds for it to shut down."
        exit 0
    fi
  ;;
  stop)
    echo -n "Stopping APC UPS power management: "
    start-stop-daemon --stop --quiet --pidfile $DAEMONPID
    echo "apcupsd." 
  ;;
  restart|force-reload)
    echo -n "Restarting APC UPS power management: "
    start-stop-daemon --stop --quiet --pidfile $DAEMONPID
    sleep 10
    start-stop-daemon --start --quiet --pidfile $DAEMONPID --exec $DAEMON
    echo "apcupsd."
  ;;
  status)
    /sbin/apcaccess status
  ;;
  *)
    echo "Usage: /etc/init.d/apcupsd {start|stop|restart|force-reload|status}" >&2
    exit 1
  ;;
esac

exit 0