Commit graph

36 commits

Author SHA1 Message Date
Daniel F. Dickinson
c25b751041 nut: Actually do FSD when required
The code was all there but the call do the function containing it was missing,
so call the function so that forced (UPS) shutdown occurs on a battery critical
or manually requested FSD situation.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2019-04-28 20:44:15 +00:00
Daniel F. Dickinson
867ea959a2 nut: Fix nutmon issues with init
NUT's upsmon is rather peculiar in that it has a child process that runs as
a regular user and a parent process that runs as root (in order to facilitate
shutting down the device if needed).  procd doesn't deal well with this and
doing 'normal' procd stop / restart / etc results in the child process still
hanging around but with not parent, which causes undesired behaviour.  Therefore,
add the use of 'upsmon -c stop' during process shutdown / restart in order to
ensure that upsmon is actually fully stopped.

Also fixes nut-monitor going into crashloop on network changes (due to
trigger that restarted upsmon but failed due to orphan child from before
restart).

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2019-04-28 20:17:12 +00:00
Daniel F. Dickinson
d7db15459f nut: initscripts hotplug: Fix many small semantic issues
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 <cshored@thecshore.com>
2019-01-20 12:16:28 -05:00
Hannu Nyman
882b497753
Merge pull request #7910 from cshoredaniel/pr-nut-fsd-bug
nut: Prevent FSD when not specifically requested
2019-01-13 09:45:43 +02:00
Daniel F. Dickinson
cb06f02504 nut: Prevent FSD when not specifically requested
Under certain circumstances nutshutdown was causing a forced
shutdown of the UPS even though killpower was not indicated.
Prevent that.  Also clarify the logic for powering off server
by avoiding && || chains.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2019-01-08 04:07:01 -05:00
Daniel F. Dickinson
c8cc504efe nut: Fix procd crashloop no interfaces
Fix a crashloop under procd when attempting to bind
to any address when no interfaces are yet available.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2019-01-07 02:03:31 -05:00
Daniel F. Dickinson
2d87aa40c8 nut: really run upsd as non-root
One local removal was missed in last push of this fix, so
in certain circumstances upsd would run as root even when
it shouldn't.

Fixes f48b060fa7 ("nut: Fix upsd runs as root")
Closes: #6697 (properly)

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-23 00:25:39 -05:00
Daniel F. Dickinson
f916a7e0eb nut: Update server config comment 'docs'
Update the commented out settings in /etc/config/nut_server that
shows the available sections with their default settings.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-23 00:24:37 -05:00
Daniel F. Dickinson
23c4235554 nut: Fix additional (other) variable handling
There was a cut & paste error in the handling of 'other'
variables (i.e. driver variables not specifically known
to the package but which some users may require to be add).
There was also a logic error from not switching sufficient
after cut & paste.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-20 23:24:00 -05:00
Daniel F. Dickinson
d04f2580b1 nut: Remove extraneous config reads
Handling of driver variable defaults, overrides, and additional
(other) variables changed and left behind some extraneous
config reads (config_get and config_list_foreach).  Remove those.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-20 23:23:56 -05:00
Daniel F. Dickinson
97c7ef6c4d nut: alphabetize driver options
There are a lot of options; to make development easier
alphabetize them.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-20 23:23:50 -05:00
Daniel F. Dickinson
a5d06ce110 nut: Optionally set serial USB to NUT user
When using serial-port based UPSes with NUT, it is handy to be able to
configure a USB serial port to have be set tot the NUT runas user, so
that NUT can access the serial port automagically.
Closes #6997

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-06 03:31:47 -05:00
Daniel F. Dickinson
f48b060fa7 nut: Fix upsd runs as root
Closes #6997 - Allows upsd to runas a non-privileged user.
If any driver is running as non-privileged user, the last driver's
user will be used as the server non-privileged user, otherwise the
user specified in config upsd, otherwise nut. Previously the
localisation of RUNAS variable was in the wrong locations.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-06 03:02:29 -05:00
Daniel F. Dickinson
192b0f1646 nut: Fix a typo in setting a driver parameter
synchronous would not get set due to typo.  Fixed.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-12-06 00:06:53 -05:00
Daniel F. Dickinson
36fd59dc78 nut: Fix extraneous config_get
nut-server initscript had a duplicate config_get statepath, so remove it

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-11-19 16:41:32 -05:00
Daniel F. Dickinson
58e33b02a8 nut: Fix nut-cgi config creation (startup)
Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-11-19 16:41:18 -05:00
Daniel F. Dickinson
44e57d4bdf nut: Fix variables for NUT drivers
Avoid specifying variables that are not specificy set in order to avoid breaking
drivers for which those variables do not exist.  Closes: #7096.

As part of these fixes make sure we have all the variables we need.  Closes: #7001.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-11-19 16:40:49 -05:00
Daniel F. Dickinson
3b5a8eee84 nut: Various startup fixes for monitor and server
Various path and permissions fixes to properly allow nut-server and nut-monitor to
start properly.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-11-19 16:40:39 -05:00
Daniel F. Dickinson
0a49d0ffbb nut: Fix checking for path before it exists
The mechanism for making sure hotplug doesn't execute during forced shutdown
was interfering with initial start of hotplug script due to checking for path
that doesn't exist at initial start.  This fixes that and closes #6966.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-11-19 16:39:53 -05:00
Daniel F. Dickinson
daa974cff0 nut: Fix undetected UPS hardware
Leading zeroes left in ProductId results in some UPS hardware not being matched
by the hotplug script lead to bad permissions and driver not starting.

Closes: #6966
Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-11-19 16:39:39 -05:00
Daniel F. Dickinson
461393810d nut: Use quotes around filenames
Avoid potential issues with space or other strangeness by
quoting filenames through the initscripts.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:35:01 -04:00
Daniel F. Dickinson
a2f64b3bac nut: Reduce user error with POWERDOWNFLAG
Instead of making POWERDOWNFLAG an uci option the user can
only change it via initscript edits.  This avoids chance for users
to miss the required change to nut-driver when setting an UCI option
for nut-monitor which results in failure to do FSD on the UPS.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:17:19 -04:00
Daniel F. Dickinson
cf446c7c47 nut: Use diff non-privileged user for upsmon
By default use a non-privileged user that is different than
the server or driver (when they are running non-privileged).
This is recommended by upstream.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:16:34 -04:00
Daniel F. Dickinson
56c1bc51a9 nut: Use 'real' procd for nut-cgi
Even though nut-cgi doesn't run a daemon, using procd triggers
is helpful for updating the generated config file when the
UCI config changes.  So implement this and 'modernize' nut-cgi initscript

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:16:33 -04:00
Daniel F. Dickinson
2fca922cf0 nut: nut-cgi: Add support for upsset
This allows config for setting variables and/or running
commands from the CGI.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:15:18 -04:00
Daniel F. Dickinson
918a62f919 nut: Make FSD really work
Forced shutdown of the UPS was not actually happening before
due to lack of specific commands doing the shutdown.  This
(and the nut-driver initscript) fix that.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:15:14 -04:00
Daniel F. Dickinson
f6a2a97d2f nut: Use 'real' procd init for nut-monitor
This fully procdifies nut-monitor, which fixes some issues with
very slow restarts (due to /lib/functions/procd.sh using a very
long delay for non-native scripts doing restart) as well as gives
respawning, etc.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:14:20 -04:00
Daniel F. Dickinson
1cd4dcfa99 nut: Add USB hotplug support
usbhid-ups has the necessary information in the source, so
let's support USB hotplugging out of the box.  Takes advantage of
the procd support now in nut-server initscript.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:12:53 -04:00
Daniel F. Dickinson
ceff68837d nut: Reorganize nut-server to clarify nut-driver
Clarify the different between the common nut-driver portions of
nut-server and the nut-server (upsd) proper.  nut-driver can't
be used without nut-server so there is no compelling reason
to split into a separate package, but the reorganization makes
such a move easier and makes it clear what each bit is for.

While we continue to use a single initscript, it's a properly
procdified one which handles the upsd daemon as a different
instance than the driver instances.  This resolves a race
condition in which upsd and drivers fail to start do to
a degree of interdepedence.

Also properly 'procd'ifies the nut-server initscript.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-29 00:12:53 -04:00
Daniel F. Dickinson
98fdf16ecb nut: Fix for nut-upsmon without nut-server
nut-monitor failed to create required dir /var/etc/nut, as
well as failing to set appropriate user on the directory and
conf files.  Fixing this closes
https://github.com/openwrt/packages/issues/6644

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2018-08-02 08:40:12 -04:00
Daniel Dickinson
c00d89593e net/nut: Fix '/var/run' world readable warning
Use /var/run/nut as statepath and set appropriate owner
and permissions on /var/run/nut in order to avoid pidfile
for nut being world-readable.

Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
2017-01-11 18:54:51 -05:00
Daniel Dickinson
c94e334c4e net-nut: Add UPS notifications via sendmail
Add option to send email notification via sendmail
(or replacement).

Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
2017-01-11 18:54:40 -05:00
Daniel Dickinson
c1d26bacdf net/nut: Protect CGI via HTTP Basic Auth
When using uhttpd (the default), protect NUT CGI
via HTTP Basic Auth.

Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
2017-01-11 18:54:16 -05:00
Daniel Dickinson
a23c4e85c5 net/nut: Build optional separate packages and ucify
With a LuCI app (of which I have one written) ucification makes
sense (and is in fact needed), so ucify the initscripts.

Also, rather than making selection of things to include an image
a matter of selecting compile-time config options, make optional
things into seperate packages that are built in default builds,
and leave selection of what to include or not up to the user
(e.g. using ImageBuilder, or adding packages via opkg).

Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
2017-01-11 18:53:58 -05:00
Marty R
064d84ab90 nut: add dev headers, nut-web-cgi and nut-avahi-service, bugfix
Headers are required by collectd as mentioned in #1801. This is the nut portion based on dwmw2@d636841cd1d1dfab04cb509520c082738ddfb2ea
Happy to merge with 15.05 as per #1803.
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
[martin.p.rowe@gmail.com: condensed InstallDev lines]

Added package nut-web-cgi based on demorfi@7e340f47944ff4a9c49d3b1dc6c1d9d965cd344c. Closes #1614.
Pending signoff by @demorfi
[martin.p.rowe@gmail.com: simplified implementation, no changes to Config.in]

Added package nut-avahi-service similar to other implementations in #618
Bugfix to remove redundant NUT_DRIVER_SERIAL config
Bugfix to make UPSLOG config actually install (requires PKG_RELEASE bump)
Some code tidy-ups
Signed-off-by: Martin Rowe <martin.p.rowe@gmail.com>
2015-10-03 18:11:28 -07:00
Marty R
d8258c35d5 nut: New package for Network UPS Tools
An older version of nut is in oldpackages. This commit is based on that
package and bumps the version to the latest release along with unifying
the server and client packages. More build options are provided for any
custom configuration but the defaults provide a working client and
server install which only needs a UPS driver. Drivers still build as
individual packages to minimise bloat. SSL support has also been added.

Signed-off-by: Martin Rowe <cyanidium@users.noreply.github.com>
2014-10-15 21:30:25 -07:00