hello together,
can't get a Nut-Script to work on a Proxmox 9 System. got a doku from a colleague.
first installed nut with apt install nut
set mode to netclient in /etc/nut/nut.conf
some settings in
/etc/nut/upsmon.conf
event control in /etc/nut/upssched.conf
an event-Script /etc/nut/upssched-cmd
set permissions
shutdown-Script /usr/local/bin/pre-shutdown.sh
next installed sudo, which is required for the nut-user
/etc/sudoers.d/nut-shutdown
restarted services
now i can successfully query the USV-status with
but everytime i execute the test_Script in /etc/net with:
i got an error on the main-console
"you are in rescue-mode, press Control-D to continue"
System is fresh installed proxmox VE 9.1 in VM for testing. does anyone see what im doing wrong here?
can't get a Nut-Script to work on a Proxmox 9 System. got a doku from a colleague.
first installed nut with apt install nut
set mode to netclient in /etc/nut/nut.conf
Code:
MODE=netclient
/etc/nut/upsmon.conf
Code:
MONITOR dummy@192.168.X.X 1 user pwXXX secondary
MONITOR h401ausv0@192.168.X.X 1 user pwXXX secondary
MONITOR h401ausv1@192.168.X.X 1 user pwXXX secondary
MINSUPPLIES 1
NOTIFYCMD /usr/sbin/upssched
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYFLAG LOWBATT SYSLOG+EXEC
POWERDOWNFLAG /etc/killpower
SHUTDOWNCMD "/sbin/shutdown -h now"
event control in /etc/nut/upssched.conf
Code:
CMDSCRIPT /usr/bin/upssched-cmd
PIPEFN /run/nut/upssched.pipe
LOCKFN /run/nut/upssched.lock
AT ONBATT * START-TIMER immediate_shutdown 0
AT ONBATT * START-TIMER forced_shutdown 180
AT ONBATT * START-TIMER hard_deadline 300
AT ONLINE * CANCEL-TIMER immediate_shutdown
AT ONLINE * CANCEL-TIMER forced_shutdown
AT ONLINE * CANCEL-TIMER hard_deadline
AT LOWBATT * EXECUTE forced_shutdown
an event-Script /etc/nut/upssched-cmd
Bash:
#!/bin/sh
case "$1" in
immediate_shutdown)
/usr/bin/sudo /usr/local/bin/pre-shutdown.sh
;;
forced_shutdown)
/usr/bin/sudo /sbin/shutdown -h now "USV: forced shutdown after 3 min"
;;
hard_deadline)
/usr/bin/sudo /sbin/shutdown -h now "USV: 5 min deadline reached"
;;
*)
exit 1
;;
esac
set permissions
Code:
chmod 0755 /etc/nut/upssched-cmd
shutdown-Script /usr/local/bin/pre-shutdown.sh
Bash:
#!/bin/bash
set -euo pipefail
logger -t nut-shutdown "USV EVENT: immediate shutdown triggered"
systemctl isolate rescue.target
logger -t nut-shutdown "SIGTERM to all processes"
killall5 -15
sleep 5
logger -t nut-shutdown "SIGKILL to all processes"
killall5 -9
sync
logger -t nut-shutdown "shutdown now"
/sbin/shutdown -h now
next installed sudo, which is required for the nut-user
Code:
apt install sudo
visudo -f /etc/sudoers.d/nut-shutdown
/etc/sudoers.d/nut-shutdown
Code:
nut ALL=(root) NOPASSWD: /usr/local/bin/pre-shutdown.sh
nut ALL=(root) NOPASSWD: /sbin/shutdown
restarted services
Code:
systemctl restart nut-client
systemctl restart nut-monitor
now i can successfully query the USV-status with
Code:
upsc dummy@192.168.X.X
upsc h401ausv0@192.168.X.X
but everytime i execute the test_Script in /etc/net with:
Code:
./upssched-cmd immediate_shutdown
i got an error on the main-console
"you are in rescue-mode, press Control-D to continue"
System is fresh installed proxmox VE 9.1 in VM for testing. does anyone see what im doing wrong here?