[systemd-devel] Service name accessible in a unit file?

Honza Horak hhorak at redhat.com
Tue Jul 26 00:28:36 PDT 2011


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.

Honza


More information about the systemd-devel mailing list