Systemd unit file: Can/Should ExecStart and ExecStop run a script?

Lennart Poettering mzerqung at
Wed Oct 19 20:39:43 UTC 2011

On Wed, 19.10.11 14:21, Richard Shaw (hobbes1069 at wrote:

> Ok,  I took Jóhann's idea and ran with it, trying to preserve as much
> of the functionality of the sysv init script as I could. It turn out
> the need to change device permissions is only for people who want to
> run mythbackend as a real user, not root. I'm not sure if the
> following is valid, but here it is:
> [Unit]
> Description=MythTV backend service
> mysqld.service
> [Service]
> Type=forking
> PIDFile=/var/run/
> EnvironmentFile=-/etc/sysconfig/mythbackend
> Environment=MYTHCONFDIR=${MYTHTV_HOME:-/etc/mythtv}
> Environment=HOME=${MYTHTV_HOME:-/etc/mythtv}

The ${...:-...} syntax is a shell syntax and not supported in systemd.

You should be able to set set Environment=foo=bar first, and then place
EnvironmentFile= after it, so that it can override the previous settings.


Lennart Poettering - Red Hat, Inc.

More information about the devel mailing list