diff options
author | Phil Sutter <phil@nwl.cc> | 2025-01-05 01:18:36 +0100 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2025-01-06 11:53:44 +0100 |
commit | d7452d1a846d5e419f3907819f45e2e0c1cecff2 (patch) | |
tree | 6f6cf4dd0f6c138ba44f399388877d4fde5aff5b /package/apcupsd/files/apcupsd.init | |
parent | 8bda2592cdf86248206f150625dd065d74befef7 (diff) |
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 <phil@nwl.cc>
Diffstat (limited to 'package/apcupsd/files/apcupsd.init')
-rw-r--r-- | package/apcupsd/files/apcupsd.init | 38 |
1 files changed, 38 insertions, 0 deletions
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 $? |