summaryrefslogtreecommitdiff
path: root/sys-power/apcupsd
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2021-04-28 20:21:43 +0100
committerV3n3RiX <venerix@redcorelinux.org>2021-04-28 20:21:43 +0100
commit40aaaa64e86ba6710bbeb31c4615a6ce80e75e11 (patch)
tree758c221bad35c9288d0bd6df9c7dfc226728e52c /sys-power/apcupsd
parent8d5dbd847cbc704a6a06405856e94b461011afe3 (diff)
gentoo resync : 28.04.2021
Diffstat (limited to 'sys-power/apcupsd')
-rw-r--r--sys-power/apcupsd/Manifest9
-rw-r--r--sys-power/apcupsd/apcupsd-3.14.14-r3.ebuild (renamed from sys-power/apcupsd/apcupsd-3.14.13.ebuild)74
-rw-r--r--sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch50
-rw-r--r--sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch15
-rw-r--r--sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch15
-rw-r--r--sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch33
-rw-r--r--sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch20
-rw-r--r--sys-power/apcupsd/files/apcupsd.init28
8 files changed, 211 insertions, 33 deletions
diff --git a/sys-power/apcupsd/Manifest b/sys-power/apcupsd/Manifest
index 7ae8f0d745de..e767ac0c9ff1 100644
--- a/sys-power/apcupsd/Manifest
+++ b/sys-power/apcupsd/Manifest
@@ -1,12 +1,17 @@
AUX apcupsd-3.14.9-aliasing.patch 2108 BLAKE2B b6ce1e6e3e40b6d533a08d5fac633e7c3d81574b2b2fd9c442a10eac8e507abfa73ddf3dc74ac9fc4d8bbd9c7da3f7d9eb5194f6df959dbe792d5b103d88844c SHA512 48eb51385136216d1cdddb6b237b89a52c516b223aa7fe50fb35761cd595d9ab7f7fabbd0e4f8c0f7d45df6feed0a2e240d227181f3d772fc5fa9f8bfa62529f
+AUX apcupsd-3.14.9-close-on-exec.patch 1700 BLAKE2B 33bc681a008c98a6659a832359d3906bfe153db7cf3fbb0dbf442dc60e97c41dd0680eb5674592c835a28731f1fb361a20f2f5acae88f84142781153fba5ca66 SHA512 5f348efc11f35538fc9810d9026b2f8eeeadf5675ca1bf2275f704310a654266e5e79e393a59e6c25171a94f5d0b1d9e74b45a1511c4289242379f6f4e30888b
+AUX apcupsd-3.14.9-commfailure.patch 519 BLAKE2B 58763a637f44ad3e506b1f8da73027353d05bbcab6a3a108d39c4d189682a8185d89960e46eb760b7f5781115b266ff0c5ebb902a1307634faed0639c7b4ceb9 SHA512 856063b915ccd583abbef4347e01a8a5f71f7853efbfeb62d2edfee1acd14030e34373c420d5fdd58bc47ce03e79b55dd4a5ee6486c8dee984e8f272257af673
+AUX apcupsd-3.14.9-fix-nologin.patch 529 BLAKE2B 6d3f6c735d88808056a73620c92e5f219cda2501714dc4566e6ccc9b36e4ef6a28da97d4938dd0174f8c7769afe71c2937fdfe0b9bf46d5f1172307f84d22a7f SHA512 50c614aeaa2118cc5745f34ec86aada0eaf41af4b6616717b7d5637aa84710fd078950a149fb0bf3a68107619125ea0c74ea6f8fa937338a662c7ee31804fbab
+AUX apcupsd-3.14.9-gapcmon.patch 1213 BLAKE2B ecc9798a010cb60beb9bacd93b1223b2d8f0c7f5739b2237bd7bdc10182c4973944bc49a34c7a3060c164965524f19e2fbe40a042df8e6c7e77001874b396ab1 SHA512 5cb0eeb7449c16bd820f17ff64895f6e7beaa7f2af66376fbe5450e9ef803138f5248f43232bc7753b72ca7c650ca177b0227ce79d4002383f19d0174adbe542
+AUX apcupsd-3.14.9-wall-on-mounted-usr.patch 815 BLAKE2B dcc4e89328b0d5afc8d33555cc5c9b9a5ea06e74d80ffc761506f0435b65b4174ce9e4873344e7a1838f3a11d69eb9f7286b189f0cc67e7c21ae66db1baa7aca SHA512 00a3a01f3afdb1755c65ebc9832778bd3a7bfeab115531a1282668ba5340fd081eeaa263264a6510722ac4726e5d84961089c6c0305d0a6f7d1cf9e4de80be00
AUX apcupsd-tmpfiles.conf 70 BLAKE2B 6bc5fdff60918a5ccb616e28cc3832053938accd47a75aa29c3e569808c59ee35d618f385022309ab8eb2f714b5d87d6c752547447d896b7537b30b8dfc262ed SHA512 c63242a06cc14242575c24a8aca4ea35a7150e6073425c8230e36c7117a1bc49dc659dbb0c455ddc454a0ac5ebd7faa5638fb70282c38ed5d1ca9ffab700ef05
AUX apcupsd-udev.rules 328 BLAKE2B be1a8ff2eb09c045137ab2f1e48d3caa5ea9df85f766da5f9ae04786895631503d986cb184c74fd92aa6c229d34fedeab0a61dc5cad4a8fba1a799ade3f01081 SHA512 ba2ebb9f28011548c845a81f17a328b98ec8d79c1e6be33aeab863d77b9d3aa61b4dfbd1bb89a0cae00465387dffe8cc223634a6e9a2f59170846d4bed9e7135
AUX apcupsd.conf 12475 BLAKE2B c7695035887fa4fa867b2588f2ed0e2fee6c6a0086c221fec3019e3de639202287e9a35082334b8801cda38c846a0bcac714b046b1ddc1297f764bb211e42fb9 SHA512 1519d3cd47a2a73ff4148e4f74964ae841d37639616fe5b974b426983f5379db89b8793a6952389c443c56b84d0ef33f6995eccd920f71b4e5efc842a58a04e1
+AUX apcupsd.init 804 BLAKE2B 7afd83a6be8b068133f6221cc2396a1fe4cab23f6dec68957b48ef7940730908e7a20e1597a21480eeffdb79314fd02505d4bafdd0b7a6bd1ff2b7c452f847ef SHA512 dd7fcc52b495c3f73bc9b2fe73bbb7c8fe3ec959ea733360d370148d617d98f34de3b48f1cb451f9a8356eb8088b06d3c736bd6cbad2bb5e9e609e37d5f2c53c
AUX apcupsd.init.4 926 BLAKE2B a698aa40ebab7bb14f6efd05f8d1300f95e81d18aa74d2d8daa35629803f8758a56ec4f6f79f27ccc3aec9d54a53a7326f5afe72b9972de90387b751c7ca21b2 SHA512 b31d054252d0caeaeee4b3e0d7d9d0f5c1d0ad32a08f952f57fe91a36964d6a895ff26bb5514820cc8e83b7e87df1b0c508c3ae35c39f43d2be2e1cd66ef705e
AUX apcupsd.powerfail.init 397 BLAKE2B 472512906536753d3054d275707764a98094c14866da63fbc8d2d62e16a9099fdce0b61cf572a4ba862f0be13e1ed3407821ed07ec90f9c77fb8d95f18aafc2f SHA512 cd0ed9d24a8371de7920bf0ce2e89bb63c0bee58da1ac782ed2b929068f95b2af47458529223a33ecea4e8f73ddfe3a7b9591af6f64828de7ed1d91e2edbb6e1
AUX apcupsd.service 111 BLAKE2B bf2ac8161af5b971642298c30b08ad78d289044bb2452bdef39b31119b60eceb0a14add7c00262132bb80dbf1964103242452cb8d9b815d6ec82c204100ea184 SHA512 011e3e52e7909f36fb73b6064277a69e5db41263cfc72bda07e326172396d5318cd2b050f1fb84c4cc6da7a247c0035c36c55322ffb234a1cfa7bf13ba492889
-DIST apcupsd-3.14.13.tar.gz 1935043 BLAKE2B 56d8fb9c6a055b20c2d99867e43b6a2d6ebe1d55c724d8a6701d9baa569a14f600cb03c6176380c6c42c46ac610f43136a4b52c47c8b86bc41966d4091481e95 SHA512 74f7763de268626e24f9dd99090b01d5bff35c2fde769039104105ec27941673d1613c41fcac11e3d97d2fe5c364bcc0459847fcba5d2f7f1aac85795d6d8570
DIST apcupsd-3.14.14.tar.gz 1843409 BLAKE2B 48a3b249780064d699d86b658584aa222ce9f3b46a81209110b4684bf737cca7492b87b063154864ce76478f29f73cda83ab96b47f4a7aa7aa91e29a8abbf4a8 SHA512 c953bbf3e08f809748a7978a3952604176390d1cd276f187fe096d9bc3c8993b52127e8350c0363387da41318e24b4d1e00ea58df71f3bb8f50c9a5a64cd2d7f
-EBUILD apcupsd-3.14.13.ebuild 3924 BLAKE2B 85dfef3e437613485b35d62f6987340d9dbeff63f0da334fae429e629e137e7648c3138f669e22f6a0975acac07d8d6517c75830835abbfe91a4cd6d41bdc7c5 SHA512 5197db78dd4be02b5e8ea8316d69e06fd065d2b43900be364faaf363712897888dcf5b8315c13d6d37fd1ba9f91ac7ce2f4625f99eab3183ba9f3233bb2fb8f1
EBUILD apcupsd-3.14.14-r2.ebuild 4042 BLAKE2B 3c71cb4717d389d1d6ff192c9654df79c515efde571b62e7a58bbf3dcd270220fba0611cc85f258255d95f989006c9a3521e62030b9fe2780aa48ca344c03bdb SHA512 864ed6f867c2f289318bd7ac8a1f123758bedf76f729c5304d84cf4a56e46313dc83054e2081e18e8a71a303e9da68d1e239e13b61e1b092d6e40a28c3ea6c09
+EBUILD apcupsd-3.14.14-r3.ebuild 4309 BLAKE2B 8951b63af6533640e2182e17138f578f55ed6b2481cf392a55a430ff4b4ee66ed5c21fd4ef183885bbb1371eb97b2169bcf4af4280fc72c9472f47c5b5e912d9 SHA512 d0257f7e2d11f3eabc89bac089bf0c85e783022310b774486ddd7ef44fc1a02544d95ed3427d88e72296042c2236b979b5c828c99a182362917c006a8828f977
MISC metadata.xml 1161 BLAKE2B 6ea52dc98c841f0f6e018f74addd11054ddedc635d0f153f5f629b6949eebc0833d3c5a7e27a584a0344dc48319de2cf85d0304dd03ba77927244654713a2488 SHA512 384db8369118c9d430e4baea4d65bef498ec4f198e0379581eac77f081fb34705ce5171fec4753beeaa5ae3c153fe98a91dbebbd04ce5c671172c7ba28d30dfe
diff --git a/sys-power/apcupsd/apcupsd-3.14.13.ebuild b/sys-power/apcupsd/apcupsd-3.14.14-r3.ebuild
index b3489084c867..12e0b16bcc7e 100644
--- a/sys-power/apcupsd/apcupsd-3.14.13.ebuild
+++ b/sys-power/apcupsd/apcupsd-3.14.14-r3.ebuild
@@ -1,9 +1,9 @@
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI=5
+EAPI="7"
-inherit eutils linux-info flag-o-matic systemd udev tmpfiles
+inherit linux-info flag-o-matic systemd udev tmpfiles
DESCRIPTION="APC UPS daemon with integrated tcp/ip remote shutdown"
HOMEPAGE="http://www.apcupsd.org/"
@@ -11,42 +11,55 @@ SRC_URI="mirror://sourceforge/apcupsd/${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
-KEYWORDS="amd64 ~arm ppc x86"
-IUSE="snmp +usb cgi nls gnome kernel_linux"
+KEYWORDS="~amd64 ~arm ~ppc ~x86"
+IUSE="snmp +usb +modbus cgi gnome kernel_linux"
-DEPEND="
- >=sys-apps/util-linux-2.23[tty-helpers(-)]
+DEPEND=">=sys-apps/util-linux-2.23[tty-helpers(-)]
cgi? ( >=media-libs/gd-1.8.4 )
- nls? ( sys-devel/gettext )
- snmp? ( >=net-analyzer/net-snmp-5.7.2 )
- gnome? ( >=x11-libs/gtk+-2.4.0:2
+ modbus? ( usb? ( virtual/libusb:0 ) )
+ gnome? (
+ >=x11-libs/gtk+-2.4.0:2
dev-libs/glib:2
- >=gnome-base/gconf-2.0 )"
+ >=gnome-base/gconf-2.0
+ )
+ snmp? ( >=net-analyzer/net-snmp-5.7.2 )"
+
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"
+DOCS=( ChangeLog ReleaseNotes )
+HTML_DOCS=( doc/manual )
+
+PATCHES=(
+ "${FILESDIR}"/${PN}-3.14.9-aliasing.patch
+ "${FILESDIR}"/${PN}-3.14.9-close-on-exec.patch
+ "${FILESDIR}"/${PN}-3.14.9-commfailure.patch
+ "${FILESDIR}"/${PN}-3.14.9-fix-nologin.patch
+ "${FILESDIR}"/${PN}-3.14.9-gapcmon.patch
+ "${FILESDIR}"/${PN}-3.14.9-wall-on-mounted-usr.patch
+)
+
pkg_setup() {
- if use kernel_linux && use usb && linux_config_exists; then
+ if use kernel_linux && use usb && linux_config_exists ; then
check_extra_config
fi
}
-src_prepare() {
- epatch "${FILESDIR}/${PN}-3.14.9-aliasing.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= "
+
+ if use usb ; then
+ myconf="${myconf} --with-upstype=usb --with-upscable=usb --enable-usb --with-dev="
+ use modbus && myconf="${myconf} --enable-modbus-usb"
else
myconf="${myconf} --with-upstype=apcsmart --with-upscable=smart --disable-usb"
+ use modbus || myconf="${myconf} --disable-modbus"
fi
# We force the DISTNAME to gentoo so it will use gentoo's layout also
@@ -61,10 +74,10 @@ src_configure() {
--with-nis-port=3551 \
--enable-net --enable-pcnet \
--with-distname=gentoo \
- $(use_enable snmp net-snmp) \
+ $(use_enable snmp) \
$(use_enable gnome gapcmon) \
${myconf} \
- APCUPSD_MAIL=/bin/mail
+ APCUPSD_MAIL=$(type -p mail)
}
src_compile() {
@@ -72,34 +85,33 @@ src_compile() {
# the text files in the distribution, but I wouldn't count on them
# doing that anytime soon.
MANPAGER=$(type -p cat) \
- emake
+ emake VERBOSE=2
}
src_install() {
- emake DESTDIR="${D}" install
- rm -f "${D}"/etc/init.d/halt
+ emake DESTDIR="${D}" VERBOSE=2 install
+ rm "${ED}"/etc/init.d/halt || die
insinto /etc/apcupsd
newins examples/safe.apccontrol safe.apccontrol
doins "${FILESDIR}"/apcupsd.conf
- dodoc ChangeLog* ReleaseNotes
doman doc/*.8 doc/*.5
- dohtml -r doc/manual/*
+ einstalldocs
- rm "${D}"/etc/init.d/apcupsd
- newinitd "${FILESDIR}/${PN}.init.4" "${PN}"
+ rm "${ED}"/etc/init.d/apcupsd || die
+ newinitd "${FILESDIR}/${PN}.init" "${PN}"
newinitd "${FILESDIR}/${PN}.powerfail.init" "${PN}".powerfail
systemd_dounit "${FILESDIR}"/${PN}.service
dotmpfiles "${FILESDIR}"/${PN}-tmpfiles.conf
- # remove hal settings, we don't really want to have it around still.
- rm -r "${D}"/usr/share/hal
+ # remove hal settings, we don't really want to have it still around.
+ rm -r "${D}"/usr/share/hal || die
# replace it with our udev rules if we're in Linux
- if use kernel_linux; then
+ if use kernel_linux ; then
udev_newrules "${FILESDIR}"/apcupsd-udev.rules 60-${PN}.rules
fi
@@ -108,7 +120,7 @@ src_install() {
pkg_postinst() {
tmpfiles_process ${PN}-tmpfiles.conf
- if use cgi; then
+ 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
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch
new file mode 100644
index 000000000000..aeaa78b35420
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-close-on-exec.patch
@@ -0,0 +1,50 @@
+Close the socket on exec - avoid leaked file descriptors, patch from Fedora
+
+--- a/src/apcnis.c
++++ b/src/apcnis.c
+@@ -157,6 +157,9 @@ void do_server(UPSINFO *ups)
+ sleep(5 * 60);
+ }
+
++ /* Close the socket on exec - avoid leaked file descriptors */
++ fcntl(sockfd, F_SETFD, FD_CLOEXEC);
++
+ /* Reuse old sockets */
+ #ifndef HAVE_MINGW
+ if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (void*)&turnon, sizeof(turnon)) < 0) {
+--- a/src/apcupsd.c
++++ b/src/apcupsd.c
+@@ -212,6 +212,9 @@ int main(int argc, char *argv[])
+ if (ups->event_fd < 0) {
+ log_event(ups, LOG_WARNING, "Could not open events file %s: %s\n",
+ ups->eventfile, strerror(errno));
++ } else {
++ /* Close the file on exec - avoid leaked file descriptors */
++ fcntl(ups->event_fd, F_SETFD, FD_CLOEXEC);
+ }
+ }
+
+--- a/src/drivers/usb/linux/linux-usb.c
++++ b/src/drivers/usb/linux/linux-usb.c
+@@ -246,8 +246,11 @@ bool LinuxUsbUpsDriver::open_usb_device()
+ /* Retry 10 times */
+ for (i = 0; i < 10; i++) {
+ _fd = open_device(_ups->device);
+- if (_fd != -1)
++ if (_fd != -1) {
++ /* Close the device on exec - avoid leaked file descriptors */
++ fcntl(_fd, F_SETFD, FD_CLOEXEC);
+ return true;
++ }
+ sleep(1);
+ }
+
+@@ -270,6 +273,7 @@ auto_detect:
+ asnprintf(devname, sizeof(devname), "%s%d", hiddev[j], k);
+ _fd = open_device(devname);
+ if (_fd != -1) {
++ fcntl(_fd, F_SETFD, FD_CLOEXEC);
+ /* Successful open, save device name and return */
+ strlcpy(_ups->device, devname, sizeof(_ups->device));
+ return true;
+
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch
new file mode 100644
index 000000000000..49641c06bef3
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-commfailure.patch
@@ -0,0 +1,15 @@
+Author: Tero Janka <tero.janka@mbnet.fi>
+Description: apcaccess call blocking commfailure mails (Closes: #409734).
+
+Index: apcupsd/platforms/etc/commfailure.in
+===================================================================
+--- apcupsd.orig/platforms/etc/commfailure.in
++++ apcupsd/platforms/etc/commfailure.in
+@@ -13,7 +13,5 @@ MSG="$HOSTNAME Communications with UPS $
+ echo "Subject: $MSG"
+ echo " "
+ echo "$MSG"
+- echo " "
+- @sbindir@/apcaccess status
+ ) | $APCUPSD_MAIL -s "$MSG" $SYSADMIN
+ exit 0
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch
new file mode 100644
index 000000000000..75f9e4449bf5
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-fix-nologin.patch
@@ -0,0 +1,15 @@
+Description: only prohibit logins on shutdown if login is allowed at all
+Index: apcupsd-3.14.12/src/action.c
+===================================================================
+--- apcupsd-3.14.12.orig/src/action.c
++++ apcupsd-3.14.12/src/action.c
+@@ -208,7 +208,8 @@ static void do_shutdown(UPSINFO *ups, in
+ delete_lockfile(ups);
+ ups->set_fastpoll();
+ make_file(ups, ups->pwrfailpath);
+- prohibit_logins(ups);
++ if (ups->nologin.type != NEVER)
++ prohibit_logins(ups);
+
+ if (!ups->is_slave()) {
+ /*
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch
new file mode 100644
index 000000000000..0dd1cc69aa35
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-gapcmon.patch
@@ -0,0 +1,33 @@
+Description: take care of some deprecated functions and format issue
+Author: Thorsten Alteholz <debian@alteholz.de>
+Index: apcupsd-3.14.14/src/gapcmon/gapcmon.c
+===================================================================
+--- apcupsd-3.14.14.orig/src/gapcmon/gapcmon.c 2016-07-16 03:04:22.000000000 +0200
++++ apcupsd-3.14.14/src/gapcmon/gapcmon.c 2017-10-06 09:26:40.412004149 +0200
+@@ -1580,7 +1580,7 @@
+ scaled = gdk_pixbuf_scale_simple(pixbuf, size, size, GDK_INTERP_BILINEAR);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(pm->tray_image), scaled);
+ gtk_widget_show(pm->tray_image);
+- gdk_pixbuf_unref(scaled);
++ g_object_unref(scaled);
+ }
+
+ if (pm->window != NULL)
+@@ -2889,7 +2889,7 @@
+
+ pch = g_strdup_printf("%s(%s) emsg=%s", pch_func, pch_topic, pch_emsg);
+
+- g_message(pch);
++ g_message("%s",pch);
+
+ g_free(pch);
+
+@@ -4474,7 +4474,7 @@
+ gtk_image_set_from_pixbuf(GTK_IMAGE(image), scaled);
+ gtk_box_pack_start(GTK_BOX(hbox), image, TRUE, TRUE, 0);
+ gtk_widget_show(image);
+- gdk_pixbuf_unref(scaled);
++ g_object_unref(scaled);
+
+ label = gtk_label_new(about_text);
+ gtk_label_set_use_markup(GTK_LABEL(label), TRUE);
diff --git a/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch b/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch
new file mode 100644
index 000000000000..b89a5309e5ba
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd-3.14.9-wall-on-mounted-usr.patch
@@ -0,0 +1,20 @@
+At halt/killpower time, /usr may already be umounted, and wall
+lives in /usr. Avoid failing by using cat if needed.
+
+Index: apcupsd/platforms/apccontrol.in
+===================================================================
+--- apcupsd.orig/platforms/apccontrol.in
++++ apcupsd/platforms/apccontrol.in
+@@ -62,10 +62,10 @@ fi
+
+ case "$1" in
+ killpower)
+- echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
++ echo "Apccontrol doing: ${APCUPSD} --killpower on UPS ${2}" | (${WALL} 2>/dev/null || cat)
+ sleep 10
+ ${APCUPSD} --killpower
+- echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | ${WALL}
++ echo "Apccontrol has done: ${APCUPSD} --killpower on UPS ${2}" | (${WALL} 2>/dev/null || cat)
+ ;;
+ commfailure)
+ echo "Warning communications lost with UPS ${2}" | ${WALL}
diff --git a/sys-power/apcupsd/files/apcupsd.init b/sys-power/apcupsd/files/apcupsd.init
new file mode 100644
index 000000000000..e544fd4f3900
--- /dev/null
+++ b/sys-power/apcupsd/files/apcupsd.init
@@ -0,0 +1,28 @@
+#!/sbin/openrc-run
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+: ${APCUPSD_CONFIGFILE:=/etc/apcupsd/${SVCNAME#*.}.conf}
+: ${APCUPSD_POWERFAILFILE:=/etc/apcupsd/powerfail}
+: ${APCUPSD_PIDFILE:=/run/${SVCNAME}.pid}
+: ${APCUPSD_SSDARGS:=--wait 1000}
+: ${APCUPSD_TERMTIMEOUT:=TERM/60/KILL/5}
+
+command="/sbin/apcupsd"
+command_args="${APCUPSD_OPTS} --config-file \"${APCUPSD_CONFIGFILE}\" --pid-file \"${APCUPSD_PIDFILE}\""
+pidfile="${APCUPSD_PIDFILE}"
+retry="${APCUPSD_TERMTIMEOUT}"
+start_stop_daemon_args="${APCUPSD_SSDARGS}"
+required_files="${APCUPSD_CONFIGFILE}"
+
+depend() {
+ use dns
+}
+
+start_pre() {
+ if [ -e "${APCUPSD_POWERFAILFILE}" ] ; then
+ ebegin "Removing stale ${APCUPSD_POWERFAILFILE}"
+ rm "${APCUPSD_POWERFAILFILE}"
+ eend $?
+ fi
+}