[systemd-devel] Shut down system after all sshd instances terminate

Lennart Poettering lennart at poettering.net
Fri Sep 4 14:37:32 UTC 2020


On So, 23.08.20 14:47, Daan De Meyer (daan.j.demeyer at gmail.com) wrote:

> Hi,
>
> After following
> http://0pointer.de/blog/projects/socket-activated-containers.html
> which details how to set up a socket activated container, I'm looking
> into ways to have the container automatically shut down when the last
> ssh connection terminates.
>
> My idea was to have each sshd instance take an inhibitor lock (the
> blocking kind) that prevents poweroff and make each sshd instance pull
> in poweroff.target. The problem is that the inhibitor documentation
> mentions that poweroff operations will fail if a blocking inhibitor
> lock is taken. For this to work, I need poweroff.target to wait
> indefinitely until all locks are released. Is this possible at the
> moment?
>
> Any other suggestions on how to achieve this are appreciated as well.

There's an RFE somewhere to optionally consider sessions poweroff
inhibitors. Together with IdleAction=poweroff you should then have all
you need.

Would love to merge a patch adding that. Should just be another bool
in logind.conf. And if enabled whenever we check if poweroff is
inhibited we check if number of active sessions is > 0.

Lennart

--
Lennart Poettering, Berlin


More information about the systemd-devel mailing list