[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: init system policy



Hi,

On 11/18/2014 05:39 PM, Matthias Urlichs wrote:
>>     trying to convert minidlna sysv init file to systemd, managed to have
>>     a working unit file but failed to split the configuration mimicing
>>     the ../default/minidlna content with the hability to make USER and
>>     GROUP configurable.
> 
> You _can_ do
> 
>>     ExecStart=sudo -u $USER_MINIDLNA -g GROUP_MINIDLNA /usr/sbin/minidlnad -S
> 
> but that's not the optimal solution here.
> 
> It's better IMHO to use a fixed user in your packaging -- why should that
> user be configurable in the first place? If the sysadmin _really_ needs to
> use a different user+group, they can add an overriding unit file to
> /etc/systemd/system/ (files get merged, so no need to copy the whole thing).

Ack.

> 
>>     ExecStartPre=/bin/mkdir -p /var/run/minidlna
> 
> You might want to use this opportunity to replace /var/run with /run.
> 
>>     ExecStartPre=/bin/chown $USER /var/run/minidlna

Both of these can be replaced with

  RuntimeDirectory=minidlda

which will create /run/minidlna, chown it to the user given in User= and
even remove it again once the service is stopped.

There's RuntimeDirectoryMode= if you need different permissions.

All of this is documented in systemd.exec(5) if you want more information.

Ansgar


Reply to: