I have a new service implemented as a shell script, and created a /etc/init.d/
script to handle it in the way defined by the system. I followed the advice near the bottom of the docs page https://openwrt.org/docs/guide-developer/packages where it says
Very basic example of a suitable init.d script
and
# "new(er)" style init script
I found out that it does not work, and also why. Now I'm wondering whether this is a bug in the /lib/functions/service.sh
code, or if the behaviour is intended, and the bug is an omission in the documentation.
Basically, what happens is that the argument of the call to service_stop
(the path to the executable) is passed to the start-stop-daemon
as the -x
option. Now the man page of start-stop-daemon
has the following to say about passing script names with the -x
option:
-x, --exec executable
Check for processes that are instances of this executable. The
executable argument should be an absolute pathname. Note: this
might not work as intended with interpreted scripts, as the
executable will point to the interpreter. ...
Indeed, the process' commandline starts with /bin/sh
, as is expected for a shell script, so the match fails, when trying to stop the service.
So, what kind of bug is this? Shall this behaviour be changed in the future? I guess for the time being I'm better off with using the "old style" init.d
script?