entrypoint.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. set -e
  3. echo "Running version ${VERSION} commit ${COMMIT} built on ${CREATED}"
  4. # Show versions
  5. echo "supervisord version: $(supervisord version)"
  6. php-fpm83 -v | head -n 1
  7. nginx -v
  8. # Database creation
  9. if [ "${DB_CONNECTION}" = "sqlite" ]; then
  10. # DB_DATABASE is trimmed if necessary
  11. if [[ $DB_DATABASE == \"* ]] && [[ $DB_DATABASE == *\" ]] ; then
  12. dbpath=${DB_DATABASE:1:${#DB_DATABASE}-2}
  13. else
  14. dbpath=${DB_DATABASE}
  15. fi
  16. if [ $dbpath != "/srv/database/database.sqlite" ]; then
  17. echo "DB_DATABASE sets with custom path: ${dbpath}"
  18. if [ ! -f ${dbpath} ]; then
  19. echo "${dbpath} does not exist, we create it"
  20. touch ${dbpath}
  21. fi
  22. else
  23. echo "DB_DATABASE sets with default path, we will use a symlink"
  24. echo "Actual db file will be /2fauth/database.sqlite"
  25. if [ ! -f /2fauth/database.sqlite ]; then
  26. echo "/2fauth/database.sqlite does not exist, we create it"
  27. touch /2fauth/database.sqlite
  28. fi
  29. rm -f /srv/database/database.sqlite
  30. ln -s /2fauth/database.sqlite /srv/database/database.sqlite
  31. echo "/srv/database/database.sqlite is now a symlink to /2fauth/database.sqlite"
  32. fi
  33. fi
  34. # Inject storage in /2fauth and use it with a symlink
  35. if [ ! -d /2fauth/storage ]; then
  36. mv /srv/storage /2fauth/storage
  37. else
  38. rm -r /srv/storage
  39. fi
  40. ln -s /2fauth/storage /srv/storage
  41. # Note: ${COMMIT} is set by the CI
  42. if [ -f /2fauth/installed ]; then
  43. INSTALLED_COMMIT="$(cat /2fauth/installed)"
  44. if [ "${INSTALLED_COMMIT}" != "${COMMIT}" ]; then
  45. echo "Installed commit ${INSTALLED_COMMIT} is different from program commit ${COMMIT}, we are migrating..."
  46. php artisan cache:clear
  47. php artisan config:clear
  48. php artisan migrate --force
  49. fi
  50. else
  51. php artisan migrate:refresh --force
  52. php artisan passport:install --no-interaction
  53. fi
  54. echo "${COMMIT}" > /2fauth/installed
  55. php artisan storage:link --quiet
  56. # Clearing compiled, cache has already been cleared
  57. php artisan clear-compiled
  58. # Clearing and Caching config, events, routes, views
  59. php artisan optimize
  60. supervisord