<div dir="auto"><a href="https://github.com/networkupstools/nut/pull/1762">https://github.com/networkupstools/nut/pull/1762</a> (and maybe some of other recent PRs) updated quite a bit here and there, including a configure-time option for default POWERDOWNFLAG value (using legacy default still).<div dir="auto"><br></div><div dir="auto">Distros now have easier time to put it into a tmpfs of their choice that they know will remain mounted.</div><div dir="auto"><br></div><div dir="auto">Jim </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 5, 2023, 19:03 Greg Troxel <<a href="mailto:gdt@lexort.com">gdt@lexort.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Charles Lepple <<a href="mailto:clepple@gmail.com" target="_blank" rel="noreferrer">clepple@gmail.com</a>> writes:<br>
<br>
> On Dec 30, 2022, at 7:42 PM, Greg Troxel <<a href="mailto:gdt@lexort.com" target="_blank" rel="noreferrer">gdt@lexort.com</a>> wrote:<br>
>> <br>
>> maybe me, maybe docs.<br>
>> <br>
>> I have never had auto shutdown set up on netbsd.  Mostly I monitor to<br>
>> mqtt.  But now I'm trying and have multiple confusions.<br>
>> <br>
>> 1) 'upsdrvctl shutdown' vs 'upscmd shutdown.return'<br>
>> <br>
>> upsdrvctl is about stopping the driver, but lowbatt shutdown wants to<br>
>> send a command.  I don't get the upsmon example file:<br>
><br>
> "upsdrvctl stop" is for stopping the driver, but "upsdrvctl shutdown"<br>
> runs "$DRIVER -k" to kill power to the load on the UPS (which is<br>
> actually a second, non-long-running instance of the driver that<br>
> doesn't talk to upsd, after the rest of the system is ready to stop).<br>
><br>
> That being said, upscmd needs to talk to upsd, which needs a running<br>
> driver - IMHO this is only workable if you trust your<br>
> delay-before-shutdown in the UPS. The "upsdrvctl shutdown" case can<br>
> often be run after everything has been remounted read-only, at which<br>
> point it is okay if there is no delay before the power gets pulled.<br>
<br>
Thanks.  I am editing docs for a soon PR.  Checking my understanding:<br>
<br>
psdrvctl stop will not affect the UPS, and upsdrvctl shutdown will spin<br>
up $driver -k, assuming that the previous long-running driver is no<br>
longer running.<br>
<br>
And thus one does not use upscmd to do a shutdown, because it needs<br>
upsd/driver running and in getting to fs being ro, those will have been<br>
stopped.<br>
<br>
And, one can either:<br>
<br>
  do shutdown when upsd/driver/upsmon is stopped and hope delay is long<br>
  enough<br>
<br>
or<br>
<br>
  have another script that runs essentially last, after the fs are ro,<br>
  so even if no delay it's ok<br>
<br>
> Hopefully explained by the above. Also, you don't have to check for the file directly - you can use "upsmon -K" as in the following excerpt from the rc.d/nut script in FreeBSD's NUT port:<br>
><br>
> nut_poststop() {<br>
>         if ${nut_prefix}/sbin/upsdrvctl stop && checkyesno nut_upsshut; then<br>
>                 if ${nut_prefix}/sbin/upsmon -K; then<br>
>                         ${nut_prefix}/sbin/upsdrvctl shutdown<br>
>                 fi<br>
>         fi<br>
><br>
> }<br>
<br>
got it about -K<br>
<br>
This assumes delay, or is that somehow post remount ro?<br>
<br>
>> 2) LB config.   On a Best Fortress, I can set lowbatt runtime, but only<br>
>> 3 digits, even though I want 1800s.   Is this likely a Fortress<br>
>> limitation, or a bug?  I will read the source...<br>
><br>
> Looks like it might be a NUT bug. There should be room for four digits<br>
> in the protocol, but the protocol appears to be minutes. NUT shouldn't<br>
> limit the seconds field to three characters.<br>
<br>
Thanks, will read the printed protocol spec I have someplace.<br>
<br>
>> 2A) seems like nut should be able to have time-based config to start<br>
>> shutdown, all of batt%, seconds remaining, and seconds on battery, built<br>
>> in.<br>
><br>
> Others have covered solutions in greater depth (I think Roger's config<br>
> guide handles most of these), but IMHO things like "seconds on<br>
> battery" aren't as easy as they look (unless you don't care about the<br>
> intersection with seconds remaining).<br>
<br>
Sure, I want:<br>
<br>
  if on batt for 2min, start shutdown<br>
<br>
and I'm fine with<br>
<br>
  if LB, start shutdown<br>
<br>
also firing.  Basically one UPS has a desktop (piggy, not important to<br>
stay up, important not to break) and an RPI/switch/wifi (good to keep<br>
running).<br>
<br>
I have queued the config examples pdf for reading.<br>
<br>
>> 3) seems like shutdown should remove /etc/killpower but maybe upsmon<br>
>> removes it at boot.  should be explained more, probably, guessing it is<br>
>> at boot since fs is ro<br>
><br>
> probably should be removed at boot (or better yet, placed on a RAM-based filesystem), but this is not my area of expertise.<br>
<br>
/etc is ~never RAM-based, so we need to move to /var/run or equiv, but I<br>
think removing it at startup is easy and maybe already done.  I will<br>
look.<br>
<br>
_______________________________________________<br>
Nut-upsuser mailing list<br>
<a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">Nut-upsuser@alioth-lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
</blockquote></div>