summaryrefslogtreecommitdiff
path: root/system/s6/s6-svscanboot
diff options
context:
space:
mode:
authorLaurent Bercot <ska-adelie@skarnet.org>2018-08-14 19:52:39 +0000
committerLaurent Bercot <ska-adelie@skarnet.org>2018-08-15 15:12:16 +0000
commitafb0fe3ccead10a3a68f938e80c891fe9d9cb9d3 (patch)
treeb5809b8e852347718303fa2c93a5bc0c2eb07bfc /system/s6/s6-svscanboot
parentcdbdb41c2da9c3185122be33fdef720f7d9f0883 (diff)
downloadpackages-afb0fe3ccead10a3a68f938e80c891fe9d9cb9d3.tar.gz
packages-afb0fe3ccead10a3a68f938e80c891fe9d9cb9d3.tar.bz2
packages-afb0fe3ccead10a3a68f938e80c891fe9d9cb9d3.tar.xz
packages-afb0fe3ccead10a3a68f938e80c891fe9d9cb9d3.zip
Move s6 higher in the supervision chain
- Better s6 layout, with a place for early services and a place for packages to add their services later on. - s6-svscan is now supervised by sysvinit (instead of being run once by openrc) - s6-svscan is now the only process supervised by sysvinit. All the other "respawn" lines are delegated to s6. - utmpd and wtmpd are now early services instead of being added by openrc. These changes implement a full supervision architecture and make init more flexible. Later on, it will be easier to - add conditional gettys (for /dev/hvc0...) - remove sysvinit entirely - decouple the init process from the service manager.
Diffstat (limited to 'system/s6/s6-svscanboot')
-rw-r--r--system/s6/s6-svscanboot62
1 files changed, 49 insertions, 13 deletions
diff --git a/system/s6/s6-svscanboot b/system/s6/s6-svscanboot
index 2b41d2916..447a1a01b 100644
--- a/system/s6/s6-svscanboot
+++ b/system/s6/s6-svscanboot
@@ -1,21 +1,53 @@
-#!/bin/execlineb -S1
+#!/bin/execlineb -P
-foreground { redirfd -w 2 /dev/null mkdir -p /run/uncaught-logs }
+# Basic sanity.
+
+export PATH /usr/bin:/usr/sbin:/bin:/sbin
+umask 022
+
+
+# The live service directories are in /run/services
+# The scandir is /run/service, containing only the catch-all logger and symlinks
+# (and the s6-svscan configuration in /run/service/.s6-svscan)
+
+if { rm -rf /run/service /run/services }
+if { mkdir -p -m 0755 /run/service/.s6-svscan /run/service/s6-svscan-log }
+if { ln -sf /bin/false /run/service/.s6-svscan/crash }
+if
+{
+ redirfd -w 1 /run/service/.s6-svscan/finish
+ heredoc 0 "#!/bin/execlineb -P\ns6-svc -X -- \"/run/service/s6-svscan-log\"\n"
+ cat
+}
+if { chmod 0755 /run/service/.s6-svscan/finish }
+
+
+# Directory for the catch-all logger to store its logs
+
+if { mkdir -p -m 2700 /run/uncaught-logs }
if { chown catchlog:catchlog /run/uncaught-logs }
if { chmod 2700 /run/uncaught-logs }
-foreground { redirfd -w 2 /dev/null mkdir -p ${1}/.s6-svscan ${1}/s6-svscan-log }
-foreground { redirfd -w 2 /dev/null ln -sf /bin/false ${1}/.s6-svscan/crash }
+
+
+# Copy all the early services and link them into the scandir
+
+if { /bin/cp -a /etc/s6/early-services /run/services }
if
{
- redirfd -w 1 ${1}/.s6-svscan/finish
- heredoc 0 "#!/bin/execlineb -P\ns6-svc -X -- \"${1}/s6-svscan-log\"\n"
- cat
+ forbacktickx -pnd"\n" i { ls -1 -U /run/services }
+ importas -u i i
+ ln -nsf ../services/$i /run/service/$i
}
-if { chmod 0755 ${1}/.s6-svscan/finish }
-foreground { redirfd -w 2 /dev/null mkfifo -m 0600 ${1}/s6-svscan-log/fifo }
+
+
+# Create the catch-all logger servicedir directly in the scandir
+# (It's too fundamental to be made configurable as an early service.)
+
+if { rm -f /run/service/s6-svscan-log/fifo }
+if { mkfifo -m 0600 /run/service/s6-svscan-log/fifo }
if
{
- redirfd -w 1 ${1}/s6-svscan-log/run
+ redirfd -w 1 /run/service/s6-svscan-log/run
heredoc 0 "#!/bin/execlineb -P
redirfd -w 2 /dev/console
redirfd -rnb 0 fifo
@@ -24,9 +56,13 @@ exec -c
s6-log t /run/uncaught-logs\n"
cat
}
-if { chmod 0755 ${1}/s6-svscan-log/run }
+if { chmod 0755 /run/service/s6-svscan-log/run }
+
+
+# All ready, exec into s6-svscan.
+# By default all messages from all services will go to the catch-all logger it spawns.
redirfd -r 0 /dev/null
-redirfd -wnb 1 ${1}/s6-svscan-log/fifo
+redirfd -wnb 1 /run/service/s6-svscan-log/fifo
fdmove -c 2 1
-s6-svscan -St0 ${1}
+s6-svscan -St0 /run/service