networkupstools / nut

The Network UPS Tools repository. UPS management protocol Informational RFC 9271 published by IETF at https://www.rfc-editor.org/info/rfc9271 Please star NUT on GitHub, this helps with sponsorships!
https://networkupstools.org/
Other
1.93k stars 346 forks source link

Windows build is obsolete #1050

Open LinoBarreca opened 3 years ago

LinoBarreca commented 3 years ago

...and there are no build instructions for windows. The software works (with the openssl libraries manually copied in the right place) but it lacks the features/fixes of the newer source code. Any plan to update them or give proper instructions on how to build under windows?

jimklimov commented 3 years ago

The plan is quite latent and currently lower in priority than many other things to rectify first, for the available team members, sadly... (that said, help and PRs would be welcome!)

There are numerous issues to be found in github history and perhaps some more in mailing lists, but the gist of it is that latest Windows builds were done as a branch from 2.6.5 baseline, and later main-branch releases diverged significantly so that getting a Windows build ability on top of current code would be a new effort at best inspired by comparisons of those branches vs. main-line 2.6.5 release.

I suppose compilers, headers and third-party deps available in Windows have marched on significantly as well. Notably, if the new effort were to concentrate on recent Windows releases and require WSL2 or at least shell tools usable for configure/make logic, it might be easier than a fully-native build with older Windows versions.

opoplawski commented 2 years ago

It would be really nice to have a windows port of NUT.

jimklimov commented 2 years ago

I do not disagree, but it was not a priority so I did not even get a system set up for that although I intended to, for a year. So... PRs welcome ;)

Branch based on NUT release 2.6.5 should be there, but I suppose it would not be an easy merge with modern master, and might refer to compiler/tools versions no longer relevant. But really, I didn't try yet so may be it is not all that sad.

Jim

On Wed, Dec 1, 2021, 23:22 Orion Poplawski @.***> wrote:

It would be really nice to have a windows port of NUT.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/networkupstools/nut/issues/1050#issuecomment-984106730, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAMPTFDEYW4DUPD7OTWRX7LUO2N2RANCNFSM47DB5STQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kramttocs commented 2 years ago

Agreed this would also be great. I can't get it working on my machine and not many docs out there for troubleshooting.

jimklimov commented 2 years ago

See also #5

mrfrenzy commented 2 years ago

There are a few quirks due to changes done in Windows over the years.

Here is a short writeup how to get NUT-Installer-2.6.5-6 properly working on Windows 11 64-bit: Make sure the service is stopped Copy libgcc_s_dw2-1.dll from bin to sbin Download libeay32.dll and ssleay32.dll to sbin (https://github.com/openssl-net/openssl-net/tree/master/native/windows/x86) Download ShutdownWithupdates.exe to sbin (https://github.com/dennisbabkin/ShutdownWithUpdates) - this is needed because builtin shutdown.exe installs updates before shutdown which can be catastrophic.

nut.conf MODE=standalone

ups.conf set the proper driver here for "myups" Test it in an admin command line: cd "\Program Files (x86)\NUT\bin" genericups.exe -DDD -a myups (for example depending on what driver you choose) (leave this running)

upsd.users [upsmon] password = pass (please change to a good password) upsmon master

upsd.conf LISTEN 127.0.0.1 3493 (ipv6 runs out of memory) Open a new admin prompt and run: cd "\Program Files (x86)\NUT\sbin" upsd -DD (you should see connected to UPS and status OL/OB etc) (leave this running)

upsmon.conf MONITOR myups@127.0.0.1 1 upsmon pass master (not localhost) "c:\Program Files (x86)\NUT\sbin\ShutdownWithUpdates.exe" /s /nu /t 30 (regular shutdown.exe installs updates before shutdown) NOTIFYCMD "C:\WINDOWS\Sysnative\msg.exe *" (system32 does not work since msg.exe is actually 64-bit)

Change all NOTIFY to EXEC for example: NOTIFYFLAG ONLINE SYSLOG+EXEC

Open a new admin prompt and run: cd "\Program Files (x86)\NUT\sbin" upsmon -D (you should see logged into UPS)

Now test to disconnect line power, you should see messages in all windows and a popup, and after low bat the computer should shut down)

Close all windows and start the service, check event viewer - applications Test disconnecting power

jimklimov commented 2 years ago

See also #5 that coordinates (sort of) the effort to modernize NUT for Windows support. Might try a build of that branch. Packages not pursued yet, caveats / incomplete code are known (many listed in Project https://github.com/orgs/networkupstools/projects/2/views/1 made just for tracking all that)

See also #455 and #534 for discussion of similar issues (and some solutions)

jimklimov commented 2 years ago

FYI: To experiment with recent NUT codebase built (not packaged or otherwise integrated so far) for Windows you can try archives from https://ci.appveyor.com/project/nut-travis/nut/build/artifacts

cableghost commented 9 months ago

There are a few quirks due to changes done in Windows over the years.

I could use some help in following this... 1) Starting w/ nut.conf.. I'm not understanding where to make the changes? 2) Is there a means of setting the shutdown process to 'Hibernate' instead? 3) What if I only want the NUT server to provide access for my Home Assistant to view my UPS as a client, not to actually handle the shutting down process?

jimklimov commented 9 months ago

At the moment I can only elaborate on point (3) generally, as I haven't had practical experience with NUT 2.6.5 based MSI's and what the programs there can do.

Normally NUT has 3 layers - one or more drivers running on a system, a data server (upsd) which represents them all via network protocol, and local or remote clients. One of such clients is upsmon that can handle shutdowns, alerts, etc. Generally any client greater than the read-only upsc needs server-side preparations (see docs on upsd.users config file to set up monitoring users or admins to run commands and set firmware variables).

The setup you seem to describe involves a driver and data server running on Windows (and maybe an upsmon watching for shutdowns of that Windows box, if it is fed by the UPS it monitors), and a separate Home Assistant with which you want to just watch the UPS state but not shut down HA.

So on the Windows side, prepare the driver in ups.conf, and data server via upsd.user as well as LISTEN * (or specific IP) in upsd.conf, and probably allow access to 3493/tcp on your LAN.

On HA side, if it runs NUT upsmon - in its config set MONITOR line for that ups@server as a secondary which feeds 0 PSUs (of the HA box). If it has some other client (graphs etc) - depends on such client; probably it is readonly and needs no logins, like upsc...