#!/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.

foreground
{
  if
  {
    redirfd -w 1 /var/run/s6/uncaught-logs-fifo
    fdmove -c 2 1

    /etc/s6/init/init-stage2-partial
  }
  /etc/s6/init/init-stage2-cmd $@
}
import -u ?
if { s6-test ${?} -ne 0 }
import-from-envdir -u -D 0 /var/run/s6/container_environment S6_BEHAVIOUR_IF_STAGE2_FAILS
if { s6-test ${S6_BEHAVIOUR_IF_STAGE2_FAILS} -ne 0 }
ifelse { s6-test ${S6_BEHAVIOUR_IF_STAGE2_FAILS} -ne 1 }
{
  # Stop supervision tree
  s6-svscanctl -t /var/run/s6/services
}
s6-echo -- "\n!!!!!\n init-stage2 failed.\n Logs are in /var/log/s6-uncaught-logs\n!!!!!"
