Skip to content

Instantly share code, notes, and snippets.

@kris-anderson
Last active August 19, 2023 11:09
Show Gist options
  • Select an option

  • Save kris-anderson/6255c1fcad8ec853e1dbd44e3c029957 to your computer and use it in GitHub Desktop.

Select an option

Save kris-anderson/6255c1fcad8ec853e1dbd44e3c029957 to your computer and use it in GitHub Desktop.
pfSense NUT Package Fix Through Ansible
---
- name: get sha256sum of /usr/local/libexec/nut/usbhid-ups
stat:
path: /usr/local/libexec/nut/usbhid-ups
checksum_algorithm: sha256
get_checksum: yes
register: nut_orig
- name: backup original /usr/local/libexec/nut/usbhid-ups
copy:
remote_src: true
src: /usr/local/libexec/nut/usbhid-ups
dest: /usr/local/libexec/nut/usbhid-ups.orig
owner: root
group: wheel
mode: "0755"
remote_user: root
when: nut_orig.stat.checksum == "c90a4d8e39fa89f5eb62680b904845a690ee7dbaec9b105d610a3ef0fcd641d2"
- name: download patched usbhid-ups
get_url:
url: https://forum.netgate.com/assets/uploads/files/1678659799995-usbhid-ups.gz
dest: /tmp/usbhid-ups.gz
owner: root
group: wheel
mode: "0755"
remote_user: root
- name: extract /tmp/usbhid-ups.gz
command: gunzip -f /tmp/usbhid-ups.gz
remote_user: root
- name: get sha256sum of /tmp/usbhid-ups
stat:
path: /tmp/usbhid-ups
checksum_algorithm: sha256
get_checksum: yes
register: nut_new
- name: copy /tmp/usbhid-ups to /usr/local/libexec/nut/usbhid-ups
copy:
remote_src: true
src: /tmp/usbhid-ups
dest: /usr/local/libexec/nut/usbhid-ups
owner: root
group: wheel
mode: "0755"
remote_user: root
when:
nut_new.stat.checksum == "999a2653559dbc50ecc8ba592a67587b1e307a1495f6e8ebbd3d8e90e3967133" and
nut_orig.stat.checksum == "c90a4d8e39fa89f5eb62680b904845a690ee7dbaec9b105d610a3ef0fcd641d2"
- name: remove /tmp/usbhid-ups.gz
file:
path: /tmp/usbhid-ups.gz
state: absent
remote_user: root
- name: remove /tmp/usbhid-ups
file:
path: /tmp/usbhid-ups
state: absent
remote_user: root
@kris-anderson
Copy link
Author

Since version 23.01 of pfSense plus, some users like myself started getting spammed by disconnect messages from the pfSense NUT package.

@dennypage on Netgate's forum provided a development build of the usbhid-ups package which addresses this issue for me and many others. You can see the original source of this fix here:
https://forum.netgate.com/topic/102959/nut-package/1105?_=1685261003329

I originally fixed this manually on pfSense Plus 23.01. But after upgrading to pfSense Plus 23.05, the issue returned, and I had to track down the fix again. So I don't have to do this again, I decided to put this in Ansible so the fix will be in code and I don't need to remember in the future.

Make sure you add user=root to your ups.conf in the pfSense GUI for the NUT package.

I have tested this on:

  • pfSense Plus 23.01
  • pfSense Plus 23.05

My UPS is a Trip Lite SMART1500LCD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment