You are not logged in.

#1 2013-11-28 23:02:30

denn
Member
From: Russia
Registered: 2012-10-24
Posts: 5

[solved] systemd shutdown scripts

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

#2 2013-11-28 23:28:02

djgera
Developer
From: Buenos Aires - Argentina
Registered: 2008-12-24
Posts: 723
Website

Re: [solved] systemd shutdown scripts

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 wink

Offline

#3 2013-11-29 07:12:04

denn
Member
From: Russia
Registered: 2012-10-24
Posts: 5

Re: [solved] systemd shutdown scripts

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

Board footer

Powered by FluxBB