You are not logged in.
Pages: 1
I'm trying to configure network-ups-tools to properly shutdown UPS after system is halted, so UPS and server could restart when the line power is regained. network-ups-tools contains /usr/lib/systemd/system-shutdown/nutshutdown shell script which checks if shutdown was caused by nut-monitor daemon and in this case shuts down the UPS. Unfortunately it seems that script isn't executed.
According to man systemd-shutdown:
Immediately before executing the actual system halt/poweroff/reboot/kexec systemd-shutdown will run all executables in /usr/lib/systemd/system-shutdown/ and pass one arguments to them: either "halt", "poweroff", "reboot" or "kexec", depending on the chosen action.
It sounds logical to use this feature rather than service executed at shutdown as this script will immediately cut the power.
I've created /usr/lib/systemd/system-shutdown/test.sh which writes echo $1 to file, but it also does not seem to be executed. What am I doing wrong?
Last edited by denn (2013-11-29 07:12:20)
Offline
Right, I use this feature also for my UPS (APC). Did you set the right file mode (0755) ?
In my case:
/usr/lib/systemd/system-shutdown/apc_killpower
#!/bin/sh
if [ -f /etc/apcupsd/powerfail -a "$1" = "poweroff" ]; then
/etc/apcupsd/apccontrol killpower
fi
At that point / is mounted ro, your file should be writed to /run for example, then from "initramfs" after pivot_root (if you have enabled shutdown hook) you can see it (just execute "ash" in /run/initramfs/shutdown at some point , ie just before poweroff
Offline
Thanks! I didn't realize that root filesystem is ro at this moment. So shutdown scripts are running fine, I probably should look for some problem with the UPS driver.
Offline
Pages: 1