<feed xmlns='http://www.w3.org/2005/Atom'>
<title>packages/net/nut/files/nut-server.init, branch master</title>
<subtitle>Mirror of packages feed</subtitle>
<id>https://git-03.infra.openwrt.org/feed/packages/atom?h=master</id>
<link rel='self' href='https://git-03.infra.openwrt.org/feed/packages/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/'/>
<updated>2026-03-03T18:53:14Z</updated>
<entry>
<title>nut: fix no permissions to use USB UPS, and more</title>
<updated>2026-03-03T18:53:14Z</updated>
<author>
<name>Daniel F. Dickinson</name>
</author>
<published>2026-02-15T03:23:12Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=072f32fee3614c98dfa93141355155ec24a25dcc'/>
<id>urn:sha1:072f32fee3614c98dfa93141355155ec24a25dcc</id>
<content type='text'>
When a USB UPS is first configured, the permissions on the device under
`/dev/bus/usb` have not yet been set to allow the nut user access. This
resulted in errors such as:

Fri Feb 13 23:39:01 2026 daemon.debug upsd[3504]: [D1] mainloop: UPS
[eco550ups] is not currently connected, trying to reconnect
Fri Feb 13 23:39:01 2026 daemon.debug upsd[3504]: [D1] mainloop: UPS
[eco550ups] is still not connected (FD -1)
Fri Feb 13 23:39:03 2026 daemon.debug upsd[3504]: [D1] mainloop: UPS
[eco550ups] is not currently connected, trying to reconnect
Fri Feb 13 23:39:03 2026 daemon.debug upsd[3504]: [D1] mainloop: UPS
[eco550ups] is still not connected (FD -1)

or

Fri Feb 13 23:38:44 2026 daemon.err usbhid-ups[3083]: No matching HID
UPS found
Fri Feb 13 23:38:49 2026 daemon.warn procd: failed adding instance
cgroup for nut-server: No error information
Fri Feb 13 23:38:49 2026 daemon.err usbhid-ups[3115]: libusb1: Could not
open any HID devices: insufficient permissions on everything
Fri Feb 13 23:38:49 2026 daemon.err usbhid-ups[3115]: No matching HID
UPS found
Fri Feb 13 23:38:54 2026 daemon.warn procd: failed adding instance
cgroup for nut-server: No error information

and upsd would enter a procd crashloop.

We fix that by looking in `sysfs` (under `/sys/devices`) to find the
correct USB device and set its ownership and permissions to allow acces
to the user the driver is running under.

Copilot complained about a few things

* nut-server.init had potential word-splitting issues in various spots.
* it also had some commands missing an argument
* improved documentation was required to clarify a dependency
* an incorrect sed could mangle names as well as remove the intended
  name

Additionally, while fixing those issues the author noticed that the case
of multiple UPS devices with the same vendorid:productid were not
correctly handled. A check of the serial number, if provided, was added
along with a fallback to allowing NUT communications with all UPS
devices with a given vendorid:productid, if no serial number was given.

Improve efficiency and decrease McCabe complexity of
ensure_usb_ups_access, while also fixing Copilot complaints.

$@ in case is a problem, and we only handle the first parameter in any
event, so change $@ to "$1"

Copilot caught a missing 2&gt;&amp;1 and we silence some shellcheck
false positives

Signed-off-by: Daniel F. Dickinson &lt;dfdpublic@wildtechgarden.ca&gt;
</content>
</entry>
<entry>
<title>nut: comment and simplify server script</title>
<updated>2026-03-03T18:53:14Z</updated>
<author>
<name>Daniel F. Dickinson</name>
</author>
<published>2026-02-11T20:50:16Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=9cfa3f657d243ff47f90e320f562b4ccf7a9af34'/>
<id>urn:sha1:9cfa3f657d243ff47f90e320f562b4ccf7a9af34</id>
<content type='text'>
Attempt to de-mystify the nut-server initscript by adding comments
and factoring out some common code that adds to complexity of the
functions of which it is part.

Signed-off-by: Daniel F. Dickinson &lt;dfdpublic@wildtechgarden.ca&gt;
</content>
</entry>
<entry>
<title>nut: stop de-configured ups</title>
<updated>2026-03-03T18:53:14Z</updated>
<author>
<name>Daniel F. Dickinson</name>
</author>
<published>2026-01-23T04:26:23Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=688c20bc78ac0b5d4857cfb162b3b0ef6e50dc26'/>
<id>urn:sha1:688c20bc78ac0b5d4857cfb162b3b0ef6e50dc26</id>
<content type='text'>
Ensure that when a ups is removed from the configuration that its
driver instance is stopped.

Signed-off-by: Daniel F. Dickinson &lt;dfdpublic@wildtechgarden.ca&gt;
</content>
</entry>
<entry>
<title>nut: fix driver, server, and monitor reload/stop</title>
<updated>2026-03-03T18:53:14Z</updated>
<author>
<name>Daniel F. Dickinson</name>
</author>
<published>2026-01-11T10:41:48Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=90d3d1e9d013e9cc3fec755f46826d8feab94cfa'/>
<id>urn:sha1:90d3d1e9d013e9cc3fec755f46826d8feab94cfa</id>
<content type='text'>
Updated configuration was not being applied after config change. This
was due to the means used to do the daemon reloads.

Closes #28298 "Drivers not restarted on config change"

Enable creating PID files for the server, driver, and monitor daemon
processes. This allows to use NUT's built-in facilities for signalling
the daemon's.

For server, when reloading:
1. Check if upsd is running
   1. If not, start it.
   2. If it is send reload signal to upsd
2. For each driver:
   1. Check if the driver is running
      1. If it is, send reload-or-exit signal to driver
      2. If driver is not running, start it
3. Attempt to start server (upsd and drivers) if service was stopped.

For server, when stopping:
1. Check if upsd is running
   1. If it is send stop signal to upsd
   2. Ensure it really is stopped
2. For each driver:
   1. Check if the driver is running
      1. If it is, send stop signal to driver
      2. If driver is still running, stop it.
3. If the server process is active (even with not upsd or drivers),
   stop it.

For monitor, send the reload signal on config change, with fallback to
stopping and starting the daemon.

Change the names of variables and functions to make it more clear what
is being acted on, configured, or otherwise touched.

Avoid confusing messages in syslog

* Avoid attempting to remove a procd server instance that does not exist
  as doing so results in confusing/scary messages in syslog, such as:

  Command failed: ubus call service delete
  { "name": "nut-server", "instance": "upsd" } (Not found)

In NUT some models of UPS use shutdown_delay rather than offdelay, and
yet others use usd for the same purpose. shutdown_delay and usd were
previously not available in the list of available driver options, so
add them.

Signed-off-by: Daniel F. Dickinson &lt;dfdpublic@wildtechgarden.ca&gt;
</content>
</entry>
<entry>
<title>nut: add linting and fix whitespace and typos</title>
<updated>2026-03-03T18:53:14Z</updated>
<author>
<name>Daniel F. Dickinson</name>
</author>
<published>2026-01-11T10:36:43Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=7eafd0ada63825d560b8ea6ef3dd9230926e5e57'/>
<id>urn:sha1:7eafd0ada63825d560b8ea6ef3dd9230926e5e57</id>
<content type='text'>
shellcheck is a useful linter if a bit pedantic and overzealous so
add overrides to silence false positives

Also, fix issues found by the linting.

* misspelling meant initscript could skip updating configuration in
  certain circumstances
* minor: assignment of the result of execution as the time of creating
  local. This has been separated.

Fix whitespace and comment typos
Fix typo in Config.in option text
* This is cosmetic, but user-facing (for users building via SDK or
  buildroot).

Signed-off-by: Daniel F. Dickinson &lt;dfdpublic@wildtechgarden.ca&gt;
</content>
</entry>
<entry>
<title>nut: add cable type nut driver config</title>
<updated>2022-05-13T04:53:27Z</updated>
<author>
<name>Rob J. Epping</name>
</author>
<published>2022-05-11T21:17:06Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=67e49b7e0e837f8b8677b7ac70321879a941b928'/>
<id>urn:sha1:67e49b7e0e837f8b8677b7ac70321879a941b928</id>
<content type='text'>
at least driver apcsmart-old (maybe more) allow for specifying the
type of cable used. My old UPS does will not function when cable type
is not specified.

This will add support for configuration option 'cable'

Signed-off-by: Rob J. Epping &lt;epping@renf.us&gt;
</content>
</entry>
<entry>
<title>nut: Add the option to compile Nut NetXML drivers with the Nut package.</title>
<updated>2021-09-23T20:03:10Z</updated>
<author>
<name>Seb Belcher</name>
</author>
<published>2021-09-21T12:49:48Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=ff68df2faa8eb537fcd587a46ff5d235b89ffa58'/>
<id>urn:sha1:ff68df2faa8eb537fcd587a46ff5d235b89ffa58</id>
<content type='text'>
Also modifies the nut-server init script to include options specific to the netxml driver.

Signed-off-by: Seb Belcher &lt;sdjbelcher@gmail.com&gt;
</content>
</entry>
<entry>
<title>nut: fix _ handling</title>
<updated>2020-09-19T23:52:58Z</updated>
<author>
<name>Rosen Penev</name>
</author>
<published>2020-09-19T23:52:58Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=4d39346fb4ca38e7c4b2f20735efb09b9eccb587'/>
<id>urn:sha1:4d39346fb4ca38e7c4b2f20735efb09b9eccb587</id>
<content type='text'>
Taken from https://github.com/openwrt/packages/issues/13359

Signed-off-by: Rosen Penev &lt;rosenp@gmail.com&gt;
</content>
</entry>
<entry>
<title>nut: fix other/otherflag custom variables in nut-server.init</title>
<updated>2020-01-20T03:39:44Z</updated>
<author>
<name>Matt Merhar</name>
</author>
<published>2020-01-20T03:39:44Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=0b04dd34a0cd706a7be33da3b7536f3c50714c8e'/>
<id>urn:sha1:0b04dd34a0cd706a7be33da3b7536f3c50714c8e</id>
<content type='text'>
This allows custom config parameters to be added to the generated config
files, enabling the original intended functionality per
https://openwrt.org/docs/guide-user/services/ups/software.nut.

Example usage from /etc/config/nut_server:

config driver 'apc'
	option driver 'snmp-ups'
	option snmp_version 'v3'
	option port '172.16.100.5'
	list other 'secLevel'
	list other 'secName'
	list other 'authPassword'
	list otherflag 'notransferoids'

config other 'other_secLevel'
	option value 'authNoPriv'

config other 'other_secName'
	option value 'some_username'

config other 'other_authPassword'
	option value 'some_password'

config other 'otherflag_notransferoids'
	option value '1'

Signed-off-by: Matt Merhar &lt;mattmerhar@protonmail.com&gt;
</content>
</entry>
<entry>
<title>nut: initscripts hotplug: Fix many small semantic issues</title>
<updated>2019-01-20T17:16:28Z</updated>
<author>
<name>Daniel F. Dickinson</name>
</author>
<published>2019-01-16T12:09:13Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/feed/packages/commit/?id=d7db15459f222ef1b5878c543a01a78fb55a73a7'/>
<id>urn:sha1:d7db15459f222ef1b5878c543a01a78fb55a73a7</id>
<content type='text'>
Small but important tweaks to fix the operation of the nut initscripts
and hotplug scripts.  All hail shellcheck and proofreading and
dogfooding.

Signed-off-by: Daniel F. Dickinson &lt;cshored@thecshore.com&gt;
</content>
</entry>
</feed>
