void-runit
void-runit copied to clipboard
pass VIRTUALIZATION var to runsvdir for scripts
This fixes the issues identified in https://github.com/void-linux/void-runit/pull/101 where the VIRTUALIZATION
environment variable exported in /etc/runit/1
is not available to runsv scripts. Allowing this will permit runsv services to do different things based on whether they're running in a container or not. (See https://github.com/void-linux/void-packages/pull/41273 for an example of when this would be needed - this PR needs some modifications but it will be able to use this variable to determine which setup commands to run.)
Supersedes and obviates https://github.com/void-linux/void-runit/pull/101
cc @CameronNemo
I don't like exporting that variable, this is not a standard and we shouldn't have to invent things and then depend on just for one service run script. The run script could just be changed to not exit if modprobe fails or use some other command to check if the module is loaded first and otherwise try modprobe and exit.
The run script could just be changed to not exit if modprobe fails or use some other command to check if the module is loaded first and otherwise try modprobe and exit.
That's what I had originally (https://github.com/void-linux/void-packages/pull/41272) but it turns out that you also need a different cgroups mount if you're in a container. You can put it in /etc/rc.local
but that can't be part of the install process and needs to be documented somewhere.
Having a way for runsv to determine whether or not you're in a container is really useful.
@sbromberger cgroups mounting is handled in this repo, in the pseudofs "core service".
@Duncaen - Is it your recommendation that we re-implement the functionality of detect_virt
within the runsv scripts that require it by grepping through /proc/1/environ
? This seems a bit wasteful when the work has already been done in 1
, but I can certainly modify the run script to do this.
@CameronNemo this is a special cgroups mount for docker: https://github.com/void-linux/void-packages/blob/7ac4f42d9795a6bd0e8c523fd70cb6ab9fe902fc/srcpkgs/moby/files/docker/run#L6 is the way it's currently done, but this doesn't work in containers: you need mount -t cgroup2 cgroup2 /sys/fs/cgroup/
instead.
#103 before I lose my train of thought
relevant past discussion: https://github.com/void-linux/void-docs/pull/151#issuecomment-671138650