-
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 #26 from glerchundi/master
implement how s6 behaves if stage2 fails
- Loading branch information
Showing
11 changed files
with
131 additions
and
88 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
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
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
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
#!/usr/bin/execlineb -S0 | ||
|
||
# this env decides what to do if stage2 fails | ||
import-from-envdir -u -D 0 /var/run/s6/container_environment S6_BEHAVIOUR_IF_STAGE2_FAILS | ||
|
||
foreground | ||
{ | ||
## | ||
## fix-attrs.d: ensure owners and permissions are correct | ||
## | ||
|
||
if { s6-echo "[fix-attrs.d] applying owners & permissions fixes..." } | ||
if | ||
{ | ||
pipeline { s6-ls -0 -- /etc/fix-attrs.d } | ||
pipeline { s6-sort -0 -- } | ||
forstdin -0 -- i | ||
import -u i | ||
if { s6-echo -n -- "[fix-attrs.d] applying ${i}... " } | ||
foreground { redirfd -r 0 /etc/fix-attrs.d/${i} fix-attrs } | ||
import -u ? | ||
if { s6-echo -- " exited ${?}" } | ||
ifelse { s6-test ${S6_BEHAVIOUR_IF_STAGE2_FAILS} -eq 0 } { exit 0 } | ||
exit ${?} | ||
} | ||
if { s6-echo -- "[fix-attrs.d] done." } | ||
|
||
|
||
## | ||
## 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 -o 0 -0 -- i | ||
import -u i | ||
if { s6-echo -n -- "[cont-init.d] executing ${i}... " } | ||
foreground { with-contenv /etc/cont-init.d/${i} } | ||
import -u ? | ||
if { s6-echo -- " exited ${?}" } | ||
ifelse { s6-test ${S6_BEHAVIOUR_IF_STAGE2_FAILS} -eq 0 } { exit 0 } | ||
exit ${?} | ||
} | ||
if { s6-echo -- "[cont-init.d] done." } | ||
|
||
## | ||
## services.d: long-lived processes to be supervised | ||
## | ||
|
||
|
||
if { s6-echo "[services.d] starting services" } | ||
if | ||
{ | ||
pipeline { s6-ls -0 -- /etc/services.d } | ||
forstdin -0 -p -- i | ||
import -u i | ||
if { s6-test -d /etc/services.d/${i} } | ||
s6-hiercopy /etc/services.d/${i} /var/run/s6/services/${i} | ||
} | ||
if { s6-svscanctl -a /var/run/s6/services } | ||
if { s6-echo -- "[services.d] done." } | ||
} | ||
import -u ? | ||
ifelse { s6-test ${S6_BEHAVIOUR_IF_STAGE2_FAILS} -eq 0 } { exit 0 } | ||
exit ${?} |
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
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,29 @@ | ||
#!/usr/bin/execlineb | ||
|
||
elgetopt "uD:" | ||
multisubstitute | ||
{ | ||
importas -u envdir 1 | ||
importas -u envvar 2 | ||
importas -u -D "" defval ELGETOPT_D | ||
import -u -D 0 ELGETOPT_u | ||
} | ||
shift -n 2 | ||
elgetpositionals -P0 | ||
emptyenv -P | ||
backtick -n ${envvar} | ||
{ | ||
ifelse { s6-test -f ${envdir}/${envvar} } | ||
{ | ||
redirfd -r 0 ${envdir}/${envvar} | ||
s6-cat | ||
} | ||
s6-echo -n "${defval}" | ||
} | ||
ifelse { s6-test ${ELGETOPT_u} -eq 1 } | ||
{ | ||
import -u ${envvar} | ||
$@ | ||
} | ||
import ${envvar} | ||
$@ |