In this document, I will explain how to upgrade the default nut
(Network UPS Tools) version from 2.7.4-5.1ubuntu2 to 2.7.4-11ubuntu4.
It is basically the same process as the one used in my previous upgrade gist, Upgrade systemd on Ubuntu 18.04.
The main reason why you would follow this gist is because by default the UPS detection tool nut-scanner
is not available by default on Ubuntu 18.04 and can't be compiled correctly from source due to non standard library linking used that does not find the shared library even if it is correctly installed / loaded on the system.
Maybe you have been more lucky than me on your side and then you can simply leave this gist 😅 but on my side every fix attempts resulted in:
$ ./Projects/nut/tools/nut-scanner/nut-scanner
Cannot load USB library (/usr/lib/x86_64-linux-gnu/libusb.so) : file not found. USB search disabled.
No start IP, skipping NUT bus (old connect method)
You can get more references from here:
- NixOS/nixpkgs#91730
- networkupstools/nut#233
- networkupstools/nut#805
- https://lists.fedoraproject.org/archives/list/scm-commits%40lists.fedoraproject.org/message/KVXANOQPK6G7JMBPDT34XVRJWI7IBKOF/
sudo apt install build-essential libpowerman0-dev libusb-dev libltdl-dev
You might need to provide more dependencies to cover all the features provided by
nut
(Network UPS Tools)
# Patch sources file
sudo sed -e 's/# deb-src/deb-src/' -i /etc/apt/sources.list
# Update package cache
sudo apt update --fix-missing -y
sudo apt build-dep nut
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/nut/2.7.4-11ubuntu4/nut_2.7.4.orig.tar.gz
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/nut/2.7.4-11ubuntu4/nut_2.7.4-11ubuntu4.debian.tar.xz
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/nut/2.7.4-11ubuntu4/nut_2.7.4-11ubuntu4.dsc
# Move to home
cd $HOME
# Uncompress orig archive
tar xvzf nut_2.7.4.orig.tar.gz
# Move to decompressed folder
cd nut-2.7.4
# Uncompress debian files
tar xvJf ../nut_2.7.4-11ubuntu4.debian.tar.xz
This will also generate debian packages to install in next step.
dpkg-buildpackage -us -uc -d
This step is pretty long so be patient if you don't have a lot of CPU cores.
The argument
-d
is required to bypass the requested ubuntu version.
Now we will install the new compiled nut
version.
# Move back to home
cd $HOME
# List generated debian packages
ll | grep deb
# Create dedicated folder for debian packages
mkdir -v nut-274-debs
# Move all created packages
mv -v *.*deb nut-274-debs/
# Move to debian packages folder
cd nut-274-debs
# Install generated packages
sudo dpkg --auto-deconfigure -i *.deb
# Fix missing package like "powerman"
sudo apt --fix-broken install
This command will give us two things:
- The proof that
nut-scanner
has been correctly compiled and installed - Returns the installed
nut
version
nut-scanner --version
I've tried all the
ups*
commands and none of them has a-V
or--version
argument available, onlynut-scanner
has one.
It should return something similar:
SNMP library not found. SNMP search disabled.
Neon library not found. XML search disabled.
Network UPS Tools - 2.7.4
# Scan all available devices (default)
$ nut-scanner
# Scan USB devices only
$ nut-scanner -U
# Scan USB devices only but print in ups.conf format
$ nut-scanner -UN
In case you would like to try the compilation process on your side, here is what I've tried on my side before moving to the install from debian packages process:
# Install required dependencies
sudo apt install libusb-dev libltdl-dev
# Clone the project
git clone https://github.com/networkupstools/nut.git
# Move to the cloned project folder
cd nut
# Generation configuration files
./autogen.sh
# Get configuration options
./configure --help
# Provide minimal options to compile 'nut' with the 'nut-scanner' tool
# The provided '--with-user' and '--with-group' values has been
# cloned from what is used under Ubuntu 20.04.x
./configure --with-user=nut --with-group=nut --with-usb --with-dev
# Run compilation process with all CPU cores
make -j $(nproc)
# Move to the 'nut-scanner' folder
cd tools/nut-scanner/
# See if it works
./nut-scanner
If the last commands returns something like:
Cannot load USB library (/usr/lib/x86_64-linux-gnu/libusb.so) : file not found. USB search disabled.
No start IP, skipping NUT bus (old connect method)
But running find /usr/lib/x86_64-linux-gnu/ -iname "libusb.so"
returns:
/usr/lib/x86_64-linux-gnu/libusb.so
Then it means that you're getting suck at the point I was and I can only wish you "good luck" if you want to keep going on the installation from sources or you can simply follow steps described in this gist.
- https://launchpad.net/ubuntu/+source/nut
- https://launchpad.net/ubuntu/+source/nut/2.7.4-11ubuntu4
- https://github.com/networkupstools/nut
- https://wiki.archlinux.org/title/Network_UPS_Tools
- https://manpages.ubuntu.com/manpages/focal/en/man8/nut-scanner.8.html
- NixOS/nixpkgs#91730
- networkupstools/nut#233
- networkupstools/nut#805
- https://lists.fedoraproject.org/archives/list/scm-commits%40lists.fedoraproject.org/message/KVXANOQPK6G7JMBPDT34XVRJWI7IBKOF/
- https://gist.github.com/Jiab77/7df6e80804567f6f599b227cf2fafd00
- https://networkupstools.org/docs/user-manual.chunked/ar01s05.html
- https://networkupstools.org/download.html#_development_tree