Alpine linux如何配置和管理自定义服务

备忘

安装 rc-service 服务

Alpine使用的是OpenRCinit系统,而rc-service是openrc的一部分,所以安装openrc即可,使用如下命令安装:
apk add openrc --no-cache

添加自定义服务

vim /etc/init.d/xxx

#!/sbin/openrc-run
 
name="actc"
command="/path/to/${name}"
#command_background="yes"
 
depend() {
	after sshd
}

管理服务

  • 列出所有可用服务
    rc-service --list

  • 启动/停止/重启 已有服务
    rc-service 服务名 start/stop/restart
    OR
    /etc/init.d/服务名 start/stop/restart

设置开机自启动

rc-update add {service-name}

参考:

https://wiki.alpinelinux.org/wiki/Writing_Init_Scripts
https://dev.alpinelinux.org/~clandmeter/other/forum.alpinelinux.org/forum/installation/adding-custom-service-rc-service.html
https://www.cyberciti.biz/faq/how-to-enable-and-start-services-on-alpine-linux/
https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management

posted @ 2020-08-09 11:38  jonnyan  阅读(7255)  评论(0编辑  收藏  举报