entrypoint.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/env bash
  2. isCommand() {
  3. for cmd in \
  4. "about" \
  5. "archive" \
  6. "browse" \
  7. "clear-cache" \
  8. "clearcache" \
  9. "config" \
  10. "create-project" \
  11. "depends" \
  12. "diagnose" \
  13. "dump-autoload" \
  14. "dumpautoload" \
  15. "exec" \
  16. "global" \
  17. "help" \
  18. "home" \
  19. "info" \
  20. "init" \
  21. "install" \
  22. "licenses" \
  23. "list" \
  24. "outdated" \
  25. "prohibits" \
  26. "remove" \
  27. "require" \
  28. "run-script" \
  29. "search" \
  30. "self-update" \
  31. "selfupdate" \
  32. "show" \
  33. "status" \
  34. "suggests" \
  35. "update" \
  36. "validate" \
  37. "why" \
  38. "why-not"
  39. do
  40. if [ -z "${cmd#"$1"}" ]; then
  41. return 0
  42. fi
  43. done
  44. return 1
  45. }
  46. # check if the first argument passed in looks like a flag
  47. if [ "$(printf %c "$1")" = '-' ]; then
  48. set -- /sbin/tini -- composer "$@"
  49. # check if the first argument passed in is composer
  50. elif [ "$1" = 'composer' ]; then
  51. set -- /sbin/tini -- "$@"
  52. # check if the first argument passed in matches a known command
  53. elif isCommand "$1"; then
  54. set -- /sbin/tini -- composer "$@"
  55. fi
  56. exec "$@"