[systemd-devel] Issues with Service Dependencies in Systemd

Robert Landers landers.robert at gmail.com
Tue May 21 20:46:43 UTC 2024


Hello hello,

I'm encountering an issue with Systemd service dependencies that I
can't seem to resolve despite following the documentation. Either
there's a misunderstanding on my part or there's a potential bug.

1. I cannot modify a specific service (immutable.service) because it's
generated dynamically by a tool which I also cannot modify.
2. I need to create a service (after-reboot.service) that runs after
the network is completely up and running and before immutable.service.
3. I need to prevent immutable.service from starting if
after-reboot.service fails to start.

Here is the unit file for after-reboot.service:

```

[Unit]
Description=Special Network Configuration
Before=immutable.service
After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/usr/local/bin/after-reboot
Type=notify
NotifyAccess=all

[Install]
WantedBy=multi-user.target
RequiredBy=immutable.service

```

The after-reboot script currently just exits with status code 1 to
simulate a failure.

After rebooting, after-reboot.service fails as expected, but
immutable.service still starts. Here are the status outputs:

```

systecmctl status after-reboot

× after-reboot.service - Special Network Configuration
Loaded: loaded (/etc/systemd/system/after-reboot.service; enabled;
vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2024-05-21 20:35:36 UTC; 4s ago

systemctl status immutable

● immutable.service - Immutable Service
Loaded: loaded (/etc/systemd/system/immutable.service; enabled; vendor
preset: enabled)
Active: active (running) since Tue 2024-05-21 20:35:39 UTC; 6s ago

```

What part of the documentation might I be missing, or is this a
potential bug in Systemd? I need to ensure that immutable.service does
not start if after-reboot.service fails.

Robert Landers
Software Engineer
Utrecht NL


More information about the systemd-devel mailing list