66
www.obarun.org
66-boot
66-boot is a program that is meant to run as pid 1, as a stage1 init: it performs the necessary early system preparation and execs into 66-scandir.
Interface
66-boot [ -h ] [ -s skel ] [ -m ] [ -l log_user ] [ -e environment ] [ -d dev ] [ -b banner ]
it performs some early preparation, spawns a process that will run the rc.init script, then execs into 66-scandir.
Options
- -h : prints this help.
-
-s skel : path of the skeleton files. By default this will be /etc/66/. The default can also be changed at compile time by passing the --sysconfdir=SYSDIR option to ./configure. This directory must contains the necessaries skeleton files to properly boot the machine, without it the system will not boot. skel must be an absolute path.
-
-m : umount the basename of the LIVE directory set into the init.conf skeleton file and mount a tmpfs on it.
-
-l log_user : the catch-all logger will run as the log_user user. Default is root.
-
-e environment : stage 1 init empties its environment before spawning rc.init skeleton file and executing into 66-scandir, in order to prevent those "kernel" environment variables from leaking into the whole process tree. The PATH variable will be the only one variable set into the environment. If you want to define environment variable use this options. environment must be an absolute path and reacts at the same as 66-scandir -e option.
-
-d dev : mount a devtmpfs on dev. By default, no such mount is performed - it is assumed that a devtmpfs is automounted on /dev at boot time by the kernel or an initramfs.
-
-b banner : prints banner to /dev/console at the start of the stage 1 init process. By default [Starts stage1 process ...].
Early preparation
When booting a system, 66-boot performs the following
operations:
- It prints a banner to /dev/console.
- It parse the init.conf skeleton file.
- It chdirs to /.
- It sets the umask to initial_umask.
- It becomes a session leader.
- It mounts a devtmpfs on dev, if requested.
- It uses /dev/null as its stdin (instead of /dev/console).
/dev/console is still used, for now, as stdout and stderr.
- It check the LIVE basename as valid mountpoint and unmount it in such case then mount a tmpfs on it if requested. If LIVE basename is not valid mountpoint it mount directly a tmpfs on it.
- It create LIVE directory invocating 66-scandir -v VERBOSITY -l LIVE -b -c -s skel more -L user_log if requested.
- It initiate the early services of TREE invocating 66-init -v VERBOSITY -l LIVE -t TREE classic.
- It reads the initial environment from environment if requested.
- It performs "the fifo trick", i.e. it redirects its stdout to the
catch-all logger's fifo, without blocking, before the catch-all
logger is even up (because it's a service that will be spawned a bit
later, when 66-scandir is executed).
- It forks a child, also called stage2
- The child blocks until the catch-all logger runs.
- The child starts service of tree TREE.
- The child becomes a session leader.
- It also makes the catch-all logger's fifo its stderr.
- It execs into 66-scandir -v VERBOSITY -l LIVE -u
with LIVE/scandir/0 (default /run/66/scandir/0) as its scandir.
- 66-scandir pass the relay to s6-svscan which
spawns the early services that are defined in TREE where one of those services is scandir-log, which is
the catch-all logger. When this service is up, 66-boot's
child unblocks.
- The child execs into rc.init.
If one of the above processus fail, 66-boot try to launch a Single-user login a.k.a. sulogin which let you the ability to fix the error. This case should not arrive.
Exit codes
66-boot never exits. It spawns the rc.init script and execs into 66-scandir, which runs forever until the machine stops or reboots.
Skeleton files
Skeleton files are mandatories and must exist on your system to be able to boot and shutdown the machine properly. By default those files are installed at /etc/66. Use the --sysconfdir=SYSDIR option at compile time to change it.
- init : 66-boot binary is not meant to be called directly, or be linked to the binary directory directly, because it takes command-line options. Thereby the init file is used to pass an options to 66-boot. By default 66-boot is launched without any options. This file should be copied by the administrator into the binary directory of your system.
- init.conf : this file contains a set of key=value pairs. All keys are mandatory and thereby the name of the key cannot be changed. This is the file used by an user to configure the boot process. By default:
- VERBOSITY=0 : increase/decrease the verbosity of stage1 process.
- LIVE=/run/66 : create the scandir at LIVE. The value by default will depend of the --livedir=live set a compile time. An absolute is expected as value.
- PATH=/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin : the initial value for the PATH environment variable, that will be transmitted to all the starting process unless it's overridden by a PATH declaration via the -e option. It is absolutely necessary for execline,s6, s6-rc and all 66 tools binaries to be accessible via PATH, else the machine will not boot.
- TREE=init : name of the tree to start. This tree should contain a set of service to bring up the machine to an operating system. 'classic' services will become earlier service at 66-init invocation. stage2 will start all other kind of service defined into it. It's the responsability of the administrator to correctly set this tree.
- RCINIT=/etc/66/rc.init : This file is launched at the end of the stage1 and run as stage2. It call 66-init to iniatiate all service of TREE except 'classic' which are already initiated on the stage1 than invoke 66-dbctl to bring up the services. An absolute path is expected as value pointing to the name of the file to run.
- RCSHUTDOWN=/etc/66/rc.shutdown : This is launched when a shutdown is requested also called stage3. It invoke 66-all to bring down all services of TREE. An absolute path is expected as value pointing to the name of the file to run.
- UMASK=0022 : set the value of the initial file umask for all the starting processes, in octal.
- RESCAN=0 : ask at s6-svscan to perform a scan every RESCAN milliseconds. It should be 0 at stage1 but its here just in case. It is strongly discouraged to set RESCAN to a positive value under 500.
- ISHELL=/etc/66/ishell : run ISHELL in case of stage2 crash. This file try to run a sulogin. An absolute path is expected as value pointing to the name of the file to run.
- rc.init : this file is called by the child of 66-boot to process the stage2. It invoke two command:
- 66-init -v${VERBOSITY} -l ${LIVE} -t ${TREE} database will initiate 'bundle' and 'atomic' service of the TREE. If the process fail, it try to run ISHELL as command to rescue.
- 66-dbctl -v${VERBOSITY} -l ${LIVE} -t ${TREE} -u will bring up all 'bundle' and 'atomic' service of the TREE. If the process fail, it try to run ISHELL as command to rescue.
- rc.shutdown : this file is called at shudown request when the administrator runs the shutdown, halt, poweroff or reboot command. It invoke one command:
- 66-all -v${VERBOSITY} -l ${LIVE} -t ${TREE} -f down will bring down all services for all tree marked enabled.
- ishell : this file is called by rc.init in case of crash of the stage2 and try to run a sulogin.
- halt : safe wrapper around 66-hpr -h command and accept any command options of it. This is the file called to halt the system and should be copied or symlinked by the administrator into the binary directory of your system
- poweroff : safe wrapper around 66-hpr -p command and accept any command options of it. This is the file called to poweroff the system and should be copied or symlinked by the administrator into the binary directory of your system
- reboot : safe wrapper around 66-hpr -r command and accept any command options of it. This is the file called to reboot the system and should be copied or symlinked by the administrator into the binary directory of your system
- shutdown : safe wrapper around 66-shutdown command and accept any command options of it. This is the file called to shutdown the system and should be copied or symlinked by the administrator into the binary directory of your system