Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Systemd Service Directories #41

Open
adedomin opened this issue May 17, 2022 · 2 comments
Open

Systemd Service Directories #41

adedomin opened this issue May 17, 2022 · 2 comments

Comments

@adedomin
Copy link

systemd gives users the option in service units to create and point to various directories under paths like, /run/{app}, /var/lib/{app}, etc. Would It make sense to add these environment variables as possible returns if the XDG paths don't match? I guess I'm asking if I implement this, would you accept such a PR?

systemd.exec(5) has this table that seems to layout the variables set and roughly where they'd end up. I'm not sure why some of these paths would fall into the XDG_CONFIG_HOME paths if the service is a user service. I'd think XDG_DATA_HOME makes more sense.

           Table 2. Automatic directory creation and environment variables
           ┌────────────────────────┬────────────────┬───────────────────────┬──────────────────────────┐
           │Directory               │ Below path for │ Below path for        │ Environment              │
           │                        │ system units   │ user units            │ variable set             │
           ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
           │RuntimeDirectory=       │ /run/          │ $XDG_RUNTIME_DIR      │ $RUNTIME_DIRECTORY       │
           ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
           │StateDirectory=         │ /var/lib/      │ $XDG_CONFIG_HOME      │ $STATE_DIRECTORY         │
           ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
           │CacheDirectory=         │ /var/cache/    │ $XDG_CACHE_HOME       │ $CACHE_DIRECTORY         │
           ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
           │LogsDirectory=          │ /var/log/      │ $XDG_CONFIG_HOME/log/ │ $LOGS_DIRECTORY          │
           ├────────────────────────┼────────────────┼───────────────────────┼──────────────────────────┤
           │ConfigurationDirectory= │ /etc/          │ $XDG_CONFIG_HOME      │ $CONFIGURATION_DIRECTORY │
           └────────────────────────┴────────────────┴───────────────────────┴──────────────────────────┘
@k-e-l-p
Copy link

k-e-l-p commented May 17, 2022

I do not think that this change would make sense. This addition would be objectively useful, but, in my opinion, applications should be architectured in such a way, where non-standard (i.e non-XDG) paths should be provided to the application by systemd, via generated config, or command-line argument, if required.

systemd should not be a target for any piece of software, since it already has more than enough features to adapt to anything.

@asasine
Copy link

asasine commented Feb 17, 2024

I've created the systemd-directories crate for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants