-
Notifications
You must be signed in to change notification settings - Fork 3.8k
nut: A number of fixes and enhancements #6897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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>
|
Ooops...forgot the migration path (there have been UCI changes)...even if Travis gets working, please don't merge yet. |
|
Well, broke something ... <mutters incoherently> ... will push when resolved. |
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>
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>
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>
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 allows config for setting variables and/or running commands from the CGI. 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>
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>
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>
We're using --without-wrap unconditionally anyway, so this legacy dependency needs to be removed. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
Reduce compilation time and complexity by not building documentation we don't use. 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>
Avoid potential issues with space or other strangeness by quoting filenames through the initscripts. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
Cosmetic edit. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
Removes a duplicate directory creation and a stray newline. Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
|
Ok, the breakage was a need to do dirclean since I rebased against latest master for openwrt, packages, and luci. It's working. And I've tested the patches with them reordered somewhat sensibly (so the first 5 I want to cherry-pick and verify on 18.06 for backporting). Oh and I eliminated the difference in UCI; no migration is necessary. |
|
Run tested ath79, CR5000, current masters
|
|
@cshoredaniel |
|
@commodo I don't have rights on the openwrt github account (I removed myself when I was ill and didn't think I'd be back to OpenWrt). |
|
Hmmm...let's see if we can kick off a new build without the Travis access.... |
|
Hi @cshoredaniel, we managed to compile the updated source codes and so far the forced shutdown command works. Thanks for this. We bumped in into some problems when we tried to use the same UCI files that was setup when we were reproducing the issue. Our next step is to start from a new /etc/config/nut_server and nut_monitor which are generated by the installed packages. We will update you with the results. |
|
@malakingpusa Hmmm....can you describe problems? If the upsdrvctl thing, you need to stop the nut-driver before using it, as it's not meant to be used with the driver already running (and procd will restart the driver fairly quickly (i.e. before -k has a chance to read all the descriptors and do it's thing). Can you share a sanitized version of the configs you are using so I can see what's up? |
|
Here is my /etc/sysupgrade.conf: When I try upsc CP37@localhost: This works as expected: Why is there no /lib/nut/usbhid-ups -a CP37 in my processes? When does the following part of the /etc/init.d/nut-server get executed? Right now, just have to make upsc work and test multiple UPSes. |
|
Two questions: How long after boot are you attempting upsc (it takes some time for the driver to come up because of the way the procd + hotplug work in this case)? |
|
How long after boot are you attempting upsc (it takes some time for the driver to come up because of the way the procd + hotplug work in this case)? >> hours because i left it last night and then started again when I reported for work. I'm puzzled by the 'no such dir' --- does it appear on subsequent flashes or just coming from the previous version? >> never encountered them with previous flashes without the new compiled packages. will try this command you suggested: |
|
Did a reboot and after 32 minutes I checked upsc CP37: |
|
In the 'config driver' section, can you try setting e.g for my setup I have Perhaps there is some issue with hotplug messing things up without the vendorid and product id on your device (I think I tried both ways, but will try to make some time to test again). Wait: Please use 'master' not '18.06' The backported changes haven't been merged yet (I guess @hnyman is waiting for results with 'master') |
|
@malakingpusa Please let me know the results with master; I believe you are seeing the old version of the initscripts and no hotplug because 18.06 doesn't have the updates yet. |
|
@cshoredaniel thanks for pointing that out. Asking our SW engineer now to compile OpenWrt from master. We will test and then update you again. Thanks. |
|
@cshoredaniel SW engineer is asking if we will compile source code from latest commit or latest release? |
|
Latest commit |
|
Great. Will tell my SW engineer. |
|
Bumped into this issue when I tried to install kmod-usb2: kmod-usb2 is needed by lsusb |
|
@malakingpusa Ah, are you building only the core and then using snapshots? That won't work. You need to either build everything you want and include it in the image, or you need to use snapshots build (which might already have the updated NUT code). |
|
I see. Building now nut packages with usbutils and kmod-usb2. Thanks @cshoredaniel . |
|
Hi @cshoredaniel , we managed to compile from the master branch. Here are the results of testing:
|
|
Other notes: I need the pollinterval so I do not get stale data and the ignorelb so I can override the battery.charge.low parameter. |
|
@malakingpusa Ah, I missed adding those parameters to the options available driver. By any chance can you submit a PR which adds missing parameters. I got rid of the auto-parameter stuff (i.e. not specifically named) because I had various concerns about it, and because LuCI requires explicitly named parameters and I want the parameters documentation in the NUT package. |
|
@cshoredaniel submitted #7001 for this. thanks. |
|
Hi @cshoredaniel , Just to clarify, for now while waiting for the updated parameters for the driver, is it correct that I can now use the router by doing the following:
??? |
|
I believe part of your problem is #6966 (which I'm working on right now). As a quick work around remove the leading 0 on any product id (middle number in xxxx/xxxx/* | \ in /etc/hotplug.d/usb/30-libhid-... and also remove [ -d /var/run/nut ] from the same file, and you should need to do the killing of upsd and/or upsdrvctl start. Also to FSD just |
|
Wow! Worked from reboot after doing the workaround you mentioned as I can see output from upsc command. As a result, usbhid-ups is now running as nut user and no longer as root. I added another UPS and it can now detect and read status from both UPSes after reboot, of course I had to add the new UPS in the /etc/config/nut_server. This is how the nut processes look now: Also was able to run the command Thanks for the help @cshoredaniel ! Just need that fix for the parameters so I get a reliable reading from the UPSes and avoid stale outputs. |
|
@malakingpusa I'd recommend But great news! |
|
@cshoredaniel here are the processes from a fresh reboot before trying Then tried executing And then I tried Here are the remaining processes after |
|
@malakingpusa Is this with multiple UPSes or a single one? (working on a build now for the other changes so will test again). It was working for me, but maybe I broke something? |
|
@malakingpusa UPS takes about 20-30 seconds after last slave exits before UPS is shutdown and (it should) come back in about 10 seconds if UPS is still powered on. Does that make a difference? |
|
Using blazer_usb nut driver and found that this PR brings https://github.com/openwrt/packages/pull/6897/files#diff-b43121d3cb6f04f9a4f58f93c7970813R150 option which is not available in blazer_usb thus it cannot start with the following error The second issue is permissions to /dev/bus/usb/001/00*
I'm using latest master compiled from sources |
hi @cshoredaniel , managed to explore this again after some serious load at the office. while waiting for the parameters fix, did just what was described here: I still can query and send shutdown to UPS after that which is really an improvement. Next step I am starting now on is to soak test the UPS to check if I won't get stale data errors over the weekend. So far log looks good: |
|
In case folks haven't seen it elsewhere: FYI I've posted PR: #7638 which ought to do must of what's now in master except the USB hotplug bits (as that's a new feature IMO). If you can, please test and comment! |
Maintainer: me
Run tested: ath79, CR5000, current master for openwrt and openwrt-packages
In addition to while developing testing each part did a final:
Description:
The fixes #6843 by properly 'procdifying' the initscripts as well fixing a number of minor nits and adding USB hotplug support.
It also makes forced UPS shutdown (FSD) via upsmon actually work by adding a script to implement the necessary actions.