Files

72 lines
2.7 KiB
Markdown

# NUT on OpenMediaVault 6 (openmediavault-nut plugin)
For hosts where NUT is managed by the OMV plugin `openmediavault-nut`
(6.0.x, NUT 2.7.4 on Debian 11). Do **not** use the install scripts from
`bluewalker-vfi-icr/` here: OMV regenerates `/etc/nut/*` on every deploy and
overwrites hand-made files.
First deployment: DaKa NAS (80005), Eaton 3S 550 via USB (`usbhid-ups`,
subdriver `MGE HID`), standalone mode. Host notes in
`it-wartung/hosts/80005-nas.md`.
## Settings in the OMV web UI
Services -> UPS: enable, mode `standalone`, identifier `ups`,
driver config:
```
driver = usbhid-ups
port = auto
```
Shutdown mode `onbatt`, timer 300 s (shut down after 5 minutes on battery,
LOWBATT shuts down earlier anyway).
## Plugin bugs and the fix
1. **Random passwords break upsmon.** Without an override the plugin
generates the `monmaster`/`admin` passwords with `random.get_str(16)`,
which includes `#` and `'`. NUT 2.7.4 treats `#` as a comment, the
`MONITOR` line loses fields and `nut-monitor` dies with
"Unable to use old-style MONITOR line without a username". Every save in
the web UI rolls the dice again.
2. **DEADTIME 555.** The template multiplies the string `'5'` by 3.
Fix: fixed alphanumeric values in `/etc/default/openmediavault`, then
rebuild the pillar and deploy:
```
gen(){ tr -dc A-Za-z0-9 </dev/urandom | head -c 24; }
echo "OMV_NUT_UPSDUSERS_MONITOR_PASSWORD=\"$(gen)\"" >> /etc/default/openmediavault
echo "OMV_NUT_UPSDUSERS_ADMIN_PASSWORD=\"$(gen)\"" >> /etc/default/openmediavault
echo 'OMV_NUT_UPSMON_DEADTIME="15"' >> /etc/default/openmediavault
omv-salt stage run prepare # rewrites /srv/pillar/omv/default.sls
omv-salt deploy run nut
```
`omv-salt stage run prepare` is required: the pillar file is only rebuilt
by that stage, `deploy run` alone keeps the old values and the plugin
silently falls back to a new random password.
## Check
```
systemctl is-active nut-driver nut-server nut-monitor # 3x active
upsc -c ups@localhost # lists 127.0.0.1 = upsmon is logged in
upsc ups@localhost ups.status # OL = on line
grep -E '^(MONITOR|DEADTIME)' /etc/nut/upsmon.conf
```
PID-file warnings from `nut-monitor` ("Can't open PID file ... Operation
not permitted") are cosmetic on Debian's NUT 2.7.4.
## Behaviour on power loss
- ONBATT -> upssched timer 300 s -> `upsmon -c fsd` -> shutdown.
- `/lib/systemd/system-shutdown/nutshutdown` tells the UPS to cut output
after `ups.delay.shutdown` (20 s) and to restart it when mains returns.
- Whether the host then boots again depends on the BIOS/BMC power-restore
policy (`ipmitool chassis status`). For a host that should stay off,
set it to `always-off`.
- No mail notification unless OMV mail notification is configured.