Test 1 - I moved the environ.conf file to /tmp. I ran systemctl daemon-reload, then restarted [email protected]. Results:

=====================================
[root@mythtv [email protected]]# systemctl restart [email protected] Job for [email protected] failed because the control process exited with error code. See "systemctl status [email protected]" and "journalctl -xeu [email protected]" for details. [root@mythtv [email protected]]# systemctl --full --no-pager status [email protected] [email protected] - Network UPS Tools - device driver for NUT device 'cyberpower' Loaded: loaded (/usr/lib/systemd/system/[email protected]; enabled; preset: disabled)
    Drop-In: /etc/systemd/system/[email protected]
└─nut-driver-enumerator-generated-checksum.conf, nut-driver-enumerator-generated.conf Active: activating (auto-restart) (Result: exit-code) since Fri 2022-12-02 05:54:03 CST; 2s ago Process: 10732 ExecStartPre=/usr/bin/systemd-tmpfiles --create /usr/lib/tmpfiles.d/nut-client.conf (code=exited, status=0/SUCCESS) Process: 10733 ExecStart=/bin/sh -c NUTDEV="`/usr/libexec/nut-driver-enumerator.sh --get-device-for-service cyberpower`" && [ -n "$NUTDEV" ] || { echo "FATAL: Could not find a NUT device section for service unit cyberpower" >&2 ; exit 1 ; } ; /usr/sbin/upsdrvctl start "$NUTDEV" (code=exited, status=1/FAILURE)
        CPU: 80ms
=========================================

It seems that the nut device driver requires environ.conf to be present.

Test 2 - I moved environ.conf back to the correct place. I edited the file to use "Environment=NUT_STATEPATH=/run/nut". I did a daemon-reload then started the nut-driver. It worked - no errors.

Test 3 - I modified /etc/ups/upsd.conf to comment out the STATEPATH line. I restarted nut-server.service. It failed.

================================
[root@mythtv ups]# systemctl --full --no-pager status nut-server
● nut-server.service - Network UPS Tools - power devices information server
Loaded: loaded (/usr/lib/systemd/system/nut-server.service; enabled; preset: disabled)
     Active: active (running) since Fri 2022-12-02 06:00:54 CST; 13s ago
   Main PID: 11452 (upsd)
      Tasks: 1 (limit: 9482)
     Memory: 728.0K
        CPU: 5ms
     CGroup: /system.slice/nut-server.service
             └─11452 /usr/sbin/upsd -F

Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: listening on ::1 port 3493 Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: listening on 127.0.0.1 port 3493
Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: listening on ::1 port 3493
Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: listening on 127.0.0.1 port 3493 Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: /var/run is world readable
Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: /var/run is world readable
Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: Can't connect to UPS [cyberpower] (usbhid-ups-cyberpower): No such file or directory Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: Can't connect to UPS [cyberpower] (usbhid-ups-cyberpower): No such file or directory Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: Running as foreground process, not saving a PID file Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: Running as foreground process, not saving a PID file
===================================

Test 4 - I uncommented the STATEPATH line in upsd.conf. It points to /run/nut. I restarted nut-server. Success.


===============
Bill Gee

On 12/1/22 18:35, Simon Wilson via Nut-upsuser wrote:
Resending as original was too big for list acceptance.

Hi Bill,

/etc/systemd/system/[email protected]/environ.conf sets the nut-driver service's environment variable, such that it sees a workable NUT_STATEPATH of /var/run/nut when upsdrvctl is run by the service, regardless of what is set in upsd.conf, and explains why the driver worked yesterday but upsd didn't.

Tests which may be interesting:

1. First test:- move nut-driver's environ.conf file to somewhere else temporarily; leave upsd.conf STATEPATH uncommented saying /run/nut; restart [email protected]; and see if it runs. This tests to see if it *needs* the drop-in service file *or* will work with only STATEPATH explicitly set in upsd.conf to /run/nut.  If this prevents the driver from working, put the environ.conf file back (but edit it, it should say /run/nut, not /var/run/nut)

2. Second test:- copy the edited /etc/systemd/system/[email protected]/environ.conf to /etc/systemd/system/nut-server.service.d/environ.conf. So you should at that point have both locations with a file saying
   [Service]
   Environment=NUT_STATEPATH=/run/nut
Then comment out STATEPATH line (back to default) in upsd.conf and restart nut-server - does it still start, and does it still pop a "Could not find PID file '/var/run/upsd.pid'" message? That tests whether the drop-in file is a better, more consistent fix for now (until the packages are resolved). Calling the nut-server process with that variable set for upsd *even before it reads upsd.conf* may remove the first error 'Could not find PID file '/var/run/upsd.pid''

And definitely document any changes you make to your setup as subsequent package releases will likely change all of this :)

Couple more comments inline below.

Simon


----- Message from Bill Gee <[email protected]> ---------
    Date: Thu, 1 Dec 2022 16:49:14 -0600
    From: Bill Gee <[email protected]>
Subject: Re: [Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade
      To: [email protected]

Checking now - There is a file called /etc/systemd/system/[email protected]/environ.conf.  Its contents are

==========================
[root@mythtv [email protected]]# ll
total 8
-rw-r--r-- 1 root root 49 Nov 29 18:14 environ.conf
-rw-r--r-- 1 root root 81 Nov 30 18:58 nut-driver-enumerator-generated-checksum.conf

[root@mythtv [email protected]]# cat environ.conf
[Service]

[snip]

_______________________________________________
Nut-upsuser mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser

Reply via email to