From d7452d1a846d5e419f3907819f45e2e0c1cecff2 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 5 Jan 2025 01:18:36 +0100 Subject: package: Port apcupsd For USB-connected UPSs, kernel's USB_HIDDEV option is required as the daemon communicates via /dev/usb/hiddev* raw HID devices. Therefore make USB_HID select USB_HIDDEV (shouldn't hurt much on other systems) and select the former if the package is enabled. Ship a config which defaults to USB-based UPSs as they are probably the most common ones. Also install a minimal apccontrol which merely remounts relevant filesystems read-only in case of near blackout. The core OpenADK fs layout should tolerate pulling the plug as-is already. Signed-off-by: Phil Sutter --- package/apcupsd/files/apcupsd.init | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 package/apcupsd/files/apcupsd.init (limited to 'package/apcupsd/files/apcupsd.init') diff --git a/package/apcupsd/files/apcupsd.init b/package/apcupsd/files/apcupsd.init new file mode 100644 index 000000000..a9817f1be --- /dev/null +++ b/package/apcupsd/files/apcupsd.init @@ -0,0 +1,38 @@ +#!/bin/sh +#PKG apcupsd +#INIT 15 +. /etc/rc.conf + +pidfile=$(echo "$apcupsd_flags" | \ + sed -n 's/.*\(-P\|--pid-file\) \([^ ]\+\).*/\2/p') +[ "$pidfile" ] || pidfile="/var/run/apcupsd.pid" + +case $1 in +autostop) ;; +autostart) + test x"${apcupsd:-NO}" = x"NO" && exit 0 + test x"$apcupsd" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start + exec sh $0 start + ;; +start) + mkdir -p /var/lock + /usr/sbin/apcupsd $apcupsd_flags + ;; +stop) + if [ -f "$pidfile" ]; then + kill $(<$pidfile) + rm -f $pidfile + else + kill $(pgrep -f /usr/sbin/apcupsd) + fi + ;; +restart) + sh $0 stop + sleep 1 + sh $0 start + ;; +*) + echo "usage: $0 (start | stop | restart)" + exit 1 +esac +exit $? -- cgit v1.2.3