From f20aba9f971d70c148fb787f551a8abb2229c864 Mon Sep 17 00:00:00 2001 From: Bas Ploeger Date: Sat, 2 Apr 2022 22:00:49 +0200 Subject: [PATCH] apcupsd: add powerfail logic at shutdown This implements the behavior described in the upstream documentation: https://web.archive.org/web/20230206010908/http://www.apcupsd.org/manual/manual.html#verifying-a-source-installation Also patch the doc/Makefile to not generate *.man.txt files which are only needed for the MinGW platform and depend on the deprecated `col` command. --- srcpkgs/apcupsd/files/apcupsd-powerfail.sh | 7 +++++++ srcpkgs/apcupsd/files/apcupsd/run | 7 ++++++- srcpkgs/apcupsd/patches/skip-man-txt-build.patch | 14 ++++++++++++++ srcpkgs/apcupsd/template | 3 ++- 4 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 srcpkgs/apcupsd/files/apcupsd-powerfail.sh create mode 100644 srcpkgs/apcupsd/patches/skip-man-txt-build.patch diff --git a/srcpkgs/apcupsd/files/apcupsd-powerfail.sh b/srcpkgs/apcupsd/files/apcupsd-powerfail.sh new file mode 100644 index 00000000000000..ac826dae8baa60 --- /dev/null +++ b/srcpkgs/apcupsd/files/apcupsd-powerfail.sh @@ -0,0 +1,7 @@ +PWRFAILDIR="$( awk '$1 == "PWRFAILDIR" {print $2; exit}' /etc/apcupsd/apcupsd.conf )" +PWRFAILDIR="${PWRFAILDIR:-/etc/apcupsd}" + +if [ -f "${PWRFAILDIR}/powerfail" ]; then + msg "Powering off the UPS with APCUPSD..." + /etc/apcupsd/apccontrol killpower +fi diff --git a/srcpkgs/apcupsd/files/apcupsd/run b/srcpkgs/apcupsd/files/apcupsd/run index e570f226c90a8a..c11f573cf112b9 100644 --- a/srcpkgs/apcupsd/files/apcupsd/run +++ b/srcpkgs/apcupsd/files/apcupsd/run @@ -1,4 +1,9 @@ #!/bin/sh exec 2>&1 -[ -r conf] && . ./conf + +PWRFAILDIR="$( awk '$1 == "PWRFAILDIR" {print $2; exit}' /etc/apcupsd/apcupsd.conf )" +PWRFAILDIR="${PWRFAILDIR:-/etc/apcupsd}" +rm -f "${PWRFAILDIR}/powerfail" + +[ -r conf ] && . ./conf exec apcupsd -b ${OPTS} diff --git a/srcpkgs/apcupsd/patches/skip-man-txt-build.patch b/srcpkgs/apcupsd/patches/skip-man-txt-build.patch new file mode 100644 index 00000000000000..e3820d77a2d918 --- /dev/null +++ b/srcpkgs/apcupsd/patches/skip-man-txt-build.patch @@ -0,0 +1,14 @@ +Do not generate *.man.txt files at build time. The build rule depends on the +deprecated `col` command and the files are only needed for the MinGW platform. +--- a/doc/Makefile ++++ b/doc/Makefile +@@ -3,9 +3,6 @@ + SUBDIRS = + include $(topdir)/autoconf/targets.mak + +-all-targets: apcupsd.man.txt apcaccess.man.txt apctest.man.txt \ +- apccontrol.man.txt apcupsd.conf.man.txt +- + apcupsd.man.txt: apcupsd.8 + $(call MANIFY,$<,$@) + apcaccess.man.txt: apcaccess.8 diff --git a/srcpkgs/apcupsd/template b/srcpkgs/apcupsd/template index ba1394b2d9d073..5b7c1404589fb9 100644 --- a/srcpkgs/apcupsd/template +++ b/srcpkgs/apcupsd/template @@ -1,7 +1,7 @@ # Template file for 'apcupsd' pkgname=apcupsd version=3.14.14 -revision=1 +revision=2 build_style=gnu-configure configure_args=" --disable-install-distdir @@ -37,4 +37,5 @@ post_install() { # This binary is not needed and conflicts with a binary from an other package. rm ${DESTDIR}/usr/bin/smtp vsv apcupsd + vinstall ${FILESDIR}/apcupsd-powerfail.sh 644 etc/runit/shutdown.d 89-apcupsd-powerfail.sh }