Linux (NUT One-Click Script)

Configure NUT (Network UPS Tools) on Linux via the official one-click script to manage the WalleCube Smart UPS.

Linux (NUT One-Click Script)

WalleCube provides setup-nut.sh, an official one-click script built on top of NUT (Network UPS Tools) — the most widely used open-source UPS management framework, supporting thousands of devices with built-in network monitoring and multi-host capabilities. Download the script and finish the entire setup with a single command.

📥 Download the Script

Download setup-nut.sh

Or grab it directly from your terminal:

1
2
3
curl -fsSLO https://www.wallecube.com/software/setup-nut.sh
chmod +x setup-nut.sh
sudo bash ./setup-nut.sh

Overview

NUT (Network UPS Tools) is the industry-standard open-source UPS framework. WalleCube W150 / W180 are fully detected through the generic usbhid-ups driver.

setup-nut.sh automates the following:

  • Installs NUT packages (works with apt / dnf / yum)
  • Generates every configuration file under /etc/nut/
  • Creates the shutdown-timer event script
  • Sets the correct file ownership and runtime directories
  • Enables and starts the systemd services
  • Verifies the UPS connection automatically

Supported Systems

  • Debian / Ubuntu / Armbian
  • RHEL / CentOS / Rocky / AlmaLinux / Fedora
  • FnOS and other derivatives based on the above distributions

Requires one of apt-get, dnf or yum, and access to the distribution’s package repository.


Installation Steps

1. Connect the Hardware

Plug one end of the UPS USB signal cable into the UPS and the other end into the Linux host.

2. SSH In and Switch to root

1
2
ssh user@your-host
sudo -i

3. Download the Script

Pull the latest version directly from the WalleCube site:

1
2
curl -fsSLO https://www.wallecube.com/software/setup-nut.sh
chmod +x setup-nut.sh

Or click the Download setup-nut.sh button at the top of this page and scp it to the host.

4. Run the Script

1
sudo bash ./setup-nut.sh

The script then asks 4 questions. Press Enter to accept the defaults:

ParameterDefaultDescription
UPS NameupsIdentifier used by NUT, e.g. upsc ups@localhost
UPS DescriptionW150Human-readable model; change to your actual model (W150 / W180)
Monitor PasswordmypasswordPassword used by upsmon to log into upsd. Change this in production.
Shutdown Delay (sec)30How long on battery before the system shuts down if power isn’t restored

Confirm with Y to proceed.


What the Script Does

The script runs through 6 stages; any failure aborts the run.

① Install NUT

Detects the package manager and installs nut nut-client nut-server.

② Generate Configuration Files

All files live under /etc/nut/:

  • nut.confMODE=standalone (single-host mode)
  • ups.conf — declares the UPS, driver usbhid-ups, port auto
  • upsd.confLISTEN 127.0.0.1 3493 (loopback only)
  • upsd.users — defines the upsmon master account
  • upsmon.conf — event notifications and fallback shutdown command
  • upssched.conf — shutdown countdown and cancellation rules

③ Create /bin/upssched-cmd

Logs the event and runs /sbin/shutdown -h now when the timer expires.

④ Set Permissions

  • Auto-detects the nut / ups / root user and group
  • Config files become root:<nut-group> with mode 640 (password protected)
  • Ensures /var/run/nut exists with correct ownership

⑤ Enable and Start Services

Tolerates different systemd unit naming across distributions:

RolePreferred UnitFallback Units
UPS Drivernut-driver@<UPS_NAME>nut-driver / nut-driver.target
upsd Servernut-serverupsd
upsmon Monitornut-monitorupsmon

Each is enabled via systemctl enable --now.

⑥ Verify Connection

The script runs:

1
upsc ups@localhost

If device.type appears in the output, the UPS is connected and key fields (status, load, charge, voltage) are printed.


Status Check

Anytime later, check live status with:

1
upsc ups@localhost

Typical output (excerpt):

1
2
3
4
5
ups.status: OL          # OL = on line, OB = on battery, LB = low battery
ups.load: 12            # current load %
ups.charge: 100         # battery charge %
battery.voltage: 13.5
input.voltage: 230.0

Useful Commands

1
2
3
4
5
6
7
8
9
# Live UPS status
upsc ups@localhost

# Service status
systemctl status nut-server
systemctl status nut-monitor

# Event log (ONBATT / ONLINE / shutdown countdown)
tail -f /var/log/syslog

How It Works

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
Power loss
upsd detects ONBATT event
upsmon calls upssched
upssched starts the shutdown-timer countdown (default 30s)
   ├── Power restored → ONLINE event → timer cancelled
   └── Timer expires → /bin/upssched-cmd
                  /sbin/shutdown -h now

Troubleshooting

upsc returns Driver not connected

  • Check the USB cable; verify with lsusb that the UPS is enumerated.
  • Inspect the driver: systemctl status nut-driver@ups.

Access denied or wrong password

  • Make sure the password in /etc/nut/upsmon.conf matches /etc/nut/upsd.users.
  • When editing either file by hand, update both.

Shutdown does not trigger on power loss

  • Look for upssched-cmd entries in syslog.
  • Confirm /bin/upssched-cmd exists and is executable.
  • Verify /var/run/nut is owned correctly so the pipe/lock can be created.

Monitoring other hosts remotely

  • Add LISTEN <internal-IP> 3493 to /etc/nut/upsd.conf.
  • Add a slave user in /etc/nut/upsd.users.
  • On the remote host, configure upsmon.conf with the slave role pointing at this server’s IP.
  • Restart nut-server.

Re-apply different parameters

Just run the script again — it overwrites the config and restarts the services:

1
sudo bash setup-nut.sh

Uninstall

To fully remove the NUT configuration:

1
2
3
sudo systemctl disable --now nut-monitor nut-server "nut-driver@ups"
sudo apt-get remove --purge nut nut-client nut-server   # or dnf/yum remove nut*
sudo rm -rf /etc/nut /var/run/nut /bin/upssched-cmd

Configuration Reference

FilePurposeKey Fields
/etc/nut/nut.confRun modeMODE=standalone
/etc/nut/ups.confUPS hardwaredriver / port / desc
/etc/nut/upsd.confServer listenLISTEN
/etc/nut/upsd.usersMonitor accountspassword / upsmon master
/etc/nut/upsmon.confClient policyMONITOR / NOTIFYCMD / SHUTDOWNCMD
/etc/nut/upssched.confEvent schedulingAT ONBATT / AT ONLINE
/bin/upssched-cmdEvent handlershutdown-timer branch

References

这篇文档对你有帮助吗?

如果仍有疑问,欢迎随时联系我们的工程师团队。