Re:Systemd Sucks, Long Live Systemd
by naftulikay on Friday January 13, 2017 @12:45AM
(#13388704)
> Now agreed, if your workflow demands that you embed a Bash while loop in a unit, you’re already in a bad place, but there are times where this is required for templating purposes.
It's right there in the post. I have indeed had to do something like this in the wild to run a Docker container with special needs.
Re:Systemd Sucks, Long Live Systemd
by colemickens on Friday January 13, 2017 @03:36AM
(#13389345)
I don't see how "templating purposes" answers the question. I deploy services on VMs that need to parameterized and I can parameterize via templating a written-to-disk shell script that is then just simply executed in the unit... or I can have more dynamic parameterization and use environment variables and Environment= lines in the unit. The latter solution means the substitution is effectively happening in the same place as if they were inlined parameters, so I can't imagine a scenario when it wouldn't be workable.
Both you and OP haven't mentioned why you needed to do it inline as opposed to in an external script, though.
Also, I'm failing to think of a scripting purpose that requires you to place non-trivial bash directly in a systemd unit that couldn't be solved by writing out the script somewhere and just invoking the script in the unit.