[systemd-devel] What is the best way to run a shell script through 'ExecStart'

Muhammad Shakeel muhammad_shakeel at mentor.com
Mon Sep 30 06:25:15 PDT 2013


Greetings all,

I have been trying to convert a LSB initscript of a package into 
corresponding systemd service file. Most init scripts are simple and 
translating them into systemd unit files is non-trivial. In this case it 
is a relatively long script involving some loops.

1) Should I write a script file separately and then call it through 
'ExecStart'?
or
2) It would be good (and do-able) idea to fit whole script inside 
ExecStart=/bin/sh -c " <script>"? (If yes, I would prefer it as it will 
free me from hassle of maintaining two files)

If 2) seems appropriate, can anyone please share something which 
involves using of loop inside systemd service file?

Thanks,
Shakeel


More information about the systemd-devel mailing list