How can I override a systemd service conflict without losing changes during package updates?

0
0
Asked By MellowCedar42 On

I'm running both Postfix and Exim, with Exim configured to use an alternate port. Their systemd unit files declare a conflict, so they cannot run together. Editing the packaged unit under /usr/lib/systemd/system/ works temporarily, but package updates overwrite the changes. I tried creating override.conf drop-ins, but the conflict is still enforced. What is the proper way to customize these units, especially on RHEL 8, without modifying files managed by the package manager?

3 Answers

Answered By BrightNook18 On

Another clean option is to create separately named custom units based on the vendor files, remove the conflicting dependency there, and mask the original units if necessary. That avoids having two package-provided services competing over the same unit name, but it also means you’ll be responsible for maintaining the custom units. In most cases, copying the full unit to `/etc/systemd/system/` is simpler.

Answered By SilverMaple63 On

Since the setting you need to remove is a dependency, a drop-in cannot disable it. Copy the complete vendor unit into `/etc/systemd/system/`, for example: `sudo cp /usr/lib/systemd/system/postfix.service /etc/systemd/system/postfix.service`. Edit the copy, remove or change the `Conflicts=` line, then run `sudo systemctl daemon-reload`. This makes the `/etc` copy authoritative, so you’ll need to compare it with the vendor version after future package updates if the packaged unit changes.

Answered By CopperLynx7 On

For normal service changes, use a drop-in rather than editing the packaged file directly. Run `sudo systemctl edit postfix.service` or create a file such as `/etc/systemd/system/postfix.service.d/custom.conf`. Then run `sudo systemctl daemon-reload` and restart the service. Files under `/etc` take precedence over the vendor units in `/usr/lib` and survive package updates.

QuietOrbit29 -

The important exception here is `Conflicts=`. It represents a dependency, and systemd does not allow dependencies to be removed by simply setting `Conflicts=` to an empty value in a drop-in.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.