To better understand init systems, I thought I'd try switching from OpenRC to s6.
The documentation is a bit to go through, as so is the wiki page, but this wiki by user Capezotte does a good job of explaining things with the examples.
I've also looked at the s6 scripts Artix uses for both general system initialization/cleanup and for some other services
Basically, for anyone wondering:
Your init scripts are in a "database." This could be a /etc/s6/db, /etc/s6/src, whatever. s6 has to "compile" those scripts into another folder like /etc/s6/[some unique name]. That would be what /etc/init.d is for OpenRC.
Each service has it's own folder, which must contain at least a file called "type" that should have one of the following and a terminating newline:
- oneshot # something that runs once and that's it, i.e. mounting the filesystem
longrun # something that runs in the background, i.e. sshd
bundle # a combination of the previous two or itself, each line listing one name of the oneshot longrun service or another bundle, i.e. a series of explicit mount commands that are services
Services can depend on one another, so say for binfmt you want to make sure the procfs is mounted first in the binfmt folder you have a subfolder named "dependencies.d" with a (usually) empty file named "mount-procfs" or whatever. (See the Artix scripts for examples)
To bring a service up, there needs to be a file named "up" that's a script (it needs to have a shebang) that runs the service. It could be a shell script, execline scripts, or even a Python, Perl, or Ruby script.
On the flip side, to do something specific to bring a service down there needs to be file named "down" that is also a script.
I don't know why I went into a very basic and brief description of s6 but there you go.
Looking at the Artix s6 scripts and services, is there anything missing from there that would been needed for Gentoo? I will say the OpenRC net.* init scripts are uh, quite large, so I don't know if I really need to implement all of that. The Artix scripts just have
Code: Select all
#!/bin/execlineb -P
exec ip link set up dev lo
Code: Select all
ip link set up dev foobarbaz # <- a nonexistent interface
Other than that for things like mounting the filesystems I can just use `mount -a` since my /etc/fstab is really simple:
Code: Select all
UUID=LONG-UUID /boot vfat defaults,noatime 0 2
UUID=LONGER-UUID none swap sw 0 0
UUID=LONGER-UUID / btrfs compress=zstd:10,clear_cache,noatime 0 1
tmpfs /var/tmp/portage tmpfs size=16G,uid=portage,gid=portage,mode=775,nosuid,noatime,nodev 0 0
The only other thing would be that in some of the OpenRC scripts' "depend" function there's "after", "before", etc and I'm not entirely sure if that's something needed or used in s6.



