-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from glerchundi/master
fixes/implements #13
- Loading branch information
Showing
26 changed files
with
254 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/execlineb -S0 | ||
|
||
## | ||
## ensure our vital fifo exists | ||
## | ||
|
||
if { s6-mkfifo -m 0600 -- /var/run/s6/uncaught-logs-fifo } | ||
|
||
## | ||
## ensure ownership & permissions for our vital files | ||
## | ||
|
||
if { s6-rmrf /var/log/s6-uncaught-logs } | ||
if { s6-mkdir -p /var/log/s6-uncaught-logs } | ||
if { s6-envuidgid -D 32768:32768 nobody s6-chown -U /var/log/s6-uncaught-logs } | ||
if { s6-chmod 2700 /var/log/s6-uncaught-logs } | ||
|
||
|
||
## | ||
## init the scandir with our base services | ||
## | ||
|
||
if { s6-rmrf /var/run/s6/services } | ||
if { s6-hiercopy /etc/s6/services /var/run/s6/services } | ||
|
||
|
||
## | ||
## fork the "init-stage2" script | ||
## | ||
|
||
background | ||
{ | ||
# block until the supervision tree is running | ||
redirfd -w 3 /var/run/s6/uncaught-logs-fifo | ||
fdclose 3 | ||
|
||
# add some environment | ||
s6-envdir -- /etc/s6/init/env-stage2 | ||
|
||
# run the script | ||
/etc/s6/init-catchall/init-stage2 $@ | ||
} | ||
unexport ! | ||
|
||
|
||
## | ||
## run the rest of stage 1 with sanitized descriptors | ||
## | ||
|
||
redirfd -r 0 /dev/null | ||
redirfd -wnb 1 /var/run/s6/uncaught-logs-fifo | ||
fdmove -c 2 1 | ||
|
||
|
||
## | ||
## start the supervision tree | ||
## | ||
|
||
s6-svscan -t0 /var/run/s6/services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/execlineb -S0 | ||
|
||
# This file is executed (not as process 1!) as soon as s6-svscan | ||
# starts, with the original stdin/out/err, but NOT the original | ||
# environment. | ||
# Purpose of this file: to perform all the one-time initialization tasks. | ||
|
||
if -nt | ||
{ | ||
if | ||
{ | ||
redirfd -w 1 /var/run/s6/uncaught-logs-fifo | ||
fdmove -c 2 1 | ||
|
||
/etc/s6/init/init-stage2-fix-attrs | ||
/etc/s6/init/init-stage2-cont-inits | ||
/etc/s6/init/init-stage2-services | ||
} | ||
|
||
/etc/s6/init/init-stage2-cmd $@ | ||
} | ||
|
||
# if anything in the if -nt { } block fails, control jumps here. | ||
s6-echo -- "\n!!!!!\n init-stage2 failed.\n Logs are in /var/log/s6-uncaught-logs\n!!!!!" |
48 changes: 48 additions & 0 deletions
48
builder/overlay-rootfs/etc/s6/init-no-catchall/init-stage1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/execlineb -S0 | ||
|
||
## | ||
## init the scandir with our base services | ||
## | ||
|
||
if { s6-rmrf /var/run/s6/services } | ||
if { s6-hiercopy /etc/s6/services /var/run/s6/services } | ||
if { s6-rmrf /var/run/s6/services/s6-svscan-log } | ||
|
||
|
||
## | ||
## fork the "init-stage2" script | ||
## | ||
|
||
background | ||
{ | ||
# block until the supervision tree is running | ||
# NOTE: start waiting as soon as possible because we can get | ||
# into a race condition if "s" was already sent before we | ||
# started listening to the fifodir. | ||
if | ||
{ | ||
# keep stderr open, but avoid "s" printing to the outside | ||
redirfd -w 1 /dev/null | ||
s6-ftrig-wait /var/run/s6/services/s6-fdholderd/event "s" | ||
} | ||
|
||
# add some environment | ||
s6-envdir -- /etc/s6/init/env-stage2 | ||
|
||
# run the script | ||
/etc/s6/init-no-catchall/init-stage2 $@ | ||
} | ||
unexport ! | ||
|
||
## | ||
## run the rest of stage 1 with sanitized descriptors | ||
## | ||
|
||
redirfd -r 0 /dev/null | ||
|
||
|
||
## | ||
## start the supervision tree | ||
## | ||
|
||
s6-svscan -t0 /var/run/s6/services |
21 changes: 21 additions & 0 deletions
21
builder/overlay-rootfs/etc/s6/init-no-catchall/init-stage2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/execlineb -S0 | ||
|
||
# This file is executed (not as process 1!) as soon as s6-svscan | ||
# starts, with the original stdin/out/err, but NOT the original | ||
# environment. | ||
# Purpose of this file: to perform all the one-time initialization tasks. | ||
|
||
if -nt | ||
{ | ||
if | ||
{ | ||
/etc/s6/init/init-stage2-fix-attrs | ||
/etc/s6/init/init-stage2-cont-inits | ||
/etc/s6/init/init-stage2-services | ||
} | ||
|
||
/etc/s6/init/init-stage2-cmd $@ | ||
} | ||
|
||
# if anything in the if -nt { } block fails, control jumps here. | ||
s6-echo -- "\n!!!!!\n init-stage2 failed.\n!!!!!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/execlineb -S0 | ||
|
||
## | ||
## The init is complete. If the user has given a CMD, run it now, then | ||
## kill everything when it exits. | ||
## | ||
|
||
if -t { s6-test $# -ne 0 } | ||
foreground { s6-setsid -gq -- with-contenv $@ } | ||
foreground { import -u ? s6-echo "${1} exited ${?}. Stopping the supervision tree." } | ||
foreground { s6-svscanctl -t /var/run/s6/services } | ||
|
||
# Race condition here, but it's ok: the sync in stage 3 takes ages, | ||
# and if we get killed by the SIGTERM instead of the SIGKILL, meh, who cares. | ||
|
||
# Wait to be nuked | ||
s6-pause -th |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/execlineb -S0 | ||
|
||
## | ||
## cont-init.d: one-time init scripts | ||
## | ||
|
||
if { s6-echo "[cont-init.d] executing container initialization scripts..." } | ||
if | ||
{ | ||
pipeline { s6-ls -0 -- /etc/cont-init.d } | ||
pipeline { s6-sort -0 -- } | ||
forstdin -0 -- i | ||
import -u i | ||
if { s6-echo -n -- "[cont-init.d] executing ${i}... " } | ||
foreground { with-contenv /etc/cont-init.d/${i} } | ||
import -u ? s6-echo -- " ... exited ${?}" | ||
} | ||
if { s6-echo -- "[cont-init.d] done." } | ||
$@ |
Oops, something went wrong.