Customizing a fedora 33 shutdown

I have an application running in two containers inside a fedora 33. The containers need to be stopped in a specific way which already has a script for it.
To make sure that the containers are always stopped correctly and sequentially before shutdown, i want to customize the system’s shutdown process. I found this which seems to suggest i cant directly stop my containers before starting the shutdown process (since systemctl stops everything in parallel).
I noticed, however, that the shutdown command is a symbolic link at /usr/sbin/shutdown for some users and at /sbin/shutdown for the root user, both pointing at /bin/systemctl.

Can i simply break both the links and substitute them by a script such as:


echo "doing stuff..."

or will this generate trouble in the future? If yes, is there a more elegant way to guarantee that my containers will always be stopped right before shutdown everytime the shutdown command is called?

You could do this but… you shouldn’t. Since you’re on Fedora Linux 33 you’re not getting security updates anyway, but if you did, they could very well break ypur kludge.

Instead, I’d suggest using systemd units to manage your containers (that is, make .service files for each), and then you can use the normal After or Requires information to express the dependencies.

Answered By: mattdm
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.