aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Shelton <stuart@shelton.me>2013-05-28 23:08:14 +0100
committerStuart Shelton <stuart@shelton.me>2013-05-28 23:08:14 +0100
commit16923a1faad7aaf244db5d24d9e3f7e47bc6eb67 (patch)
tree5029ede2f7e5ec1ad7db3eb36b7468371825c4d1 /sys-power
parentUpdate lvm2-2.02.97-r1 (diff)
downloadsrcshelton-16923a1faad7aaf244db5d24d9e3f7e47bc6eb67.tar.gz
srcshelton-16923a1faad7aaf244db5d24d9e3f7e47bc6eb67.tar.bz2
srcshelton-16923a1faad7aaf244db5d24d9e3f7e47bc6eb67.zip
sys-power/apcupsd-3.14.10-r1
Diffstat (limited to 'sys-power')
-rw-r--r--sys-power/apcupsd/Manifest8
-rw-r--r--sys-power/apcupsd/apcupsd-3.14.10-r1.ebuild137
-rw-r--r--sys-power/apcupsd/files/apcupsd-3.14.10-mib.patch104
-rw-r--r--sys-power/apcupsd/files/apcupsd-3.14.9-aliasing.patch39
-rw-r--r--sys-power/apcupsd/files/apcupsd-udev.rules10
-rw-r--r--sys-power/apcupsd/files/apcupsd.init.2a37
-rw-r--r--sys-power/apcupsd/files/apcupsd.init.328
-rw-r--r--sys-power/apcupsd/files/apcupsd.powerfail.init18
8 files changed, 381 insertions, 0 deletions
diff --git a/sys-power/apcupsd/Manifest b/sys-power/apcupsd/Manifest
new file mode 100644
index 00000000..009361a4
--- /dev/null
+++ b/sys-power/apcupsd/Manifest
@@ -0,0 +1,8 @@
+AUX apcupsd-3.14.10-mib.patch 3967 SHA256 e0eae470fd6f2d5cfc5f9faa3028ba5c13b24dc9c69c4c3a8555e61558378c70 SHA512 080fd6f6bd1aa571458c09b7587dee3fe5937175a6e111976537445e805b1a2a6bbddc28224bdc23cee58a2bedcc2c458ff24f1946fd9cbfbf50500b18124680 WHIRLPOOL b50d1b1deeb51f42230e56d4dfd1927af4858c5f42621acab94c46dc8b46ee9d281f296050f9f5b3e8ba434352eae43a90fd7a3c29d46915a40b257a3570702c
+AUX apcupsd-3.14.9-aliasing.patch 2108 SHA256 21343f4798121a828a89eee49ca9fe7574b2fb45a5aad35fbfd5aabec7740761 SHA512 48eb51385136216d1cdddb6b237b89a52c516b223aa7fe50fb35761cd595d9ab7f7fabbd0e4f8c0f7d45df6feed0a2e240d227181f3d772fc5fa9f8bfa62529f WHIRLPOOL 8ad5540b942919c7ce0c3b560feb1dc6a0771b81999f546d62b8c480ecb3731994a930c72dde9c5e36d9024d4c1b97b8bd00d8baa98ee99f273c59e43070ae38
+AUX apcupsd-udev.rules 328 SHA256 0865097a99b321301ec5b0bb51d0560a01df0a21cca0ee0df61f8d33f888b86a SHA512 ba2ebb9f28011548c845a81f17a328b98ec8d79c1e6be33aeab863d77b9d3aa61b4dfbd1bb89a0cae00465387dffe8cc223634a6e9a2f59170846d4bed9e7135 WHIRLPOOL ec304d772bcbcd5ba3cec1437a097d6159ad1f8b8e2bde49125d6cb1970bbc6f1de6264ba35a719431aed83f88210a583bb20fab0b771c115aaa93bf1db8c867
+AUX apcupsd.init.2a 844 SHA256 86be1bafb0cf72db61def444361c659e5c36d0e44b1a007772b3f49aa0e95bcb SHA512 e86dfc3b7b8a0dbca59225795a5e996176b9a064720f4c2f6c1efc27cdf2eb0ecbdb59180b24abde1af730b834303fdf31564ec3b86a46d29ebe19abfdd48494 WHIRLPOOL e7d1e8dcb61862061d1889436c9157d95ed6a86a60aca54a0dda2120f3f5410fb700c0d889841b2013808faa349f90033a34e53eecd407df4089c58fea551f56
+AUX apcupsd.init.3 659 SHA256 c3186646f06666ebd1ef265f5f6d56aeff27587face610d5f73c625b5c6053cc SHA512 fdaf68b4191dd04616c81035f8cfeafccb400a55273675b4125e67d28c3d23dc08446805e6553c868abf474773ce3a1fb36acbfbad9b85e4b6a57b7a170e01b2 WHIRLPOOL 0ea76a163c008f01d0bf8aa09219cce3a4ba6ada9f88d70b660dc06815227df37fdc82eb1b6987ec76a2cafc4f9cafa842d4ad9d81d017ef1c6d450efb077bc8
+AUX apcupsd.powerfail.init 520 SHA256 eee773aa07175674085cb0ab7ed2c071fcc04fc05383d368f38d056e7327ff35 SHA512 d946d9b3427e0269d87aba1d6048cc4c73d767b1f5bc7d112718b82ec60076123e302dc0a73a4e5bbb7d1137ff78fc87a61983622a765341cfd7a79dcd0817ad WHIRLPOOL 1639496c976c6b654c20b953d675916636e44e7e3097696850bd202c91a9ffb713b398a86a2777b93472bccd3179aa83fb63ce43a1bbbe47e99f320ba8282a9c
+DIST apcupsd-3.14.10.tar.gz 1336852 SHA256 0707b5ec9916fbde9e44eb8d18037c8d8f75dfd6aeef51aba5487e189eef2032 SHA512 f95918bff783cb60fa40b03a532ee7447293b0542f44f2f9ecf36ee028df3aa414f01e2b834a28fc319d88ec2e84c81314cd546b5628554176f2ca47fdc66bbc WHIRLPOOL 1fb40a5199eb8dfcd287bab08c2bbf51f02a3657ba615e16395d5f377bc9a5b6144db24b83ef5e9172ff970a715f87f685118a035c00372c34702984fac02d38
+EBUILD apcupsd-3.14.10-r1.ebuild 4106 SHA256 4b16ea408b67ceac28b5940fe0e7b261f09ec2d9e995a3134a40083fab485f9a SHA512 3e2daacdd3034c705b365a1032c033acad47cd78ae538aa5e12002b5715c738f2d6d357d394b195df3efb00c0530e96c933f62221d3dbd469b0c3cc7adf1eff8 WHIRLPOOL 96fcc3dc10d4e9ba9c5d9f98bcd34f805bcced8639edf0138143a2845bde5273c628e1e0fa5e2258e1ca9935d315b5c0efbbca8a042ab55e41823b926655eac0
diff --git a/sys-power/apcupsd/apcupsd-3.14.10-r1.ebuild b/sys-power/apcupsd/apcupsd-3.14.10-r1.ebuild
new file mode 100644
index 00000000..3c069a06
--- /dev/null
+++ b/sys-power/apcupsd/apcupsd-3.14.10-r1.ebuild
@@ -0,0 +1,137 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/apcupsd/apcupsd-3.14.10-r1.ebuild,v 1.3 2013/03/26 14:54:47 floppym Exp $
+
+EAPI=4
+
+inherit eutils linux-info flag-o-matic udev
+
+DESCRIPTION="APC UPS daemon with integrated tcp/ip remote shutdown"
+HOMEPAGE="http://www.apcupsd.org/"
+SRC_URI="mirror://sourceforge/apcupsd/${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~ppc ~x86 ~x86-fbsd"
+IUSE="snmp +usb cgi nls gnome kernel_linux"
+
+DEPEND="
+ cgi? ( >=media-libs/gd-1.8.4 )
+ nls? ( sys-devel/gettext )
+ snmp? ( net-analyzer/net-snmp )
+ gnome? ( >=x11-libs/gtk+-2.4.0:2
+ dev-libs/glib:2
+ >=gnome-base/gconf-2.0 )"
+RDEPEND="${DEPEND}
+ sys-apps/openrc
+ virtual/mailx"
+
+CONFIG_CHECK="~USB_HIDDEV ~HIDRAW"
+ERROR_USB_HIDDEV="CONFIG_USB_HIDDEV: needed to access USB-attached UPSes"
+ERROR_HIDRAW="CONFIG_HIDRAW: needed to access USB-attached UPSes"
+
+pkg_setup() {
+ if use kernel_linux && use usb && linux_config_exists; then
+ check_extra_config
+ fi
+}
+
+src_prepare() {
+ epatch "${FILESDIR}/${PN}-3.14.9-aliasing.patch"
+ epatch "${FILESDIR}/${PN}-3.14.10-mib.patch"
+}
+
+src_configure() {
+ local myconf
+ use cgi && myconf="${myconf} --enable-cgi --with-cgi-bin=/usr/libexec/${PN}/cgi-bin"
+ if use usb; then
+ myconf="${myconf} --with-upstype=usb --with-upscable=usb --enable-usb --with-dev= "
+ else
+ myconf="${myconf} --with-upstype=apcsmart --with-upscable=smart --disable-usb"
+ fi
+
+ # We force the DISTNAME to gentoo so it will use gentoo's layout also
+ # when installed on non-linux systems.
+ econf \
+ --sbindir=/sbin \
+ --sysconfdir=/etc/apcupsd \
+ --with-pwrfail-dir=/etc/apcupsd \
+ --with-lock-dir=/var/lock \
+ --with-pid-dir=/var/run \
+ --with-log-dir=/var/log \
+ --with-nis-port=3551 \
+ --enable-net --enable-pcnet \
+ --with-distname=gentoo \
+ $(use_enable snmp net-snmp) \
+ $(use_enable gnome gapcmon) \
+ ${myconf} \
+ APCUPSD_MAIL=/bin/mail
+}
+
+src_compile() {
+ # Workaround for bug #280674; upstream should really just provide
+ # the text files in the distribution, but I wouldn't count on them
+ # doing that anytime soon.
+ MANPAGER=$(type -p cat) \
+ emake || die "emake failed"
+}
+
+src_install() {
+ emake DESTDIR="${D}" install || die "installed failed"
+ rm -f "${D}"/etc/init.d/halt
+
+ insinto /etc/apcupsd
+ newins examples/safe.apccontrol safe.apccontrol
+
+ dodoc ChangeLog* ReleaseNotes
+ doman doc/*.8 doc/*.5
+
+ dohtml -r doc/manual/*
+
+ rm "${D}"/etc/init.d/apcupsd
+ newinitd "${FILESDIR}/${PN}.init.3" "${PN}"
+ newinitd "${FILESDIR}/${PN}.powerfail.init" "${PN}".powerfail
+
+ # remove hal settings, we don't really want to have it around still.
+ rm -r "${D}"/usr/share/hal
+
+ # replace it with our udev rules if we're in Linux
+ if use kernel_linux; then
+ udev_newrules "${FILESDIR}"/apcupsd-udev.rules 60-${PN}.rules
+ fi
+
+ # Without this it'll crash at startup. When merging in ROOT= this
+ # won't be created by default, so we want to make sure we got it!
+ keepdir /var/lock
+ fowners root:uucp /var/lock
+ fperms 0775 /var/lock
+}
+
+pkg_postinst() {
+ if use cgi; then
+ elog "The cgi-bin directory for ${PN} is /usr/libexec/${PN}/cgi-bin."
+ elog "Set up your ScriptAlias or symbolic links accordingly."
+ fi
+
+ elog ""
+ elog "Since version 3.14.0 you can use multiple apcupsd instances to"
+ elog "control more than one UPS in a single box."
+ elog "To do this, create a link between /etc/init.d/apcupsd to a new"
+ elog "/etc/init.d/apcupsd.something, and it will then load the"
+ elog "configuration file at /etc/apcupsd/something.conf."
+ elog ""
+
+ elog 'If you want apcupsd to power off your UPS when it'
+ elog 'shuts down your system in a power failure, you must'
+ elog 'add apcupsd.powerfail to your shutdown runlevel:'
+ elog ''
+ elog ' \e[01m rc-update add apcupsd.powerfail shutdown \e[0m'
+ elog ''
+
+ if use kernel_linux; then
+ elog "Starting from version 3.14.9-r1, ${PN} installs udev rules"
+ elog "for persistent device naming. If you have multiple UPS"
+ elog "connected to the machine, you can point them to the devices"
+ elog "in /dev/apcups/by-id directory."
+ fi
+}
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.10-mib.patch b/sys-power/apcupsd/files/apcupsd-3.14.10-mib.patch
new file mode 100644
index 00000000..aaa618bb
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd-3.14.10-mib.patch
@@ -0,0 +1,104 @@
+--- src/drivers/snmp/snmp.c~ 2007-10-06 15:52:52.000000000 +0100
++++ src/drivers/snmp/snmp.c 2012-08-09 11:22:30.100725543 +0100
+@@ -140,26 +140,26 @@
+
+ if (!strcmp(Sid->DeviceVendor, "APC") ||
+ !strcmp(Sid->DeviceVendor, "APC_NOTRAP")) {
+- Sid->MIB = malloc(sizeof(powernet_mib_t));
+- if (Sid->MIB == NULL) {
++ Sid->mib = malloc(sizeof(powernet_mib_t));
++ if (Sid->mib == NULL) {
+ log_event(ups, LOG_ERR, "Out of memory.");
+ exit(1);
+ }
+
+- memset(Sid->MIB, 0, sizeof(powernet_mib_t));
++ memset(Sid->mib, 0, sizeof(powernet_mib_t));
+
+ /* Run powernet specific init */
+ return powernet_snmp_ups_open(ups);
+ }
+
+ if (!strcmp(Sid->DeviceVendor, "RFC")) {
+- Sid->MIB = malloc(sizeof(ups_mib_t));
+- if (Sid->MIB == NULL) {
++ Sid->mib = malloc(sizeof(ups_mib_t));
++ if (Sid->mib == NULL) {
+ log_event(ups, LOG_ERR, "Out of memory.");
+ exit(1);
+ }
+
+- memset(Sid->MIB, 0, sizeof(ups_mib_t));
++ memset(Sid->mib, 0, sizeof(ups_mib_t));
+ return 1;
+ }
+
+--- src/drivers/snmp/drv_rfc1628.c~ 2012-08-09 11:18:56.001810234 +0100
++++ src/drivers/snmp/drv_rfc1628.c 2012-08-09 11:19:08.845988048 +0100
+@@ -32,7 +32,7 @@
+ struct snmp_ups_internal_data *Sid =
+ (struct snmp_ups_internal_data *)ups->driver_internal_data;
+ struct snmp_session *s = &Sid->session;
+- ups_mib_t *data = (ups_mib_t *)Sid->MIB;
++ ups_mib_t *data = (ups_mib_t *)Sid->mib;
+
+ /*
+ * Check the Ethernet COMMLOST first, then check the
+@@ -76,7 +76,7 @@
+ struct snmp_ups_internal_data *Sid =
+ (struct snmp_ups_internal_data *)ups->driver_internal_data;
+ struct snmp_session *s = &Sid->session;
+- ups_mib_t *data = (ups_mib_t *)Sid->MIB;
++ ups_mib_t *data = (ups_mib_t *)Sid->mib;
+
+ if (rfc_1628_check_alarms(ups) == 0) {
+ return 0;
+@@ -98,7 +98,7 @@
+ struct snmp_ups_internal_data *Sid =
+ (struct snmp_ups_internal_data *)ups->driver_internal_data;
+ struct snmp_session *s = &Sid->session;
+- ups_mib_t *data = (ups_mib_t *)Sid->MIB;
++ ups_mib_t *data = (ups_mib_t *)Sid->mib;
+
+ if (rfc_1628_check_alarms(ups) == 0) {
+ return 0;
+--- src/drivers/snmp/snmp.h~ 2007-10-06 15:52:52.000000000 +0100
++++ src/drivers/snmp/snmp.h 2012-08-09 11:17:43.988802514 +0100
+@@ -79,7 +79,7 @@
+ unsigned short remote_port; /* Remote socket, usually 161 */
+ char *DeviceVendor; /* Vendor (ex. APC|RFC) */
+ char *community; /* Community name */
+- void *MIB; /* Pointer to MIB data */
++ void *mib; /* Pointer to MIB data */
+ struct snmp_session *trap_session; /* snmp session for traps */
+ bool trap_received; /* Have we seen a trap? */
+ };
+--- src/drivers/snmp/drv_powernet.c~ 2010-01-02 21:28:28.000000000 +0000
++++ src/drivers/snmp/drv_powernet.c 2012-08-09 11:20:04.970761477 +0100
+@@ -34,7 +34,7 @@
+ struct snmp_ups_internal_data *Sid =
+ (struct snmp_ups_internal_data *)ups->driver_internal_data;
+ struct snmp_session *s = &Sid->session;
+- powernet_mib_t *data = (powernet_mib_t *)Sid->MIB;
++ powernet_mib_t *data = (powernet_mib_t *)Sid->mib;
+ int ret = 1;
+
+ /*
+@@ -161,7 +161,7 @@
+ struct snmp_ups_internal_data *Sid =
+ (struct snmp_ups_internal_data *)ups->driver_internal_data;
+ struct snmp_session *s = &Sid->session;
+- powernet_mib_t *data = (powernet_mib_t *)Sid->MIB;
++ powernet_mib_t *data = (powernet_mib_t *)Sid->mib;
+
+ if (powernet_check_comm_lost(ups) == 0)
+ return 0;
+@@ -300,7 +300,7 @@
+ struct snmp_ups_internal_data *Sid =
+ (struct snmp_ups_internal_data *)ups->driver_internal_data;
+ struct snmp_session *s = &Sid->session;
+- powernet_mib_t *data = (powernet_mib_t *)Sid->MIB;
++ powernet_mib_t *data = (powernet_mib_t *)Sid->mib;
+
+ if (powernet_check_comm_lost(ups) == 0)
+ return 0;
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-aliasing.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-aliasing.patch
new file mode 100644
index 00000000..09d9883a
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-aliasing.patch
@@ -0,0 +1,39 @@
+Index: apcupsd-3.14.9/src/apctest.c
+===================================================================
+--- apcupsd-3.14.9.orig/src/apctest.c
++++ apcupsd-3.14.9/src/apctest.c
+@@ -2206,18 +2206,18 @@ static struct {
+ const char *config_directive;
+ const char *descript;
+ char type;
+- int *data;
++ void *data;
+ } cmd_table[] = {
+ {'u', "HITRANSFER", "Upper transfer voltage", 'i', &eeprom_ups.hitrans},
+ {'l', "LOTRANSFER", "Lower transfer voltage", 'i', &eeprom_ups.lotrans},
+ {'e', "RETURNCHARGE", "Return threshold", 'i', &eeprom_ups.rtnpct},
+ {'o', "OUTPUTVOLTS", "Output voltage on batts", 'i', &eeprom_ups.NomOutputVoltage},
+- {'s', "SENSITIVITY", "Sensitivity", 'c', (int *)eeprom_ups.sensitivity},
++ {'s', "SENSITIVITY", "Sensitivity", 'c', eeprom_ups.sensitivity},
+ {'q', "LOWBATT", "Low battery warning", 'i', &eeprom_ups.dlowbatt},
+ {'p', "SLEEP", "Shutdown grace delay", 'i', &eeprom_ups.dshutd},
+- {'k', "BEEPSTATE", "Alarm delay", 'c', (int *)eeprom_ups.beepstate},
++ {'k', "BEEPSTATE", "Alarm delay", 'c', eeprom_ups.beepstate},
+ {'r', "WAKEUP", "Wakeup delay", 'i', &eeprom_ups.dwake},
+- {'E', "SELFTEST", "Self test interval", 'c', (int *)eeprom_ups.selftest},
++ {'E', "SELFTEST", "Self test interval", 'c', eeprom_ups.selftest},
+ {0, NULL, NULL} /* Last entry */
+ };
+
+@@ -2240,9 +2240,9 @@ static void print_valid_eeprom_values(UP
+ for (j = 0; cmd_table[j].cmd; j++) {
+ if (cmd[i].cmd == cmd_table[j].cmd) {
+ if (cmd_table[j].type == 'c')
+- asnprintf(val, sizeof(val), "%s", (char *)cmd_table[j].data);
++ asnprintf(val, sizeof(val), "%s", cmd_table[j].data);
+ else
+- asnprintf(val, sizeof(val), "%d", *cmd_table[j].data);
++ asnprintf(val, sizeof(val), "%d", *((int*)cmd_table[j].data));
+
+ pmsg("%-24s %-12s %-6s ", cmd_table[j].descript,
+ cmd_table[j].config_directive, val);
diff --git a/sys-power/apcupsd/files/apcupsd-udev.rules b/sys-power/apcupsd/files/apcupsd-udev.rules
new file mode 100644
index 00000000..b2eeb273
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd-udev.rules
@@ -0,0 +1,10 @@
+# do not edit this file, it will be overwritten on update
+
+ACTION!="add", GOTO="apcupsd_end"
+SUBSYSTEM!="usb", GOTO="apcupsd_end"
+ENV{ID_VENDOR}=="", IMPORT{program}="usb_id --export %p"
+ENV{ID_VENDOR_ID}!="051d", GOTO="apcupsd_end"
+
+KERNEL=="?*", SYMLINK+="apcups/by-id/$env{ID_BUS}-$env{ID_SERIAL_SHORT}"
+
+LABEL="apcupsd_end"
diff --git a/sys-power/apcupsd/files/apcupsd.init.2a b/sys-power/apcupsd/files/apcupsd.init.2a
new file mode 100644
index 00000000..f82c9d12
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd.init.2a
@@ -0,0 +1,37 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/apcupsd/files/apcupsd.init.2a,v 1.1 2011/08/29 13:38:55 flameeyes Exp $
+
+INSTANCE="${SVCNAME#*.}"
+if [ -z "${INSTANCE}" ] || [ "${SVCNAME}" = "apcupsd" ]; then
+ INSTANCE="apcupsd"
+fi
+
+depend() {
+ use net
+}
+
+start() {
+ rm -f /etc/apcupsd/powerfail
+
+ export SERVICE="${SVCNAME}"
+
+ ebegin "Starting APC UPS daemon"
+ start-stop-daemon \
+ --start --pidfile "/var/run/${SVCNAME}.pid" \
+ --exec /sbin/apcupsd -- \
+ -f "/etc/apcupsd/${INSTANCE}.conf" \
+ -P "/var/run/${SVCNAME}.pid"
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping APC UPS daemon"
+ start-stop-daemon \
+ --stop --pidfile "/var/run/${SVCNAME}.pid" \
+ --retry TERM/5/TERM/5 \
+ --exec /sbin/apcupsd
+ eend $?
+}
+
diff --git a/sys-power/apcupsd/files/apcupsd.init.3 b/sys-power/apcupsd/files/apcupsd.init.3
new file mode 100644
index 00000000..52787612
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd.init.3
@@ -0,0 +1,28 @@
+#!/sbin/runscript
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/apcupsd/files/apcupsd.init.3,v 1.1 2011/10/21 22:06:43 flameeyes Exp $
+
+INSTANCE="${SVCNAME#*.}"
+if [ -z "${INSTANCE}" -o "${SVCNAME}" = "apcupsd" ]; then
+ INSTANCE="apcupsd"
+fi
+
+name="APC UPS Daemon"
+
+pidfile=/var/run/${SVCNAME}.pid
+
+command=/sbin/apcupsd
+command_args="-f /etc/apcupsd/${INSTANCE}.conf -P ${pidfile}"
+start_stop_daemon_args="--wait 300 --retry TERM/5/TERM/5"
+
+depend() {
+ use net
+ after udev
+}
+
+start_pre() {
+ rm -f /etc/apcupsd/powerfail
+
+ export SERVICE="${SVCNAME}"
+}
diff --git a/sys-power/apcupsd/files/apcupsd.powerfail.init b/sys-power/apcupsd/files/apcupsd.powerfail.init
new file mode 100644
index 00000000..49c5db45
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd.powerfail.init
@@ -0,0 +1,18 @@
+#!/sbin/runscript
+# Copyright 2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-power/apcupsd/files/apcupsd.powerfail.init,v 1.2 2009/03/22 15:22:28 flameeyes Exp $
+
+description='Signal the UPS to kill power in a power failure condition'
+
+depend() {
+ need mount-ro
+}
+
+start() {
+ if [ "$(runlevel | cut -d' ' -f2)" = "0" -a -f /etc/apcupsd/powerfail ] ; then
+ ebegin 'Signaling UPS to kill power'
+ /sbin/apcupsd --killpower
+ eend $?
+ fi
+}