[systemd-devel] Creating unit file - conditional process arguments

Honza Horak hhorak at redhat.com
Tue Nov 22 04:27:11 PST 2011


Hi all,

Let's have the following case: the environment variable $FOO can be 
defined but it doesn't have to be. Then I want to pass this variable to 
a process in the unit file like "--foo $FOO", but only if the variable 
is not empty. Something like the following has been done in the SysV 
init script:

if [ "$FOO" ]; then
   MYARGS="--foo $FOO"
fi

Do I have to create the same bash script and execute it like:
ExecStartPre=/path/to/simple/script
ExecStart=/path/to/daemon $MYARGS

or is there any better way how to do it?

Thanks,

Honza


More information about the systemd-devel mailing list