Include more inline comments to document the nut-server initscript and
usb hotplug.
Also trim an extraneous space in a comment.
Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
A previous PR missed updating the hotplug scripts for the
new find_runas and find_statepath functions which emit
the value on stdout instead of setting a variable in the
caller's scope. Update that usage and handle error conditions.
Also ensure we fully handle finding the group of the RUNAS user for
the serial usb hotplug case, and handle error conditions for that.
Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
The match against known device was badly formatted, and was
not being used as a result. Fix that.
Also, completely ignore events which are incomplete for our purposes
(that is, which are missing ACTION or DEVNAME).
Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
On boot, hotplug events were causing excessive start and stop action
for the upsd daemon and driver daemons. We fix that with two primary
actions:
1. Don't restart service daemons on hotplug until after first boot
has completed.
2. Use more robust handling of procd instance starts by ensuring
that the first start starts the nut-server service and all
others add to the nut-server service (rather than replacing it).
Ignore hotplug events without a DEVNAME.
In addition clean up some logging.
In the process, this fixes#30375 "hotplugging for setting usb access
right[s] doesn't work anymore"
Closes: #30375
Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
Short-circuit not applicable portions of hotplug script on remove, and
make sure we ignore events with incomplete information (no DEVNAME
or no ACTION).
Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
NUT (upstream) logging has changed. With the introduction of
NUT_DEBUG_SYSLOG we can set it to "stderr" and have NUT's messages
go to stderr only.
This avoid most duplicate messages when procd sends stderr to syslog.
The reverse (syslog only from NUT) is not a current configuration
option. See the section for NUT_DEBUG_SYSLOG at
https://networkupstools.org/docs/man/nut.conf.html#_directives
This is needed because we use '-FF' so that the daemons remain in the
foreground, which is required for procd to manage them. When using
'-FF' logging behaves differently in NUT than when backgrounded.
Unfortunately, there is still some work to be done upstream to
completely eliminate duplicate messages, so some message continue to
appear twice, though not neccessarily with the same facility.priority.
See also
https://github.com/jimklimov/nut/blob/0c3eed09b89cce1e5c0c65ca03d05b4612371cb8/UPGRADING.adoc#changes-from-282-to-283
and
https://github.com/openwrt/packages/pull/29896#issuecomment-5012737643
Conversely, the log messages the initscripts emit are now configured to
emit only to syslog and not to stderr. This avoids duplicates messages
caused by procd's automatic (not configurable) behaviour of sending
the initscript's stderr to syslog, while preserving the syslogid,
facility and priority we want.
Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>
The scripts were a mess. Attempting even a simple update caused many
Copilot complaints. So we rewrite the scripts to be cleaner and
resolve the issues found by automated code review (such as Copilot).
Made extensive use of Qwen3.6-27B, LATE, and llama.ccp for local AI
code reviews during development.
In the process we deduplicate the nut-server and nut-monitor
initscripts and split them into several files, for easier automatic
and human review.
Incorporates and supersedes: #28308
Should supersede #21014Closes: #28298
Signed-off-by: Daniel F. Dickinson <dfdpublic@wildtechgarden.ca>