init 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh -e
  2. # This is the first program launched at container start.
  3. # We don't know where our binaries are and we cannot guarantee
  4. # that the default PATH can access them.
  5. # So this script needs to be entirely self-contained until it has
  6. # at least /command, /usr/bin and /bin in its PATH.
  7. addpath () {
  8. x="$1"
  9. IFS=:
  10. set -- $PATH
  11. IFS=
  12. while test "$#" -gt 0 ; do
  13. if test "$1" = "$x" ; then
  14. return
  15. fi
  16. shift
  17. done
  18. PATH="${x}:$PATH"
  19. }
  20. if test -z "$PATH" ; then
  21. PATH=/bin
  22. fi
  23. addpath /bin
  24. addpath /usr/bin
  25. addpath /command
  26. export PATH
  27. # Wait for the Docker readiness notification, if any
  28. if read _ 2>/dev/null <&3 ; then
  29. exec 3<&-
  30. fi
  31. # Now we're good: s6-overlay-suexec is accessible via PATH, as are
  32. # all our binaries.
  33. # Run preinit as root, then run stage0 as the container's user (can be
  34. # root, can be a normal user).
  35. exec s6-overlay-suexec \
  36. ' /package/admin/s6-overlay-@VERSION@/libexec/preinit' \
  37. '' \
  38. /package/admin/s6-overlay-@VERSION@/libexec/stage0 \
  39. "$@"