Jump to content

CentOS7 / systemd script broken


harisund
Go to solution Solved by fc7,

Recommended Posts

harisund

Here's the situation. I am installing the latest server on Cent OS 7. 

 

First, there's a file called /etc/default/emby-server.  This contains actual values.

 

Second, there's a file called /etc/emby-server.conf . This is fully commented out. 

 

Then, there's /usr/lib/emby-server/emby-server.sh. This file begins by sourcing "/etc/default/emby-server", and then over riding it by sourcing /etc/emby-server.conf. So far so good.

 

If a user wants to over ride values, he/she edits /etc/emby-server.conf and everything is dandy.

 

Now, the /usr/lib/systemd/system/emby-server.service is where everything breaks. The systemd service descriptor has the following ->

EnvironmentFile=/etc/emby-server.conf

 

This is bad. SystemD supports drop-in functionality where this can be over ridden. I over rode this with a drop-in config file that contained the line EnvironmentFile=/home/harisund/systemd_confs/emby-server.conf.

 

Guess what happened? SystemD changed the environment file to the above file which had all my settings, but the /usr/lib/emby-server/emby-server.sh decided to completely ignore this file, and simply used what's in /etc/default/emby-server.conf followed by /etc/emby-server.conf. Took me a while to figure out the "EnvironmentFile" value in the SystemD init script is totally being ignored by the shell script.

 

Here's the work around. Instead of using EnvironmentFile, use something like Environment=EMBY_CONF_FILE=foo.

 

Then in the /usr/lib/emby-server/emby-server.sh, change lines 18 through 21 to use EMBY_CONF_FILE instead of CONF_FILE and totally remove line 9.

Link to comment
Share on other sites

Is there any reason why you don't want/can't modify the user configuration file /etc/emby-server.conf?

The whole point of its existence is to allow users to override the default settings.

 

 

Sent from my iPad using Tapatalk

Link to comment
Share on other sites

harisund

Is there any reason why you don't want/can't modify the user configuration file /etc/emby-server.conf?

The whole point of its existence is to allow users to override the default settings.

 

 

Sent from my iPad using Tapatalk

 

 

To be honest, that's not really my point. My point is that the systemd file is misleading.  The "EnvironmentFile=/etc/emby-server.conf" implies this is a value that can be changed, when reality the code is written such that /etc/emby-server.conf is hard coded (which is bad coding practice IMO. /etc/default/emby-server.conf must be hard coded (and is, correctly), but the user configurable config file should truly be user configurable)

 

if you could remove the "EnvironmentFile=/etc/emby-server.com" from the systemd script, then it is implied that /etc/emby-server.conf is the only editable file, and there wouldn't be any ambiguity anywhere. 

 

Also, as far as possible I keep conf files version controlled in my home directory. Of course I could symlink, but then it is installed (and owned) by the RPM which installed emby-server. systemd's "drop-in" functionality is really awesome. I just need to create "/etc/systemd/system/emby-server.d" directory, put a file in there called "emby-override.conf" containing "EnvironmentFile=/home/hsundara/foo.conf" . That way I don't mess with the upstream-installed RPM at all, which is how it is intended to be used.

 

Also, the fix is trivial. If this was on github somewhere, I would like to submit a PR , but I couldn't find it anywhere. 

Edited by harisund
Link to comment
Share on other sites

  • Solution

I understand. We will review it with the other packages mantainers and probably we will just remove the EnvironmentFile from the systemd file in future releases. Thanks.

 

 

Sent from my iPhone using Tapatalk

Edited by fc7
  • Like 1
Link to comment
Share on other sites

harisund

I understand. We will review it with the other packages mantainers and probably we will just remove the EnvironmentFile from the systemd file in future releases. Thanks.

 

 

Sent from my iPhone using Tapatalk

That would be perfect, thank you.

 

Apologies if I came off as rude. 

Link to comment
Share on other sites

hurricanehrndz

I agree with him. The systemd startup should not have the environment file line at all

 

Sent from my D6603 using Tapatalk

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...