I need to develop an /etc/init.d
script to start and stop a server (binary executable) in Debian 10 Buster. Whereas in earlier versions of Debian, you would write a complete shell script that issues calls to 'start-stop-daemon'
, in recent releases these mechanics seem to be have been abstracted away. The manual page 'init-d-script'
gives a simple script that will start and stop a server based on setting a single variable 'DAEMON'
.
However I need to customise by writing a lock file to disc after the server starts, change the current working directory and pass a custom argument to the server.
The manual page refers to developing override functions such as 'do_start_override'
and 'do_stop_override'
which presumably are called instead of the default functions. How should I approach writing an override function? Should I copy and paste the function 'do_start_cmd()'
from '/lib/init/init-d-script'
and modify it? Or should I call the function 'start_daemon()'
that is defined in '/lib/lsb/init-functions'
?