rc.init 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/sh -e
  2. top="$1" ; shift
  3. if profile=`printcontenv S6_RUNTIME_PROFILE` ; then
  4. etc="/etc/cont-profile.d/$profile"
  5. else
  6. etc=/etc
  7. fi
  8. s6-rc-compile -v1 /run/s6/db "$etc/s6-overlay/s6-rc.d" /package/admin/s6-overlay-@VERSION@/etc/s6-rc/sources
  9. s6-rc-init -c /run/s6/db /run/service
  10. if timeout=`printcontenv S6_CMD_WAIT_FOR_SERVICES_MAXTIME` ; then : ; else
  11. timeout=5000
  12. fi
  13. set +e
  14. s6-rc -v2 -u -t "$timeout" -- change "$top"
  15. r=$?
  16. set -e
  17. if test "$r" -ne 0 && b=`printcontenv S6_BEHAVIOUR_IF_STAGE2_FAILS` ; then
  18. if test "$b" -eq 2 ; then
  19. echo 1 > /run/s6-linux-init-container-results/exitcode
  20. exec /run/s6/basedir/bin/halt
  21. elif test "$b" -eq 1 ; then
  22. echo '/run/s6/basedir/scripts/rc.init: warning: s6-rc failed to properly bring all the services up! Check your logs (in /run/uncaught-logs if you have in-container logging) for more information.' 1>&2
  23. fi
  24. fi
  25. if test -n "$1" ; then
  26. set +e
  27. arg0=`printcontenv S6_CMD_ARG0`
  28. $arg0 "$@"
  29. echo "$?" > /run/s6-linux-init-container-results/exitcode
  30. set -e
  31. exec /run/s6/basedir/bin/halt
  32. fi