On Mon, 1 Aug 2016, Andrei Borzenkov wrote:
On Mon, Aug 1, 2016 at 2:23 PM, Michael Chapman <[email protected]> wrote:
On Mon, 1 Aug 2016, Andrei Borzenkov wrote:
[...]
So here goes what I've done:
1. Create a service and put it in the network-online.target:
/etc/systemd/system/change-target.service:
[Unit]
Description=Change Target
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecStart=/tmp/script.sh
TimeoutSec=60s
[Install]
WantedBy=network-online.target
This unit have conflicting requirements - on one hand it is
After=network-online.target, OTOH WantedBy=network-online.target
implies Before=network-online.target.
I've seen this asserted on this list a few times, but as far as I can tell
it isn't actually correct. After/Before are meant to be completely
orthogonal to Wants/Requires/etc., according to the documentation.
Unless DefaultDependencies= is set to no in either of releated units
or an explicit ordering dependency is already defined, target units
will implicitly complement all configured dependencies of type Wants=
or Requires= with dependencies of type After=.
man systemd.target
I just checked the code, and it looks like systemd explicitly *skips*
these default dependencies if they would create a loop. In
target_add_default_dependencies:
/* Imply ordering for requirement dependencies on target
* units. Note that when the user created a contradicting
* ordering manually we won't add anything in here to make
* sure we don't create a loop. */
- Michael
_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel