Shutdown UPS with nut

gstyle

New Member
Jan 26, 2024
3
0
1
Hi everybody,

I bought an ups that is connected per usb to my proxmox server.
I installed nut, setup the connection etc.

With the standard config, I get a message "on battery" when I take the ups from power.
After 30min I get "low battery" and my proxmox server starts the shutdown process.
So far so good.

However, the ups stays on. This means, the server mainboard sees constant voltage. When the energy is back, the server does not startup automatically.

with the command
Code:
upscmd -u upsmon -p xxx idr600 shutdown.return
the ups shuts down and restarts when the energy is back.
But this is already after 5 seconds. So I am not able to shutdown in this time.
I tried to set override.ups.delay.shutdown in the ups.conf, but this parameter is not editable for my ups Riello IDR600.

I then implemented a custom shutdown script in /etc/systemd/system.

Code:
[Unit]
Description=Custom Shutdown Script

[Service]
Type=oneshot
ExecStart=/usr/local/bin/shutdown-script.sh

[Install]
WantedBy=multi-user.target

But it seems to be executed at a time, where the drivers for the ups are not loaded anymore. It does not shut down the ups, I forwarded the output to a file. The error message was: "Error: Connection failure: Connection refused".

So I am running out of ideas at the moment....
Does anybody know a way to initiate the "shutdown.return" shortly before my system is shutted down?

Cheers
Mario
 
I tried around a bit.

Seems that this script is also not started during shutdown, but in the boot process...

Does anybody know how to setup a systemd script that is executed during shutdown as late as possible?
But of course not to late so that the upscmd command does not work anymore.
 
The doc says:
Note that these executables are run after all services have been shut down, and after most mounts have been detached (the root file system as well as /run/ and various API file systems are still around though). This means any programs dropped into this directory must be prepared to run in such a limited execution environment and not rely on external services or hierarchies such as /var/ to be around (or writable).
So I think that the nut server structure is already shut down.

However the /sbin/halt approach is very interesting....
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!