NUT (UPS) daemon is unable to start after upgrade

Started by RedVortex, January 26, 2023, 11:51:42 PM

Previous topic - Next topic
root@OPNsense:/var/db # /usr/local/etc/rc.d/nut restart
nut not running? (check /var/db/nut/upsd.pid).
Network UPS Tools - UPS driver controller 2.8.0
Network UPS Tools - Generic HID driver 0.47 (2.8.0)
USB communication driver (libusb 1.0) 0.43
Can't chdir to /var/db/nut: Permission denied
Driver failed to start (exit status=1)
/usr/local/etc/rc.d/nut: WARNING: failed precmd routine for nut


Exact same as above

root@OPNsense:/var/db # ls -la nut/
total 19
drwxr-x---   2 uucp  uucp    6 Jan 19 04:44 .
drwxr-xr-x  23 root  wheel  34 Jan 27 10:23 ..
-rw-r--r--   1 nut   nut     6 Jan 18 10:00 upsd.pid
-rw-r--r--   1 nut   nut     6 Jan 27 10:23 upsmon.pid
srw-rw----   1 nut   nut     0 Jan 18 10:00 usbhid-ups-ups
-rw-r--r--   1 nut   nut     6 Jan 18 10:00 usbhid-ups-ups.pid

I don't know, nut rc.d could be botching the restart command.

# cat /usr/local/opnsense/scripts/OPNsense/Nut/setup.sh
# /usr/local/opnsense/scripts/OPNsense/Nut/setup.sh

And try again ;)

(cat to see if the content is correct)


Cheers,
Franco

Ok, strange thing. I used the cat command and realized that the script hasn't been changed to reflect the changes to nut:nut. So I applied the patch a third time and now it just works as intended. No idea why it didn't work before but it seems to be working just fine now, even after a reboot.

Third time? Applying patch twice adds and removes it :)


Thanks,
Franco

Quote from: franco on January 27, 2023, 09:10:25 AM
Does this do the job? https://github.com/opnsense/plugins/commit/16cbe99ebf

# opnsense-patch -c plugins 16cbe99ebf

I reverted my changes (put back uucp:uucp both in the setup.sh and the folder) and I emptied the folder but kept the folder to make sure things would change for people already having it existing, not just new installs.

root@*****:/usr/local/opnsense # ls -al /var/db/nut/
total 8
drwxr-x---   2 uucp  uucp    512 Jan 27 08:45 .
drwxr-xr-x  21 root  wheel  1536 Jan 27 03:40 ..


Then applied the patch and started the services through the UI (that does trigger the file to run I believe, unlike the command line rc).

Everything started properly and the files, folders and all seem happy


root@*****:/usr/local/opnsense # ls -al /var/db/nut/
total 20
drwxr-x---   2 nut   nut     512 Jan 27 08:45 .
drwxr-xr-x  21 root  wheel  1536 Jan 27 03:40 ..
-rw-r--r--   1 nut   nut       6 Jan 27 08:45 upsd.pid
-rw-r--r--   1 root  nut       6 Jan 27 08:45 upsmon.pid
srw-rw----   1 nut   nut       0 Jan 27 08:45 usbhid-ups-DP
-rw-r--r--   1 nut   nut       6 Jan 27 08:45 usbhid-ups-DP.pid


I'm also seeing the changes in the /etc/group file

before

uucp:*:66:
dialer:*:68:
network:*:69:


after

uucp:*:66:
dialer:*:68:nut
network:*:69:


Thanks a lot for the super quick fix franco !  :)

The patch worked for me as well.  Thanks Franco!


Quote from: franco on January 27, 2023, 09:10:25 AM
Does this do the job? https://github.com/opnsense/plugins/commit/16cbe99ebf

# opnsense-patch -c plugins 16cbe99ebf


Cheers,
Franco

This patch fixes the problem for me and allows NUT to start up.