s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit 917fab4b4ddf202b078eae83de3e1311f2111cfa
parent 5b7777a52d0b70b6094547c7cb4056aa9664f69d
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Tue, 24 Jan 2017 17:48:24 +0000

 Delete obsolete examples/ROOT, refer to s6-linux-init instead

Diffstat:
Mdoc/s6-svscan-1.html | 19+++++++++++--------
Dexamples/ROOT/README | 6------
Dexamples/ROOT/dev | 2--
Dexamples/ROOT/etc/README | 5-----
Dexamples/ROOT/etc/init | 2--
Dexamples/ROOT/etc/s6-init/README | 9---------
Dexamples/ROOT/etc/s6-init/env/PATH | 1-
Dexamples/ROOT/etc/s6-init/env/README | 6------
Dexamples/ROOT/etc/s6-init/init | 2--
Dexamples/ROOT/etc/s6-init/init-stage1 | 59-----------------------------------------------------------
Dexamples/ROOT/etc/s6-init/init-stage2 | 27---------------------------
Dexamples/ROOT/etc/s6-init/init-stage3 | 46----------------------------------------------
Dexamples/ROOT/etc/s6-rc/README | 9---------
Dexamples/ROOT/img/README | 4----
Dexamples/ROOT/img/tmpfs/README | 9---------
Dexamples/ROOT/img/tmpfs/dev/README | 4----
Dexamples/ROOT/img/tmpfs/dev/pts/README | 2--
Dexamples/ROOT/img/tmpfs/dev/shm | 2--
Dexamples/ROOT/img/tmpfs/service/.s6-svscan/README | 9---------
Dexamples/ROOT/img/tmpfs/service/.s6-svscan/SIGINT | 3---
Dexamples/ROOT/img/tmpfs/service/.s6-svscan/SIGUSR1 | 3---
Dexamples/ROOT/img/tmpfs/service/.s6-svscan/SIGUSR2 | 3---
Dexamples/ROOT/img/tmpfs/service/.s6-svscan/crash | 13-------------
Dexamples/ROOT/img/tmpfs/service/.s6-svscan/finish | 2--
Dexamples/ROOT/img/tmpfs/service/README | 5-----
Dexamples/ROOT/img/tmpfs/service/getty/README | 2--
Dexamples/ROOT/img/tmpfs/service/getty/run | 2--
Dexamples/ROOT/img/tmpfs/service/s6-svscan-log/README | 9---------
Dexamples/ROOT/img/tmpfs/service/s6-svscan-log/run | 13-------------
Dexamples/ROOT/img/tmpfs/shm/README | 3---
Dexamples/ROOT/img/tmpfs/tmp/README | 4----
Dexamples/ROOT/img/tmpfs/tmp/uncaught-logs/README | 4----
Dexamples/ROOT/mnt/README | 1-
Dexamples/ROOT/mnt/procfs/README | 1-
Dexamples/ROOT/mnt/rofs | 2--
Dexamples/ROOT/mnt/rwfs/README | 1-
Dexamples/ROOT/mnt/sysfs/README | 1-
Dexamples/ROOT/mnt/tmpfs/README | 1-
Dexamples/ROOT/mnt/tmpfs/dev/README | 14--------------
Dexamples/ROOT/proc | 2--
Dexamples/ROOT/run | 2--
Dexamples/ROOT/sys | 2--
Dexamples/ROOT/tmp | 2--
Dexamples/ROOT/var | 2--
44 files changed, 11 insertions(+), 309 deletions(-)

diff --git a/doc/s6-svscan-1.html b/doc/s6-svscan-1.html @@ -374,17 +374,20 @@ initialization tasks with the guarantee that s6-svscan is running. <p> This whole page may sound very theoretical, dry, wordy, and hard to grasp without a live example to try things on; unfortunately, s6 cannot provide -live examples without becoming system-specific. However, it provides a whole -set of script skeletons for you to edit and make your own working init. +live examples without becoming system-specific. </p> <p> - The <tt>examples/ROOT</tt> subdirectory in the s6 distribution contains -the relevant parts of a small root filesystem that works under Linux and follows -all that has been explained here. In every directory, a <tt>README</tt> file -has been added, to sum up what this directory does. You can copy those files -and modify them to suit your needs; if you have the proper software installed, -and the right configuration, some of them might even work verbatim. + However, the +<a href="http://skarnet.org/software/s6-linux-init/">s6-linux-init</a> +package provides you with the +<a href="http://skarnet.org/software/s6-linux-init/s6-linux-init-maker">s6-linux-init-maker</a> +command, which produces a set of working scripts, including a script +that is suitable as <tt>/sbin/init</tt>, for you to study and edit. +You can <em>run</em> the <tt>s6-linux-init-maker</tt> command even +on non-Linux systems: it will produce scripts that do not work as +is for another OS, but can still be used for study and as a basis for +a working stage 1 script. </p> </body> diff --git a/examples/ROOT/README b/examples/ROOT/README @@ -1,6 +0,0 @@ -Study this filesystem tree skeleton carefully. -After a few adjustments for your system, it can -become the basis for a very fast, efficient and -lightweight boot, with s6-svscan running as process 1 -for all of stage 2, i.e. practically the whole -system lifetime. diff --git a/examples/ROOT/dev b/examples/ROOT/dev @@ -1 +0,0 @@ -mnt/tmpfs/dev- \ No newline at end of file diff --git a/examples/ROOT/etc/README b/examples/ROOT/etc/README @@ -1,5 +0,0 @@ -Add this to your /etc/ directory. -/etc/leapsecs.dat is needed for skalibs programs to work properly! -/etc/init is what the kernel launches as process 1 if it does not -find an init binary in other places. Make sure you remove other -init programs to run this /etc/init as process 1 at boot time! diff --git a/examples/ROOT/etc/init b/examples/ROOT/etc/init @@ -1 +0,0 @@ -s6-init/init- \ No newline at end of file diff --git a/examples/ROOT/etc/s6-init/README b/examples/ROOT/etc/s6-init/README @@ -1,9 +0,0 @@ -This is an example directory containing booting scripts -that lead to s6-svscan running as process 1 in stage 2. - -Read them carefully and edit them to suit your needs. -Some scripts are Linux-dependent; they can be easily -adapted to other Unix systems. - -The skarnet.org servers actually run such a system, with -scripts that are based on this model. diff --git a/examples/ROOT/etc/s6-init/env/PATH b/examples/ROOT/etc/s6-init/env/PATH @@ -1 +0,0 @@ -/command:/usr/bin:/bin:/usr/sbin:/sbin diff --git a/examples/ROOT/etc/s6-init/env/README b/examples/ROOT/etc/s6-init/env/README @@ -1,6 +0,0 @@ - -This directory is read by s6-envdir at boot time. -It contains environment variables that will be present in -all the supervision tree, and all the launched services. -Make sure to remove this file, or else you'll have a -README environment variable in all your daemons. :) diff --git a/examples/ROOT/etc/s6-init/init b/examples/ROOT/etc/s6-init/init @@ -1 +0,0 @@ -init-stage1- \ No newline at end of file diff --git a/examples/ROOT/etc/s6-init/init-stage1 b/examples/ROOT/etc/s6-init/init-stage1 @@ -1,59 +0,0 @@ -#!/command/execlineb -P - -# This file is the first program run at boot time, -# as process 1. -# Edit it to suit your needs. - -# Make sure everything is sane and ignore input -s6-setsid -qb -cd / -umask 022 -fdclose 0 - -# This should be printed to the console -if { s6-echo "* init stage 1" } - - -# Mount /sys and /proc -if { s6-mount -wt sysfs sys /mnt/sysfs } -if { s6-mount -wt proc proc /mnt/procfs } - -# Close remaining handles to /dev/console -fdclose 1 fdclose 2 - -# Now no process has any open fd to /dev/console (or to -# anything for that matter). -# We can safely overwrite the minimal /dev with the real one. - -# in case some Linux kernel has mounted a devtmpfs -foreground { s6-umount /mnt/tmpfs/dev } - -# Make the tmpfs -if { s6-mount -wt tmpfs -o mode=0755,size=67108864 tmpfs /mnt/tmpfs } - -# Copy the image to the tmpfs -if { s6-hiercopy /img/tmpfs /mnt/tmpfs } - -# Now we have a working /dev and /tmp, and a minimal writable /service -# with a catch-all logger and a getty. We're good for stage 2 ! - -# Reopen stdin/stdout/stderr and make them point to the right places -redirfd -r 0 /dev/null -redirfd -wnb 1 /service/s6-svscan-log/fifo # (black magic: doesn't block) -fdmove -c 2 1 - -# Load the general environment -s6-envdir /etc/s6-init/env - -# Fork the "init-stage2" script and have it ready to start as soon -# as the catch-all logger is in place -background -{ - s6-setsid - redirfd -w 1 /service/s6-svscan-log/fifo # (blocks until the logger reads) - /etc/s6-init/init-stage2 -} -unexport ! - -# Start stage 2. -s6-svscan -st0 /service diff --git a/examples/ROOT/etc/s6-init/init-stage2 b/examples/ROOT/etc/s6-init/init-stage2 @@ -1,27 +0,0 @@ -#!/command/execlineb -P - -# This file is executed (not as process 1!) as soon as s6-svscan -# starts. It should perform all the remaining one-time initialization -# tasks. - -if -nt -{ - -# This should be logged in /mnt/tmpfs/uncaught-logs/current, -# NOT on /dev/console ! - if { s6-echo "* init-stage2 starting." } - -# Call your service manager commands here to run the boot scripts. - if { s6-rc-init /service } - if { s6-rc -u change normal-state } - -# We're done and the machine is fully operational. - s6-echo "* init-stage2 completed." -} - - -# If anything in the if -nt { } block fails, control jumps here. -# No need to do much because there's already an operational getty running. - -redirfd -w 1 /dev/console -s6-echo "\n!!!!!\ninit-stage2 failed, please log in and investigate.\n!!!!!" diff --git a/examples/ROOT/etc/s6-init/init-stage3 b/examples/ROOT/etc/s6-init/init-stage3 @@ -1,46 +0,0 @@ -#!/command/execlineb -S0 - -# This is the shutdown script, running as process 1. - -# Make sure we have no open handle to anywhere else -# than /dev/console -cd / -fdclose 0 -redirfd -w 1 /dev/console -fdmove -c 2 1 - -foreground { s6-echo "Syncing disks." } -foreground { s6-sync } - - -# Even if s6-rc and s6-svscan properly brought all the services down -# before exec'ing into this script, users might have launched -# background nohup processes, so we have to kill everything. - -foreground { s6-echo "Sending all processes the TERM signal." } -foreground { s6-nuke -th } -foreground { s6-sleep 1 } -foreground { s6-echo "Sending all processes the KILL signal." } -foreground { s6-nuke -k } - -# Here, s6-nuke sends a SIGKILL to every process on the system. -# It kills itself, but not before the SIGKILL has been broadcast. -# The "foreground" process runs as process 1, so it survives, -# and execs into the rest of the script when s6-nuke dies. - -# Reap the huge army of zombies we just created -wait { } - - -foreground { s6-echo "Syncing disks." } -foreground { s6-sync } # yes, it helps. -foreground { s6-echo "Unmounting disks." } - -# Unmount all your filesystems here, turn off swap, -# remount / read-only if needed, etc. -# foreground { s6-umount /mnt/rwfs } - -# Reboot, halt or poweroff the machine, depending on the parameter -# that was given to the script. -foreground { s6-echo "\nPerforming "${1}"." } -s6-${1} -f diff --git a/examples/ROOT/etc/s6-rc/README b/examples/ROOT/etc/s6-rc/README @@ -1,9 +0,0 @@ - If you are using s6-rc as your service manager, this directory should -be the place where you store your compiled service databases. - - The /etc/s6-init/init-stage2 script invokes s6-rc which expects to -find its data here by default. - - The /run/service/.s6-svscan/SIG{INT,USR1,USR2} scripts invoke -s6-rc to bring down all the managed services before shutting down -s6-svscan. diff --git a/examples/ROOT/img/README b/examples/ROOT/img/README @@ -1,4 +0,0 @@ -This directory is read-only. It contains an image of the -tmpfs that it copied as-is at boot-time (during stage 1 -init). It is only used at boot-time, it is never -written to. diff --git a/examples/ROOT/img/tmpfs/README b/examples/ROOT/img/tmpfs/README @@ -1,9 +0,0 @@ -/img/tmpfs is the hierarchy that will be copied to /mnt/tmpfs -during stage 1 init, so the basics are covered for stage 2: - - /dev points to a real, writable device directory - - /tmp points to a real, writable temporary directory - - /service points to a real, writable scan directory that -already contains basic services (s6-svscan's own logger and -an early getty) - - /mnt/tmpfs/uncaught-logs is the place in RAM where the -catch-all logger stores and rotates its logs. diff --git a/examples/ROOT/img/tmpfs/dev/README b/examples/ROOT/img/tmpfs/dev/README @@ -1,4 +0,0 @@ -This directory is the /dev image. -It should contain all your static devices. -It MUST contain at least /dev/null and /dev/console, -else the system will crash during stage 1 init. diff --git a/examples/ROOT/img/tmpfs/dev/pts/README b/examples/ROOT/img/tmpfs/dev/pts/README @@ -1,2 +0,0 @@ -The place (after it's copied to the tmpfs) where -the virtual devpts filesystem will be mounted. diff --git a/examples/ROOT/img/tmpfs/dev/shm b/examples/ROOT/img/tmpfs/dev/shm @@ -1 +0,0 @@ -../shm- \ No newline at end of file diff --git a/examples/ROOT/img/tmpfs/service/.s6-svscan/README b/examples/ROOT/img/tmpfs/service/.s6-svscan/README @@ -1,9 +0,0 @@ -This is the image of the control directory of the s6-svscan process -running as pid 1. -"crash" is run if s6-svscan fails. -"finish" is run when s6-svscan exits its loop. - - The "SIG*" files are run as children of s6-svscan when it receives -the corresponding signal. SIGINT, SIGUSR1 and SIGUSR2 will all -trigger "s6-rc -da change" (the service manager will shut down all -the services), then s6-svscan will be told to exit its loop. diff --git a/examples/ROOT/img/tmpfs/service/.s6-svscan/SIGINT b/examples/ROOT/img/tmpfs/service/.s6-svscan/SIGINT @@ -1,3 +0,0 @@ -#!/command/execlineb -P -foreground { s6-rc -da change } -s6-svscanctl -6 . diff --git a/examples/ROOT/img/tmpfs/service/.s6-svscan/SIGUSR1 b/examples/ROOT/img/tmpfs/service/.s6-svscan/SIGUSR1 @@ -1,3 +0,0 @@ -#!/command/execlineb -P -foreground { s6-rc -da change } -s6-svscanctl -0 . diff --git a/examples/ROOT/img/tmpfs/service/.s6-svscan/SIGUSR2 b/examples/ROOT/img/tmpfs/service/.s6-svscan/SIGUSR2 @@ -1,3 +0,0 @@ -#!/command/execlineb -P -foreground { s6-rc -da change } -s6-svscanctl -7 . diff --git a/examples/ROOT/img/tmpfs/service/.s6-svscan/crash b/examples/ROOT/img/tmpfs/service/.s6-svscan/crash @@ -1,13 +0,0 @@ -#!/command/execlineb -P - -# This file is run when an unrecoverable error happens -# to s6-svscan. Edit it to suit your needs. - -cd / -redirfd -r 0 /dev/console -redirfd -w 1 /dev/console -fdmove -c 2 1 - -foreground { s6-echo "s6-svscan panicked! Dropping to a root shell.\n" } - -/bin/sh -i diff --git a/examples/ROOT/img/tmpfs/service/.s6-svscan/finish b/examples/ROOT/img/tmpfs/service/.s6-svscan/finish @@ -1 +0,0 @@ -/etc/s6-init/init-stage3- \ No newline at end of file diff --git a/examples/ROOT/img/tmpfs/service/README b/examples/ROOT/img/tmpfs/service/README @@ -1,5 +0,0 @@ -This is the initial image of the scan directory. -When init executes into s6-svscan, s6-svscan will immediately -start the "s6-svscan-log" service, which logs s6-svscan's own -output, and the "getty1" service, which spawns a getty on -tty1 as early as possible, in case debugging is needed. diff --git a/examples/ROOT/img/tmpfs/service/getty/README b/examples/ROOT/img/tmpfs/service/getty/README @@ -1,2 +0,0 @@ -This service is started very early, to make sure a tty exists as soon -as s6-svscan is run, so early debugging is possible. diff --git a/examples/ROOT/img/tmpfs/service/getty/run b/examples/ROOT/img/tmpfs/service/getty/run @@ -1,2 +0,0 @@ -#!/command/execlineb -P -getty -L -H DEBUG 38400 tty1 diff --git a/examples/ROOT/img/tmpfs/service/s6-svscan-log/README b/examples/ROOT/img/tmpfs/service/s6-svscan-log/README @@ -1,9 +0,0 @@ -This service reads from the "fifo" named pipe and logs -what it reads to the /tmp/uncaught-logs log directory. -The whole supervision tree has its stderr redirected to "fifo", -as well as services that do not have their own logger. -So, /tmp/uncaught-logs is the catch-all logger: logs that aren't -caught anywhere else end up there. - - You should create the "fifo" named pipe in this directory, -belonging to nobody:nogroup with rights 0622. diff --git a/examples/ROOT/img/tmpfs/service/s6-svscan-log/run b/examples/ROOT/img/tmpfs/service/s6-svscan-log/run @@ -1,13 +0,0 @@ -#!/command/execlineb -P -redirfd -w 2 /dev/console -redirfd -rnb 0 fifo -s6-setuidgid nobody -exec -c -s6-log -bp t /mnt/tmpfs/uncaught-logs - -# The -p option is important: -# even if s6-svscan is told to kill everything, -# you do not want this logger to die. -# The -b option ensures s6-log processes lines one -# at a time, so it doesn't eat up too much memory -# in case of a problem spike. diff --git a/examples/ROOT/img/tmpfs/shm/README b/examples/ROOT/img/tmpfs/shm/README @@ -1,3 +0,0 @@ -This directory exists so /dev/shm points to a place -in the tmpfs. -It should have "1777" rights. diff --git a/examples/ROOT/img/tmpfs/tmp/README b/examples/ROOT/img/tmpfs/tmp/README @@ -1,4 +0,0 @@ -This directory contains what will be /mnt/tmpfs/tmp after -stage 1 init, so it contains everything /tmp should point -to. -It should have "1777" rights. diff --git a/examples/ROOT/img/tmpfs/tmp/uncaught-logs/README b/examples/ROOT/img/tmpfs/tmp/uncaught-logs/README @@ -1,4 +0,0 @@ -This directory should not belong to root, but to nobody:nogroup; -it should also have "2700" rights. -It is the catch-all logdir. -/tmp/uncaught-logs/current will be the current catch-all log file. diff --git a/examples/ROOT/mnt/README b/examples/ROOT/mnt/README @@ -1 +0,0 @@ -The directory containing all the real mount points. diff --git a/examples/ROOT/mnt/procfs/README b/examples/ROOT/mnt/procfs/README @@ -1 +0,0 @@ -/proc will be mounted here. diff --git a/examples/ROOT/mnt/rofs b/examples/ROOT/mnt/rofs @@ -1 +0,0 @@ -..- \ No newline at end of file diff --git a/examples/ROOT/mnt/rwfs/README b/examples/ROOT/mnt/rwfs/README @@ -1 +0,0 @@ -If you have a disk read-write filesystem, you may mount it here. diff --git a/examples/ROOT/mnt/sysfs/README b/examples/ROOT/mnt/sysfs/README @@ -1 +0,0 @@ -/sys will be mounted here. diff --git a/examples/ROOT/mnt/tmpfs/README b/examples/ROOT/mnt/tmpfs/README @@ -1 +0,0 @@ -The general tmpfs will be mounted here. diff --git a/examples/ROOT/mnt/tmpfs/dev/README b/examples/ROOT/mnt/tmpfs/dev/README @@ -1,14 +0,0 @@ -This directory (/mnt/tmpfs/dev on the root filesystem) will -be brutally overriden when the tmpfs is mounted. Its only -purpose is to provide an initial /dev/console to the kernel -when it starts process 1. -The directory should contain a working /dev/console device! - - init-stage1 will close all handles to this /dev/console, -then mount the tmpfs and copy the tmpfs image to the tmpfs -- the image contains a full version of /dev, which will then -be used. - This trick is necessary to have a working read-write /dev -when you have a root-only filesystem and when you cannot or -do not want to rely on fancy Linux-specific tricks such as -devtmpfs. diff --git a/examples/ROOT/proc b/examples/ROOT/proc @@ -1 +0,0 @@ -mnt/procfs- \ No newline at end of file diff --git a/examples/ROOT/run b/examples/ROOT/run @@ -1 +0,0 @@ -mnt/tmpfs- \ No newline at end of file diff --git a/examples/ROOT/sys b/examples/ROOT/sys @@ -1 +0,0 @@ -mnt/sysfs- \ No newline at end of file diff --git a/examples/ROOT/tmp b/examples/ROOT/tmp @@ -1 +0,0 @@ -mnt/tmpfs/tmp- \ No newline at end of file diff --git a/examples/ROOT/var b/examples/ROOT/var @@ -1 +0,0 @@ -mnt/rwfs/var- \ No newline at end of file