Add OpenRC service and basic documentation

This commit is contained in:
2025-10-18 17:11:40 -04:00
parent 5521f79107
commit 6c1f9a2e0f
2 changed files with 22 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
# unifi-shutd
This is a simple daemon that monitors the in-built NUT server on a Ubiquiti UniFi UPS and safely shuts down the active system when the UPS switches to battery power (on AC loss).
## Usage
1. Install the `unifi-shutd` daemon to `/usr/local/bin/unifi-shutd`.
2. Install the service file for your init system (be sure to edit the arguments first!!)
- OpenRC: Save [services/openrc](https://raw.githubusercontent.com/rwinkhart/unifi-shutd/refs/heads/main/services/openrc)` to `/etc/init.d/unifi-shutd`
- systemd: Not yet implemented (feel free to contribute; I just haven't bothered because all my baremetal servers are based on Alpine Linux)
3. Enable and start the service
4. Test disconnecting your UPS from AC and ensure the service properly shuts down your server
+12
View File
@@ -0,0 +1,12 @@
#!/sbin/openrc-run
supervisor=supervise-daemon
name="UniFi UPS safe shutdown"
command="/usr/local/bin/unifi-shutd"
command_args="<ip:port> <ups id> <scan interval> <bad scan limit>"
depend() {
need net localmount
after firewall
}