Network UPS Tools (NUT)
NUT Server
Pre-requisites: The Wake-on-LAN setup must be completed in order to fully use this guide
You will need a UPS with a USB port for this setup.
Plug your Raspberry Pi into the UPS power socket and connect them via a USB cable.
Install the Network UPS Tools server package on your Raspberry Pi.
Inspect the NUT folder.
You should see the following configuration files which we will be customising in this guide.
Identify key information about your UPS.
Example output:
Back up the exiting ups.conf
file as a copy and edit the main file.
Replace the file contents by matching the output from the nut-scanner
output above. Use CTRL+T
and then CTRL+V
to clear all file contents. This defines the user and driver information of your UPS.
Example:
CTRL+O
, ENTER
, CTRL+X
to save and exit.
Back up the exiting upsd.conf
file as a copy and edit the main file.
Replace the file contents with the following. Use CTRL+T
and then CTRL+V
to clear all file contents. This will enable your other devices (NUT clients) to talk to your NUT server for shutdown/power-on signals.
CTRL+O
, ENTER
, CTRL+X
to save and exit.
Back up the exiting nut.conf
file as a copy and edit the main file.
Replace the file contents with the following. Use CTRL+T
and then CTRL+V
to clear all file contents. This sets your Raspberry Pi to the NUT server
mode.
CTRL+O
, ENTER
, CTRL+X
to save and exit.
Back up the exiting upsd.users
file as a copy and edit the main file.
Replace the file contents with the following. Use CTRL+T
and then CTRL+V
to clear all file contents. This sets the credentials for the NUT user.
CTRL+O
, ENTER
, CTRL+X
to save and exit.
Back up the exiting upsmon.conf
file as a copy and edit the main file.
Add the following as new lines to the bottom of the existing file content. This defines the actual power monitoring activities and consequent actions upon detecting a power restoration.
CTRL+O
, ENTER
, CTRL+X
to save and exit.
Create the online.sh
shell script which tells all your devices to power up when it detects that power supply to your UPS has been restored following a power outage.
Note: I am using a simple script to handle the automated power on sequence because I can't get my NUT to work as intended. Let me know if anyone managed to get yours working.
Paste the following content.
CTRL+O
, ENTER
, CTRL+X
to save and exit.
This online.sh script makes use of the wake_devices script that we created in the Wake-on-LAN page.
Make this shell script executable but set proper permissions for security.
Restart the NUT services.
Inspect the nut-server
and nut-monitor
for errors.
Example output:
CTRL+C
to exit logging view.
NUT Clients
The following steps need to be configured on all your other devices (e.g., validator node) to power down gracefully when there is a power outage.
Install the Network UPS Tools client on your device.
Inspect the NUT folder.
You should see the following configuration files which we will be customising in this guide.
Back up the exiting nut.conf
file as a copy and edit the main file.
Replace the file contents with the following. Use CTRL+T
and then CTRL+V
to clear all file contents. This sets your Validator Node to the NUT server
mode.
CTRL+O
, ENTER
, CTRL+X
to save and exit.
Back up the exiting upsmon.conf
file as a copy and edit the main file.
Add the following as new lines to the bottom of the existing file content. Replace IP_ADDRESS_OF_NUT_SERVER
with the actual internal IP address of your Raspberry Pi. This defines the actual power monitoring activities and consequent actions upon detecting a power restoration.
CTRL+O
, ENTER
, CTRL+X
to save and exit.
Create the onbatt.sh
shell script which tells your device to shut down gracefully when it detects that power supply to your UPS has been cut off (e.g., due to a power outage).
Note: I am using a simple script to handle the automated shutdown sequence because I can't get my NUT to work as intended. Let me know if anyone managed to get yours working.
Paste the following content.
CTRL+O
, ENTER
, CTRL+X
to save and exit.
Make this shell script executable but set proper permissions for security.
Allow the nut user to run only the /sbin/shutdown
to power down your device without needing the sudo
(superuser) password.
Add the following as a new line in the file.
Restart the NUT services.
Enable auto-power-on in BIOS (Optional)
This is optional as your Raspberry Pi will send a power-on signal to all your devices when power is restored but still good to have as a backup.
Restart your device and press F2 repeatedly during boot to enter BIOS Setup.
Select
Advanced
, then select thePower menu
.Expand the
Secondary Power Settings
sub-menu and setAfter Power Failure
toPower On
.Press F10 to save and exit the BIOS Setup.
Last updated