大网数据广告活动
服务器运维问答

Create a custom /etc/init.d script in Debian 10 Buster

· 52CE 我爱测

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' ,…

问题原文

原帖链接 · tcdaly · CC BY-SA 4.0

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'?

已采纳解答

原帖链接 · Mantriur · CC BY-SA 4.0

Smartass response:

apt-get install sysvinit-core

Disclaimer: I have not done this on Buster, don't try it on an important system.

Assuming you'd like to stick with the new default since Jessie, systemd, the init.d scripts are not the preferred method. Configuring a systemd service unit would be the way to go.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。