summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Brueckner <darks@gentoo.org>2001-06-28 00:09:29 +0000
committerHolger Brueckner <darks@gentoo.org>2001-06-28 00:09:29 +0000
commitce845076ecd0b87a4c9897853737b2d2369554b9 (patch)
tree6aa1a5265ad94b212296a6f2b608cf520a558a8c /sys-apps/apcupsd
parent- The SHA1 Digest module for perl. Somethings use this instead of (diff)
downloadhistorical-ce845076ecd0b87a4c9897853737b2d2369554b9.tar.gz
historical-ce845076ecd0b87a4c9897853737b2d2369554b9.tar.bz2
historical-ce845076ecd0b87a4c9897853737b2d2369554b9.zip
apcupsd is a full featured management daemon for apc upc's
it has support for remote shutdown via tcp/ip needs testing !!!
Diffstat (limited to 'sys-apps/apcupsd')
-rw-r--r--sys-apps/apcupsd/apcupsd-3.8.1.ebuild50
-rw-r--r--sys-apps/apcupsd/files/apccontrol122
-rw-r--r--sys-apps/apcupsd/files/apcupsd32
-rw-r--r--sys-apps/apcupsd/files/digest-apcupsd-3.8.11
-rwxr-xr-xsys-apps/apcupsd/files/halt24
5 files changed, 229 insertions, 0 deletions
diff --git a/sys-apps/apcupsd/apcupsd-3.8.1.ebuild b/sys-apps/apcupsd/apcupsd-3.8.1.ebuild
new file mode 100644
index 000000000000..5fbe5ac90293
--- /dev/null
+++ b/sys-apps/apcupsd/apcupsd-3.8.1.ebuild
@@ -0,0 +1,50 @@
+# Copyright 1999-2000 Gentoo Technologies, Inc.
+# Distributed under the terms of the GNU General Public License, v2 or later
+# Author Holger Brueckner <darks@gentoo.org>
+
+A=${P}.tar.gz
+S=${WORKDIR}/${P}
+DESCRIPTION="apc ups daemon with integrated tcp/ip remote shutdown"
+SRC_URI="http://www.sibbald.com/apcupsd/download/${A}"
+HOMEPAGE="http://www.sibbald.com/apcupsd/"
+
+DEPEND="virtual/glibc"
+
+src_compile() {
+ try ./configure
+ try make
+}
+
+src_install () {
+ dosbin apcupsd apcaccess apcnetd
+ cd ${S}/etc
+ dodir etc/apcupsd
+ insinto etc/apcupsd
+ doins *.conf
+ exeinto etc/apcupsd
+ doexe changeme commfailure commok mainsback onbattery
+ doexe ${FILESDIR}/apccontrol
+ dodir var/log/apcupsd
+ sed -e "s:/etc/apcupsd:/var/log/apcupsd:g" ${D}/etc/apcupsd/apcupsd.conf > ${D}/etc/apcupsd/apcupsd.conf.tmp
+ mv ${D}/etc/apcupsd/apcupsd.conf.tmp ${D}/etc/apcupsd/apcupsd.conf
+ cd ${S}/doc
+ dodoc *
+ docinto developers
+ dodoc developers/*
+ docinto manual
+ dodoc manual/*
+ mv ${S}/doc/apcupsd.man ${S}/doc/apcupsd.8
+ doman apcupsd.8
+ dodir /etc/rc.d/init.d
+ exeinto /etc/rc.d/init.d
+ doexe ${FILESDIR}/apcupsd
+ doexe ${FILESDIR}/halt
+}
+
+pkg_postinst () {
+ rc-update add apcupsd
+}
+
+pkg_prerm() {
+ rc-update del apcupsd
+}
diff --git a/sys-apps/apcupsd/files/apccontrol b/sys-apps/apcupsd/files/apccontrol
new file mode 100644
index 000000000000..050b32f02006
--- /dev/null
+++ b/sys-apps/apcupsd/files/apccontrol
@@ -0,0 +1,122 @@
+#!/bin/sh
+#
+# Copyright (C) 1999-2000 Riccardo Facchetti <riccardo@master.oasi.gpa.it>
+#
+# Generated automatically from apccontrol.sh.in by configure.
+#
+
+#
+# These variables are needed for set up the autoconf other variables.
+#
+prefix=/tmp/portage/apcupsd-3.8.1/image/
+exec_prefix=${prefix}
+
+APCPID=/var/run/apcupsd.pid
+APCUPSD=/usr/sbin/apcupsd
+SHUTDOWN=/sbin/shutdown
+SCRIPTSHELL=/bin/sh
+SCRIPTDIR=/etc/apcupsd
+
+#
+# This piece is to substitute the default behaviour with your own script,
+# perl, or C program.
+# You can customize every single command creating an executable file (may be a
+# script or a compiled program) and calling it the same as the $1 parameter
+# passed by apcupsd to this script.
+#
+# After executing your script, apccontrol continues with the default action.
+# If you do not want apccontrol to continue, exit your script with exit
+# code 99. E.g. "exit 99".
+#
+# WARNING: the apccontrol file will be overwritten every time you update your
+# apcupsd, doing `make install'. Your own customized scripts will _not_ be
+# overwritten. If you wish to make changes to this file (discouraged), you
+# should change apccontrol.sh.in and then rerun the configure process.
+#
+if [ -f ${SCRIPTDIR}/${1} -a -x ${SCRIPTDIR}/${1} ]
+then
+ ${SCRIPTSHELL} ${SCRIPTDIR}/${1}
+ # exit code 99 means he does not want us to do default action
+ if [ $? = 99 ] ; then
+ exit 0
+ fi
+fi
+
+case "$1" in
+ killpower)
+ echo "Apccontrol doing: ${APCUPSD} --killpower"
+ ${APCUPSD} --killpower
+ ;;
+ commfailure)
+ printf "Warning serial port communications with UPS lost." | wall
+ ;;
+ commok)
+ printf "Serial communciations with UPS restored." | wall
+ ;;
+ powerout)
+ printf "Warning power loss detected." | wall
+ ;;
+ onbattery)
+ printf "Power failure. Running on UPS batteries." | wall
+ ;;
+ failing)
+ printf "UPS battery power exhaused. Doing shutdown.\n" | wall
+ ;;
+ timeout)
+ printf "UPS battery runtime limit exceded. Doing shutdown.\n" | wall
+ ;;
+ loadlimit)
+ printf "UPS battery discharge limit reached. Doing shutdown.\n" | wall
+ ;;
+ runlimit)
+ printf "UPS battery runtime percent reached. Doing shutdown.\n" \
+ | wall
+ ;;
+ doreboot)
+ printf "Beginning Reboot Sequence" | wall
+ ${SHUTDOWN} -r now "apcupsd initiated reboot"
+ ;;
+ doshutdown)
+ printf "Beginning Shutdown Sequence" | wall
+ ${SHUTDOWN} -h now "apcupsd initiated shutdown"
+ ;;
+ mainsback)
+ printf "Power has returned..." | wall
+ if [ -f /etc/apcupsd/powerfail ] ; then
+ printf "Attempting to cancel shutdown." | wall
+ ${SHUTDOWN} -c
+ fi
+ ;;
+ annoyme)
+ printf "Power problems please logoff." | wall
+ ;;
+ emergency)
+ printf "Emergency Shutdown. Possible UPS battery failure." \
+ | wall
+ ${SHUTDOWN} -h now "apcupsd emergency shutdown"
+ ;;
+ changeme)
+ printf "Emergency! UPS batteries have failed\nChange them NOW" \
+ | wall
+ ;;
+ remotedown)
+ printf "Remote Shutdown.\nBeginning Shutdown Sequence." | wall
+ ${SHUTDOWN} -h now "apcupsd remote shutdown"
+ ;;
+ restartme)
+ echo -n "Restarting APCUPSD Power Management: "
+ THEPID=`cat ${APCPID}`
+ kill ${THEPID}
+ rm -f ${APCPID}
+ rm -f /etc/apcupsd/powerfail
+ rm -f /etc/nologin
+ sleep 5
+ `${APCUPSD}`
+ echo "apcupsd"
+ ;;
+ *) echo "Usage: ${0##*/} command"
+ echo " warning: this script is intended to be launched by"
+ echo " apcupsd and should never be launched by users."
+ exit 1
+ ;;
+esac
diff --git a/sys-apps/apcupsd/files/apcupsd b/sys-apps/apcupsd/files/apcupsd
new file mode 100644
index 000000000000..aca9c397350a
--- /dev/null
+++ b/sys-apps/apcupsd/files/apcupsd
@@ -0,0 +1,32 @@
+#!/bin/sh
+#RCUPDATE:2 3 4:80:This line is required for script management
+
+. /etc/rc.d/config/functions
+
+SERVICE=apcupsd
+DESC="apcupsd"
+EXE=/usr/sbin/apcupsd
+opts="start stop restart"
+
+start() {
+ rm -f /etc/apcupsd/powerfail
+ ebegin "Starting ${DESC}"
+ start-stop-daemon --start --quiet --exec ${EXE} -- 1>&2
+ eend $? "Error starting ${DESC}."
+}
+
+stop() {
+ ebegin "Stopping ${DESC}"
+ start-stop-daemon --stop --quiet --exec ${EXE} -- 1>&2
+ eend $? "Error stopping ${DESC}."
+}
+
+restart() {
+
+ stop
+ start
+
+}
+
+
+doservice ${@}
diff --git a/sys-apps/apcupsd/files/digest-apcupsd-3.8.1 b/sys-apps/apcupsd/files/digest-apcupsd-3.8.1
new file mode 100644
index 000000000000..07e84bfe27ba
--- /dev/null
+++ b/sys-apps/apcupsd/files/digest-apcupsd-3.8.1
@@ -0,0 +1 @@
+MD5 0acebeaa34a6f5c35d39fc70ccfdab49 apcupsd-3.8.1.tar.gz
diff --git a/sys-apps/apcupsd/files/halt b/sys-apps/apcupsd/files/halt
new file mode 100755
index 000000000000..3d2a9422e266
--- /dev/null
+++ b/sys-apps/apcupsd/files/halt
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# halt Execute the halt command.
+#
+# Version: @(#)halt 2.75 19-May-1998 miquels@cistron.nl
+# modified by Holger Brueckner <darksi@gentoo.org>
+# for apcupsd 28-June-2001
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+APCCONTROL="/etc/apcupsd/apccontrol killpower"
+
+# See if we need to cut the power.
+
+# See if this is a powerfail situation.
+if [ -f /etc/apcupsd/powerfail ]; then
+ echo "APCUPSD to the Rescue!"
+ echo
+ $APCCONTROL
+ echo
+ sleep 120
+ exit 1
+fi
+
+/sbin/halt -nfip