On 01/23/2016 11:33 AM, Armin K. wrote: > On 23.01.2016 17:28, Armin K. wrote: >>> On 01/13/2016 10:51 AM, Steve Dickson wrote: >>>> Hello, >>>> >>>> Is is possible to set a variable in the [Unit] >>>> section of a service? >>>> >>>> For example in rpc-gssd.service there is >>>> ConditionPathExists=/etc/krb5.keytab >>>> >>>> but for some installation the krb5.keytab >>>> is in a different place. The rpc.gssd daemon >>>> can be told this by setting a command line >>>> argument from the EnvironmentFile. >>>> >>>> So people have to edit both the EnvironmentFile >>>> and the rpc-gssd.service to make this change. >>>> >>>> So it would be nice if only the EnvironmentFile >>>> need to be edit and the change would happen >>>> in both places. >>>> >>>> Possible? >>>> >>>> steved. >> >> I'm sorry I'm not responding to the original mail, as I just subscribed >> yesterday to this list. >> >> I am not sure I fully understand what you want, but I think this might do it: >> >> [Unit] >> Description=test >> >> [Service] >> Type=oneshot >> Environment=TEST=blah >> EnvironmentFile=-/etc/systemd/system/test-env >> ExecStart=/etc/systemd/system/test ${TEST} >> TimeoutSec=0 >> RemainAfterExit=yes >> >> The /etc/systemd/system/test is a script that prints $1, depending on what is >> being passed to it. When env file is not present, it prints the TEST from the >> unit file. When env file is present, and TEST is set to something else, it >> prints its value. Is that what you are looking for? >> >> Cheers >> > > Ugh, sorry. You asked for the [Unit] section, not the [Service] section. > From what I see, it doesn't yet seem to be possible: > > [/etc/systemd/system/test.service:2] Unknown lvalue 'Environment' in section > 'Unit' > [/etc/systemd/system/test.service:4] Path in condition not absolute, > ignoring: $TEST > > You can always use some kind of hackery in ExecStartPre, but I don't think > that's > what anyone wants. > Well its to bad ConditionPathExists is not part of the [Service] section so I could use a shell variable...
steved. _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel