Skip to content

Building NUT on FreeBSD

Jonas edited this page Nov 3, 2019 · 1 revision

This is not an accurate "How to build NUT on FreeBSD" in general - feel free to update this wiki!

Im not sure if this is the perfect way to compile NUT on FreeBSD, but this one worked for me! To compile NUT on FreeBSD without changes, just do:

cd /usr/ports/sysutils/nut/ && make install

Otherwise if you need to modify the sourcecode, follow step 3 to 8.


Based on Issue #736 and #737 i had to recompile the apcupsd-usb driver for FreeBSD/FreeNAS 11.1 .

What i did:

  1. Download FreeBSD 11.1 iso (the right equivalent to FreeNAS 11.1)
  2. Install it in VirtualBox/VMWare or some other virtualization software. --- check if the network mode is bridge.
  3. Boot VM and enable ssh as root:
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
/etc/rc.d/sshd restart
  1. login with ssh into the VM to make the next steps easier: (ifconfig or similar to get the IPv4 of the VM )
ssh root@192.168.0.50           <--- REPLACE IP WITH YOUR VM IP
  1. jump into the nut folder provided by FreeBSD and compile it once. This will download the sources and all the dependencies it needs. This will take some time ....
cd /usr/ports/sysutils/nut/ && make
  1. Modify the sourcecode if needed: In my case i modiefied a driver.
cd /usr/ports/sysutils/nut/work/nut-2.7.4/drivers/
nano apcupsd-ups.h

replace

{ "MBATTCHG", "battery.charge.low", ST_FLAG_RW, 1, "%.0f", DU_FLAG_NONE, NULL },

with

{ "MBATTCHG", "battery.charge.low", ST_FLAG_RW, 1, "%.0f", DU_FLAG_INIT, NULL },

7.a) recompile the drivers:

cd /usr/ports/sysutils/nut/work/nut-2.7.4/drivers/ && make

7.b) or if you modified not only the drivers:

cd /usr/ports/sysutils/nut/work/nut-2.7.4/ && make

8.a) now you will find the new apcupsd-ups in /usr/ports/sysutils/nut/work/nut-2.7.4/drivers/

8.b) the modiefied compiled files should be in /usr/ports/sysutils/nut/work/nut-2.7.4/ with the sourcode. to install it into the right place just type

make install


  1. Copy the compiled from the VM via SSH FTP or whatever to your FreeNas instance in my case this was only the /usr/local/libexec/nut/apcupsd-ups driver.

  2. set permissions and restart nut

chmod 0555 apcupsd-ups
service nut restart

Done!

Clone this wiki locally