#!/usr/bin/execlineb -S0

##
## dump environment into an envdir
##

/usr/bin/if { /usr/bin/s6-mkdir -pm 0755 -- /var/run/s6/container_environment }
/usr/bin/if { /usr/bin/s6-dumpenv -- /var/run/s6/container_environment }


##
## run everything else with only the environment defined in
## /etc/s6/init/env. Programs can get back the container
## environment by using "with-contenv program".
##

/usr/bin/exec -c --
/usr/bin/s6-envdir /etc/s6/init/env
/usr/bin/exec --


##
## route based on what was provided in S6_USE_CATCHALL_LOGGER
##

import-from-envdir -u -D 0 /var/run/s6/container_environment S6_USE_CATCHALL_LOGGER
ifelse { s6-test ${S6_USE_CATCHALL_LOGGER} -eq 1 }
{
  /etc/s6/init-catchall/init-stage1 $@
}
/etc/s6/init-no-catchall/init-stage1 $@
