From 1bfba3b0be32306b078f5ee527b864e758b2c77b Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Fri, 26 Apr 2019 15:52:54 +0000
Subject: Make a single hpr. Full doc, first draft.
---
doc/index.html | 96 +++++---
doc/overview.html | 149 ++++++++++++
doc/quickstart.html | 178 ++-------------
doc/s6-linux-init-echo.html | 69 ++++++
doc/s6-linux-init-halt.html | 102 ---------
doc/s6-linux-init-hpr.html | 87 +++++++
doc/s6-linux-init-logouthookd.html | 84 +++++++
doc/s6-linux-init-maker.html | 451 ++++++++++++++++++-------------------
doc/s6-linux-init-poweroff.html | 102 ---------
doc/s6-linux-init-reboot.html | 102 ---------
doc/s6-linux-init-shutdown.html | 36 +--
doc/s6-linux-init-shutdownd.html | 16 +-
doc/s6-linux-init-telinit.html | 72 ++++++
doc/s6-linux-init-umountall.html | 61 +++++
doc/s6-linux-init.html | 154 +++++++++++++
doc/upgrade.html | 9 +
doc/why.html | 139 ++++++++++++
17 files changed, 1152 insertions(+), 755 deletions(-)
create mode 100644 doc/overview.html
create mode 100644 doc/s6-linux-init-echo.html
delete mode 100644 doc/s6-linux-init-halt.html
create mode 100644 doc/s6-linux-init-hpr.html
create mode 100644 doc/s6-linux-init-logouthookd.html
delete mode 100644 doc/s6-linux-init-poweroff.html
delete mode 100644 doc/s6-linux-init-reboot.html
create mode 100644 doc/s6-linux-init-telinit.html
create mode 100644 doc/s6-linux-init-umountall.html
create mode 100644 doc/s6-linux-init.html
create mode 100644 doc/why.html
(limited to 'doc')
diff --git a/doc/index.html b/doc/index.html
index c8d7e7e..1b4dda6 100644
--- a/doc/index.html
+++ b/doc/index.html
@@ -26,22 +26,52 @@ system, including a /sbin/init binary, on a Linux kernel.
- s6-linux-init is meant to automate creation of scripts revolving
-around the use of other skarnet.org tools, especially s6, in order
-to provide a complete booting environment with integrated supervision
-and logging without having to hand-craft all the details.
+ The resulting architecture follows the Unix philosophy (one job →
+one tool) as closely as possible, and is fully dedicated to the s6 way of
+managing a system:
+
+ - s6-svscan
+runs as process 1 for the whole machine lifetime.
+ - Every daemon is supervised.
+ - No logs are ever lost.
+ - Policy is entirely left to the user. Typically, any service manager
+can be run on top of s6-linux-init.
+
+
+
+ Nevertheless, the architecture is fully compliant with various
+empirical and historical specifications. For instance, it provides:
+
+
+
+ - utmp management compatible with sysvinit
+ - runlevel management, with a configurable default, overridable from the
+kernel command line
+ - sysvinit-like commands to shut the system down, including a
+shutdown command that follows the
+LSB specification
+
+
+ Getting started
+
Please read the documentation for the
s6-linux-init-maker program
carefully, but if you're impatient, you can also read this
-quickstart guide, which includes
-a small FAQ.
+quickstart guide.
+
+
+
+
Installation
Requirements
@@ -50,30 +80,31 @@ a small FAQ.
A Linux-based system with a standard C development environment
GNU make, version 3.81 or later
skalibs version
-2.6.4.0 or later
+2.8.0.1 or later
execline version
-2.3.0.4 or later
- s6-portable-utils version
-2.2.1.1 or later
- s6-linux-utils version
-2.4.0.2 or later
+2.5.1.0 or later
s6 version
-2.7.1.0 or later
+2.8.0.0 or later
-When you build s6-linux-init, the
- s6-linux-init-maker tool
-is created (as well as the shutdown commands);
- then you run that tool to create an init script,
-and then you can boot your system on that init script.
+ The following optional dependencies are also supported:
+
+ - If you're using musl and
+want nsswitch-like functionality:
+nsss version
+0.0.1.1 or later
+ - If you want secure utmp functionality:
+utmps version
+0.0.2.1 or later
+
+
- skalibs is a build-time dependency. If you are linking binaries
-against the shared version of the skalibs library, it also becomes a
-run-time and boot-time dependency.
- All the other listed packages are boot-time dependencies only.
+ All those dependencies are build-time and run-time,
+except possibly skalibs, which is not needed at run time if you are linking
+all the other packages against the static version of libskarnet.
Licensing
@@ -87,7 +118,7 @@ against the shared version of the skalibs library, it also becomes a
- The current released version of s6-linux-init is
-0.4.0.0.
+1.0.0.0.
- Alternatively, you can checkout a copy of the
s6-linux-init
git repository:
@@ -114,6 +145,14 @@ the previous versions of s6-linux-init and the current one.
Reference
+ General
+
+
+
Commands
@@ -123,9 +162,14 @@ the previous versions of s6-linux-init and the current one.
Related resources
diff --git a/doc/overview.html b/doc/overview.html
new file mode 100644
index 0000000..e1f3b31
--- /dev/null
+++ b/doc/overview.html
@@ -0,0 +1,149 @@
+
+
+
+
+
+ s6-linux-init: overview
+
+
+
+
+
+
+
+s6-linux-init
+Software
+skarnet.org
+
+
+ An overview of s6-linux-init
+
+ Organisation of the package
+
+
+ When installed, the s6-linux-init package provides the
+following:
+
+
+
+ - Binaries, that are typically installed in /bin
+
+ - s6-linux-init-maker is the main
+program of the package and is used to create /sbin/init scripts
+and their supporting environment depending on configuration parameters
+given on its command line.
+ - s6-linux-init-hpr is an
+implementation of the sysv halt, poweroff and reboot
+commands; s6-linux-init-telinit
+is an implementation of the sysv telinit command; and
+ s6-linux-init-shutdown
+is an implementation of the
+shutdown
+command. s6-linux-init is an
+implementation of stage 1 /sbin/init, but it needs to be
+given command-line options in order to do what the user has chosen.
+An invocation of s6-linux-init-maker
+will create proper wrappers for all those commands, named after their
+short sysv names; the wrappers are directly usable as turnkey replacements
+for sysv commands.
+ - Other binaries are support binaries, not meant to be called
+directly by the user. They are called internally, in scripts
+created by a
+s6-linux-init-maker invocation -
+typically in run scripts for early services.
+
+
+ - A small library, that for now contains a single symbol,
+s6_linux_init_logouthook(), intended for distributions using
+login programs that add utmp entries for users logging in and
+expect init to clean up after them when users log out. See
+the s6-linux-init-logouthookd
+page for details.
+
+ - Skeleton scripts, installed by default in
+/etc/s6-linux-init/skel; that location can be changed at build
+time via the --skeldir configure option. At
+s6-linux-init-maker, the scripts are copied from the skeleton
+directory to the scripts subdirectory of the directory created
+by s6-linux-init-maker, and the copy is meant to be edited
+by the user. The skeleton scripts are commented and examples of
+interaction with various service manager are given; it is recommended
+to review them, and possibly edit them too.
+These scripts are the following:
+
+ - rc.init: the script launching the system initialization
+procedure once stage 1 init is done and
+s6-svscan is
+safely running as pid 1.
+ - rc.shutdown: the script launching the system shutdown
+procedure when the admin runs a halt, poweroff,
+reboot or shutdown command.
+ - runlevel: the script executing a machine state change
+at boot time (normally invoked by rc.init, towards the default
+runlevel) or when the administrator runs a telinit command.
+
+
+
+ Organisation of the booted system
+
+
+ When a system has booted on an /sbin/init program created by
+s6-linux-init-maker, the following
+invariants are met:
+
+
+
+ - A tmpfs is mounted on /run - that location can be changed
+at build-time via the --tmpfsdir option to configure. The rest
+of this document assumes it is /run.
+ - s6-svscan is
+running as pid 1 on the /run/service scandir.
+ - Every process on the system is running with at least the environment
+defined in the /etc/s6-linux-init/current/env envdir. The
+/etc/s6-linux-init/current location can be changed at
+s6-linux-init-maker invocation time
+via the -c option.
+ - Some early services are defined in /run/service, and running.
+They are not seen by the service manager and should remain up all the time,
+until the machine shuts down: they are considered a part of the init system,
+even if they're not process 1. Each of these services uses very few resources.
+The services are:
+
+ - s6-svscan-log: the catch-all logger
+ - s6-linux-init-shutdownd: the shutdown manager, running
+the shutdown sequence in a reproducible environment when a shutdown command
+is executed, then performing the last shutdown steps.
+ - s6-linux-init-runleveld: the runlevel manager, running
+the runlevel script in a reproducible environment when a telinit
+command is executed.
+ - (optionally) s6-linux-init-logouthookd: a local service performing
+utmp record cleanup duty for patched login programs.
+ - (optionally) s6-linux-init-early-getty: the early getty,
+allowing the user to login even if rc.init fails early.
+ - (optionally) utmpd and wtmpd: the services performing
+utmp and wtmp access when utmps is
+used.
+
+
+
+ Integration with the service manager
+
+
+ The s6-linux-init package's duties stop where the service manager's start.
+s6-linux-init simply brings the system up to the point where it is stable and
+operational enough for the service manager to take over; and at shutdown
+time, s6-linux-init just tells the service manager to bring down the services,
+and then performs the last steps of the shutdown: killing all the remaining
+processes, unmounting the file systems and halting/powering off/rebooting
+the machine.
+
+
+
+ All the interactions between s6-linux-init and the service manager are
+configurable: they happen in the rc.init, rc.shutdown
+and runlevel scripts. Examples are provided in the skeleton
+scripts, that you should review and edit.
+
+
+
+
diff --git a/doc/quickstart.html b/doc/quickstart.html
index 6a0069b..b214443 100644
--- a/doc/quickstart.html
+++ b/doc/quickstart.html
@@ -3,9 +3,9 @@
- s6-linux-init: quickstart and FAQ
-
-
+ s6-linux-init: quickstart
+
+
@@ -16,7 +16,7 @@
skarnet.org
- Quickstart and FAQ for s6-linux-init
+ Quickstart for s6-linux-init
Quickstart
@@ -25,175 +25,27 @@
- - Install s6-linux-init itself.
- - Save your old /sbin/init binary.
- Save and remove your old /etc/s6-linux-init directory, if you have one.
+ - Install s6-linux-init itself.
+ - Save your old /sbin/init, /sbin/telinit, /sbin/shutdown,
+/sbin/halt, /sbin/poweroff and /sbin/reboot binaries.
- Make sure you have a /run directory.
- - Write a machine initialization script in /etc/rc.init and
-a machine shutdown script in /etc/rc.shutdown. Make sure they are
-executable. See below for more information on how to write these scripts.
+ - Edit the scripts in /etc/s6-linux-init/skel.
- Check that your devtmpfs is automounted by your kernel at boot time. If it is not,
add the -d 1 option to the s6-linux-init-maker command line below.
- As root, run:
- rm -rf /tmp/s6-linux-init /tmp/init
- s6-linux-init-maker /tmp/s6-linux-init
- mv /tmp/s6-linux-init /etc/
- ln -sf /etc/s6-linux-init/init /sbin/init
+ rm -rf /tmp/blah
+ s6-linux-init-maker -1 -G "/sbin/getty 38400 tty1" /tmp/blah
+ rm -rf /etc/s6-linux-init/current
+ mv /tmp/blah /etc/s6-linux-init/current
+ cp -a /etc/s6-linux-init/current/bin/* /sbin/
- Reboot.
- Congratulations! your machine is now running a s6-based init system.
- - To shut the machine down, use the
-s6-halt,
-s6-poweroff or
-s6-reboot command as appropriate.
+ - To shut the machine down, use /sbin/shutdown, /sbin/halt,
+/sbin/poweroff or /sbin/reboot as usual.
- What should go into /etc/rc.init and /etc/rc.shutdown ?
-
- /etc/rc.init
-
-
- This script will be run after s6-linux-init has done is job, i.e.
-s6-svscan is running as process 1, and it
-is now up to /etc/rc.init to get the machine to its usable state.
-It normally contains a call to the service manager to bring up all the services;
-for instance, if you're using
-s6-rc as your service manager, and
-your top bundle (containing all the services you want to bring up) is named
-ok-all, a proper /etc/rc.init could look like this:
-
-
-
#!/bin/sh
-s6-rc-init /run/service && exec s6-rc -u change ok-all
-
-
-
- The script can assume that:
-
-
-
- - There is a tmpfs partition, only writable by root, mounted on /run
- - There is a s6 supervision tree
-running on /run/service
- - /dev is mounted, but /proc and /sys are not
-
-
- /etc/rc.shutdown
-
-
- This script is spawned by s6-svscan
-when the administrator calls s6-halt,
-s6-poweroff or
-s6-reboot. When this script exits, the final
-shutdown sequence is run, which means that the supervision tree is dismantled,
-all processes are killed, the file systems are umounted and the system
-undergoes a hardware shutdown or reboot. So the goal of this script is to
-bring services down in an orderly fashion and perform all the necessary
-cleanups before all remaining processes are summarily killed.
-
-
-
- If you're using s6-rc as your
-service manager, a proper /etc/rc.shutdown could look like this:
-
-
-#!/bin/sh
-exec s6-rc -da change
-
-
- FAQ
-
- Why is it so complicated to use s6 as an init process? It's much
-simpler with runit.
-
-
- Yes, runit is simpler, because it provides a simple
-runit binary
-suitable as a /sbin/init program and calls scripts to
-handle the three stages of init. However, the runit design has a
-few perfectible points:
-
-
-
- - The one-time initialization is performed in /etc/runit/1, but
-the supervision tree is not run until /etc/runit/2, which means
-means that it is impossible to start supervised services during the
-one-time initialization. Early daemons such as udevd, for
-instance, have to remain unsupervised.
- - runit runs with its descriptors pointing to /dev/console,
-which means that error messages from the supervision tree, and uncaught
-logs, will be displayed on the system console; they are not saved beyond
-the console buffer capabilities.
- - The runit supervision tree is of height 3
-(runit, runsvdir, runsv), when height 2 is enough - some init
-systems, like sysvinit, systemd or launchd, even provide a
-supervision tree of height 1! (At the expense of complexity in the init
-process, of course.) Height 3 is a bit redundant, because the supervision
-capabilities of the root will be redundant with either those of the trunk
-or those of the branches. Its display is also aesthetically less pleasing than
-height 2: try out ps afuxww on a runit-based system.
-Yes, this point is extremely minor, but still deserves a mention. :-)
-
-
-
- Running a s6-based init addresses those issues:
-
-
-
- - Save for the initial tmpfs mount, all of the machine
-initialization runs in the stage 2 script, i.e. /etc/rc.init,
-and the supervision tree is already available at that point. This
-makes it possible to start one-shot services as well as long-run
-services in the desired order while ensuring that every long-run service
-is properly supervised, i.e. it lays the ground for a proper dependency
-management system.
- - s6-linux-init solves the problem of uncaught logs in a clean
-way, and any error message from any process in the system is
-guaranteed to end up in a logging directory. The only
-exception is error messages from the catch-all logger process itself:
-those naturally go to /dev/console.
- - When s6-svscan runs as process 1, the supervision tree is of
-height 2, and ps afuxww looks clean.
-
-
-
- To sum up, a s6-based init is cleaner than a runit-based
-init; it's a bit more complex to set up, but it organizes the system
-in a better way, without using more resources. And the goal of
-s6-linux-init is to make the setup more accessible.
-
-
- My /etc/rc.init script is not printing anything!
-
-
- You probably gave the -r option to
-s6-linux-init-maker, and
-your /etc/rc.init's output is being logged into the
-/run/uncaught-logs directory instead of printed to
-/dev/console.
-
-
- I want to run s6 in a container, and I just want to log
-to stdout/stderr, without this tmpfs and /dev/console
-stuff and
-without having a catch-all logger inside the container. Is it
-possible ?
-
-
- Yes, it is possible, but then s6-linux-init may not be what you
-are looking for. For your case, it will be simpler to run s6-svscan
-directly!
-
-
-
- If you are using
-Docker, there is a
-s6-overlay
-project specifically made for integrating s6 into Docker images.
-
-