備忘
安裝 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