On 07/26/2011 07:37 PM, Lennart Poettering wrote:
On Tue, 26.07.11 09:28, Honza Horak ([email protected]) wrote:

Hi,

I wonder if a name of service can be accessed in service file somehow?

Let's have the following script (e.g. part of a former SysV init script):

thisname=`basename $0`
. /etc/$thisname

If I'd like to create the same behavior in systemd, e.g.:

EnvironmentFile=/etc/${thisname}

Is it possible?

It would be useful for many services to know its name, because if we
create a new service using
cp /lib/systemd/system/foo.service etc/systemd/system/bar.service,
we need to change the configuration file by hand always, which is
really easy to forget and make some problems unnecessarily.
Why would you copy a unit like this?

If you want to make changes to a unit file I recommend copying it from
/lib to /etc and edit it there, but that while keeping the same
filename.

Why would you want top copy a file and rename it? What's your usecase (I
don't doubt there is one, I am just curious).

(But yeah, as you noticed %n is what you are looking for.)

Spawn multiple instances for once.

so for instance I would like to run 2 different ssh servers on separated ports with separate confs and pid

I would copy /lib/systemd/system/sshd.service /etc/systemd/system/ssh2d.service

Adjust the pid and point the daemon to start with ssh2d_config

Using template in  a such scenario would be overkill me would think..

JBG

_______________________________________________
systemd-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to