[systemd-devel] Launching script that needs network before suspend
Tomáš Hnyk
tomashnyk at gmail.com
Sun Jan 23 22:13:59 UTC 2022
Hello,
I have my computer hooked up to an AVR that runs my home cinema and ideally
I would like the computer to turn off the AVR when I turn it off or suspend
it. The only way to do this is over network and I wrote a simple script
that does just that. Hooking it to shutdown was quite easy using
network.target that is defined when shutting down.
I am struggling to make it work with suspend though. When I look at the
logs, terminating network seems to be the first thing that happens when
suspend is invoked. I tried putting the script to
/usr/lib/systemd/system-sleep/ and it runs, but only after network si down,
so it fails. Running the script with systemd-inhibit
(ExecStart=/usr/bin/systemd-inhibit --what=sleep my_script) tells me that
"Failed to inhibit: The operation inhibition has been requested for is
already running".
Is there a way to make this work with service files by specifying that the
script needs to be run before network is shut down or would I need to run a
daemon listening for PrepareForSleep as here:
https://github.com/davidn/av/blob/master/av ?
Kind regards,
Tomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20220123/1c12b2ee/attachment.htm>
More information about the systemd-devel
mailing list