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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Serial drivers don't add much to main NUT and appear to be common,
so make it possible for users to use NUT with serial UPS drivers without
a custom build.
Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
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>
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>
Avoid potential issues with space or other strangeness by
quoting filenames through the initscripts.
Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
The source code has multiple licenses so update SPD-X header.
NB: The previously unlisted licenses are not applicable to parts
actually built in any configuration for OpenWrt, but rather to
unused (by us) source code.
Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
We're using --without-wrap unconditionally anyway, so this legacy
dependency needs to be removed.
Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
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>
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>
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>
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>
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>
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>
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>
We want to include the symlinks to the generated configurations
in conffiles so that if the user replaces them symlinks with
traditional NUT configuration it is preserved across sysupgrade.
Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
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>
fix Makefile chmod (644)
replace MD5SUM with HASH
add PKG_MIRROR_HASH when PKG_SOURCE_PROTO:=git
(PKG_SOURCE_PROTO:=svn tarballs are not reproducible for now)
Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
Per user request ship the sample upsset.conf file so that
upsset functionality can be used with nut-cgi
Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
Current maintainer (Martin Rowe) offered to hand over
maintership because I'm interested in doing more with
the package than he requires for his own use, so he
felt it made sense for me to maintain the package.
I accepted, hence this commit.
Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
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>
It looks like serial support was accidentally dropped due to missing
pieces on Config.in and Makefile. Add back serial support by fixing
that.
Signed-off-by: Daniel Dickinson <lede@cshore.thecshore.com>
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>