Skip to content

systemd environment file: lookup for both /etc/default (debian like) and /etc/sysconfig (centos)#350

Open
Adphi wants to merge 1 commit intokardianos:masterfrom
linka-cloud:systemd-env-dir
Open

systemd environment file: lookup for both /etc/default (debian like) and /etc/sysconfig (centos)#350
Adphi wants to merge 1 commit intokardianos:masterfrom
linka-cloud:systemd-env-dir

Conversation

@Adphi
Copy link
Copy Markdown

@Adphi Adphi commented Oct 18, 2022

As mentioned in the original Pull Request #80 (comment)

…and /etc/sysconfig (centos)

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
@kardianos
Copy link
Copy Markdown
Owner

This would be a breaking change for some users. On my OpenSUSE Micro Leap box, I have both an /etc/default directory and a /etc/sysconfig directory. The change looks in both, but returns the first of /etc/default and /etc/sysconfig, in that order. On my example system, it would shift from looking in sysconfig to default as they are both present.

I don't know the correct answer here. I don't think this PR is it.

@Adphi
Copy link
Copy Markdown
Author

Adphi commented Oct 18, 2022

Yes, but only if the environment file did not exist. For existing installation, unless I'm missing something, this should not change anything.

@jpvlsmv
Copy link
Copy Markdown

jpvlsmv commented Apr 11, 2023

The EnvironmentFile= parameter can be specified more than once in the systemd unit:

https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile=

This option may be specified more than once in which case all specified files are read.

I would suggest putting both into the template. If an existing installation has conflicting files in the two "standard" locations, things will get confusing anyway

(service_systemd_linux.go around line 124)

EnvironmentFile=-/etc/sysconfig/{{.Name}}
EnvironmentFile=-/etc/default/{{.Name}}

Anecdotally, the gitlab-runner project uses your library to install itself as a service. I needed to set an environment variable for it on my Ubuntu server, so I created /etc/default/gitlab-runner and updated the .service file to look to that. An upgrade broke things by overwriting my service change but wasn't obvious why, since /etc/default/gitlab-runner had all the settings appropriately. I ended up creating /etc/sysconfig/ and a symlink from /etc/sysconfig/gitlab-runner -> /etc/default/gitlab-runner

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

Successfully merging this pull request may close these issues.

3 participants