[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Insert a script into systemd boot order at a specific location



Am 2015-03-13 16:03, schrieb Christoph Pleger:
[Unit]
Description=Installation and configuration
Requires=basic.target
Before=multi-user.target
After=basic.target

[Install]
RequiredBy=multi-user.target

Then, I called systemctl to set the correct symlinks for script.target and
script.service.

Then, I rebooted again and the result was the same as before.

Why does systemd not follow these instructions that my script has to be
executed before multi-user?

You are starting your service as part of multi-user.target, so you can't order it before it at the same time.
Also, targets are a bit special. What
Before=multi-user.target means in this context is: multi-user.target is only considered successfully, once all service which are ordered before multi-user.target have successfully started.

Say you have serviceA and serviceB, which are pulled in via multi-user.target.wants and they are order Before=multi-user.target, then both services will be started once multi-user.target is activated and as soon as both have successfully started, multi-user.target is considered active as well.

In your case, since you use DefaultDependencies=yes (which is the default), you already have some implicit dependencies/orderings, like Requires=basic.target, After=baseic.target so there is no need to specify that.

What you probably want, is hook into basic.target or sysinit.target, use DefaultDependencies=no, and specify the dependencies/orderings explicitly.


Reply to: