Bug 87323

Summary: RFE: WorkingDirectory= should imply RequiresMountsFor= for the specified paths
Product: systemd Reporter: Stephen Benjamin <stephen>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: enhancement    
Priority: medium CC: rektide
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Stephen Benjamin 2014-12-15 10:06:01 UTC
Let's say I have a service target called 'pulp_celerybeat' that requires some content from the /var/lib/pulp directory in order to start.  

This directory contains RPM content (and quite a lot of it), so users may want to move this to a network share.

When I do, this service no longer starts because it can happen that /var/lib/pulp isn't mounted.

I've fixed this by creating:
  /etc/systemd/system/pulp_celerybeat.service.d/amendments.conf

With:
  [Unit]
  RequireMountsFor=/var/lib/pulp

Easy enough.

But systemd knows about all the mount targets.  It also knows that pulp_celerybeat uses /var/lib/pulp by this in the unit file:

  [Service]
  WorkingDirectory=/var/lib/pulp/celery/

Would it be possible to do this dependency management automatically?

Alternatively, supporting some directive like "RequiresDir" that we could ship in the packaged unit files would be useful, so if a user does move our storage to a network share, systemd would set the right mount dependencies automatically.
Comment 1 Lennart Poettering 2016-06-07 11:11:52 UTC
This has been implemented a while back.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.