1

I have an Ubuntu 20.04 server, I'm connecting to a UPS. I want the Ubuntu server to shut down a truenas server, also on the same ups. The idea is that the UPS software on Ubuntu server triggers the shutdown on the trunas server when the battery is at 50%, The ubuntu server in turn triggers a shutdown of the trunas server, giving time for both boxes to power down gracefully.

I've set up the following script file truenas-off.sh:

echo "shutdown occurred at $(date)" >> /root/shutdown-events.log
ssh root@1.2.3.4 "midclt call system.shutdown"

I set the script up as described here, the only difference is I set mine to just shutdown.

cat  /etc/systemd/system/truenas-off.service
[Unit]
Description=Run truenas-off on shutdown

[Service] Type=oneshot RemainAfterExit=true ExecStart=/root/truenas-off.sh

[Install] WantedBy=multi-user.target

I've run ssh-keygen on the ubuntu server and ssh-copy-id root@truenas-IP and when I've issued sudo -i, authenticated, I can ssh root@trunasIP truenas-off.sh and the trunas turns off

It just doesn't seem to want to work automatically when I shutdown the Ubuntu server.

What am I doing wrong?

There's a similar problem, but not quite the same here: How to send shutdown command to servers

muru
  • 207,228
Jujuh
  • 11

0 Answers0