rancher / k3os

Purpose-built OS for Kubernetes, fully managed by Kubernetes.
https://k3os.io
Apache License 2.0
3.5k stars 397 forks source link

add /etc/rc.d #732

Open dxlr8r opened 3 years ago

dxlr8r commented 3 years ago

Sometimes you want to add changes early to OpenRC, this is done through /etc/rc.d.

I suggest having /etc/rc.d as part of the image. Either as a directory, or as a symlink pointing to some persistent mount point.

dweomer commented 3 years ago

The k3os executable is /sbin/init which performs some magic before handing off to the openrc init system. As such, the drop-in directory for service definitions that you are looking for is at /etc/init.d. Please refer to https://github.com/OpenRC/openrc/blob/master/service-script-guide.md for how to write an openrc service. You will want to leverage a write_files entry in your config.yaml for making sure your service script content is overlayed on top of the ephemeral /etc hierarchy at every boot. You could also source the content from an external source or even a location on persistent disk via a boot_cmd or run_cmd. You will also want to make sure that your service is actually enabled/invoked. The cleanest way to do this while still leveraging openrc is to invoke something like rc-update add myservice via boot_cmd or run_cmd after establishing /etc/init.d/myservice on disk (write_files are processed before boot_cmd / run_cmd).

dxlr8r commented 3 years ago

Resources (files) in /etc/rc.d are automaticially sourced by OpenRC. I would argue it seems more logical to put extensions to OpenRC into that directory, even if one uses write_files to write your here doc to a file.

/etc/rc.d is for extending/modifing all services/the init itself, while /etc/init.d is per service. So I feel both should be present as they have different roles.

dweomer commented 3 years ago

Resources (files) in /etc/rc.d are automaticially sourced by OpenRC. I would argue it seems more logical to put extensions to OpenRC into that directory, even if one uses write_files to write your here doc to a file.

/etc/rc.d is for extending/modifing all services/the init itself, while /etc/init.d is per service. So I feel both should be present as they have different roles.

I was thinking about my initial response a day or two after writing it thinking I likely missed what you were shooting for. Thanks for the follow-up!