Score:1

How to send pending shutdown message to systemd services

za flag

I'm using Fedora CoreOS with the automatic updater enabled, which is great for my use case. Already, when logged in interactively, the system warns about an imminent shutdown/restart via the console, with the same mechanisms described in the answers like Sending shutdown messages to all clients from server

However, the "actual" users of this server aren't Linux users with SSH access but access servers like an IRC or other services. I would like to "catch" the shutdown warning message and forward it to each of the services, s.t. they can broadcast it.

The services are orchestrated using unprivileged podman/docker containers ran through systemd (podman-generate-systemd) user units.

I can (ab)use the ExecStopPre setting in the systemd unit to always sleep 5m before shutting down the unit. This isn't precisely what I want, though, as I'd like to be able to restart/stop a service immediately, when done manually using systemctl --user stop/restart.

I currently see two paths that could enable this:

  1. some way for units to listen to wall messages and forward them
  2. some way of specifying --ignore ExecStopPre on the console.

The latter can be, albeit unergonomically, be achieved using systemctl --user edit --runtime. However, the second approach has the downtime of (ab)using ExecStopPre while it may be needed for other purposes already.

Nonetheless, I'd be glad for ideas on how to achieve (1) or to make (2) a bit more nice to work with. Or even completely different approaches to the problem.

in flag
Maybe using `After=final.target` like in https://unix.stackexchange.com/a/479048 ? (Just a wild guess. I haven't used it myself)
ljrk avatar
za flag
@ErikSjölund Thanks, I didn't know of this setting -- but if the system is already remounted as r/o the service wouldn't be able store the current state to the disk anymore, I think.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.