Skip to content

Commit

Permalink
apcupsd: add powerfail logic at shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
basploeger committed Nov 21, 2024
1 parent 02cf800 commit a2d8ad6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
9 changes: 9 additions & 0 deletions srcpkgs/apcupsd/files/apcupsd-powerfail.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
PWRFAILDIR=$( grep -e ^PWRFAILDIR /etc/apcupsd/apcupsd.conf | cut -d ' ' -f 2 )
PWRFAILDIR=${PWRFAILDIR:=/etc/apcupsd}

if [ -f "${PWRFAILDIR}/powerfail" ]; then
echo
echo "APCUPSD will now power off the UPS"
echo
/etc/apcupsd/apccontrol killpower
fi
7 changes: 6 additions & 1 deletion srcpkgs/apcupsd/files/apcupsd/run
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh
exec 2>&1
[ -r conf] && . ./conf

PWRFAILDIR=$( grep -e ^PWRFAILDIR /etc/apcupsd/apcupsd.conf | cut -d ' ' -f 2 )
PWRFAILDIR=${PWRFAILDIR:=/etc/apcupsd}
rm -f "${PWRFAILDIR}/powerfail"

[ -r conf ] && . ./conf
exec apcupsd -b ${OPTS}
3 changes: 2 additions & 1 deletion srcpkgs/apcupsd/template
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
}

0 comments on commit a2d8ad6

Please sign in to comment.