Page MenuHomePhabricator

/etc/systemd/system/unit.service.d vs /lib/systemd/system/unit.service.d
Closed, ResolvedPublic

Description

What's the correct location as package upstream when extending systemd unit files? /etc/systemd/system/unit.service.d or /lib/systemd/system/unit.service.d?

I might have made a mistake in T306 (pull).

Figuring this out is important, so I can submit a fixed pull request and also because I plan to use similar overrides.

For example, timesync should extend the systemd unit file sdwdate.service by [Unit] (newline) Requires = msgcollector.service.

And another example, analogous to T306, swap-file-creator.service should be extended by [Unit] (newline) ConditionPathExists = !/usr/lib/qubes-whonix.

Example...


a)

/etc/systemd/system/rads.service.d/40_qubes.conf

sudo systemd-delta
[EXTENDED]   /lib/systemd/system/rads.service → /etc/systemd/system/rads.service.d/40_qubes.conf

b)

/lib/systemd/system/rads.service.d/40_qubes.conf

sudo systemd-delta
[EXTENDED]   /lib/systemd/system/rads.service → /lib/systemd/system/rads.service.d/40_qubes.conf

Details

Impact
High

Event Timeline

Patrick created this task.May 17 2015, 3:46 PM
Patrick raised the priority of this task from to Normal.
Patrick updated the task description. (Show Details)
Patrick added projects: Whonix 11, systemd.
Patrick set Impact to High.
Patrick added subscribers: Patrick, HulaHoop, nrgaway.

My understanding is distribution package file go in /lib/systemd/system.

Administrator or local files go in /etc/systemd/system

Users can further extend within home directory

If you are simply extending a unit file; adding some extra condition, modifying its behaviour, over-riding the normal behaviour (adding an alias) to that what is published by upstream, the configuration files would go in /etc/systemd/system.

Your example of timesync above is not extending msgcollector or over-riding the behaviour of msgcollector in any way and only is requiring msgcollector to be available in order to start and therefore would be placed in /lib/systemd/system. The required statement should also be in the main timesync systemd unit file, not in a .d directory since it is required in all use cases

In the example of qubes needing an override, and since that would be local specific, the configuration override would go in /etc/systemd/system.

Anything that is putting a condition on ConditionPathExists = !/usr/lib/qubes-whonix, should not be included in upstream package at all, and qubes-whonix should be responsible to add the condition in /etc/systemd/system so I would need to know which files I should be doing this for. So far I it has rads and whonix-initializer

Patrick updated the task description. (Show Details)May 18 2015, 1:19 PM

Your example of timesync above is not extending msgcollector or over-riding the behaviour of msgcollector in any way

Yes, and that's okay.

and only is requiring msgcollector to be available in order to start and therefore would be placed in /lib/systemd/system.

The intention is "if timesync is installed [which is an sdwdate gui plugin], then sdwdate.service requires msgcollector.service be running". I guess that's working.

The required statement should also be in the main timesync systemd unit file, not in a .d directory since it is required in all use cases

timesync is not a daemon, doesn't have a systemd unit file.

In the example of qubes needing an override, and since that would be local specific, the configuration override would go in /etc/systemd/system.

Yes. That way also advanced users who want to undo that setting can do that more easily by deleting the file from /etc.

Anything that is putting a condition on ConditionPathExists = !/usr/lib/qubes-whonix, should not be included in upstream package at all, and qubes-whonix should be responsible to add the condition in /etc/systemd/system so I would need to know which files I should be doing this for. So far I it has rads and whonix-initializer

Yes. By your previous choice (initial implementation of qubes-whonix), I think that is rads, whonix-initializer and swap-file-creator.

Patrick closed this task as Resolved.May 18 2015, 1:32 PM
Patrick claimed this task.

Thanks, the answer is clear to me now.