laravel.sh.j2 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. set -e
  3. # -----------------------------------------------------------------------------
  4. if [[ "$EUID" -ne 0 ]]; then
  5. echo "please run this script as root."
  6. exit 1
  7. fi
  8. . /etc/os-release
  9. if [[ "$ID" != "ubuntu" ]]; then
  10. echo "unsupported distribution $ID"
  11. exit 1
  12. fi
  13. # -----------------------------------------------------------------------------
  14. export PHP_VERSION="$(php -r 'echo PHP_VERSION;')"
  15. if [[ "$PHP_VERSION" == "8.1.34" ]]; then
  16. export WORKSPACE=$PWD/api-v8
  17. if [[ "$PHP_VERSION" == "8.4.16" ]]; then
  18. export WORKSPACE=$PWD/api-v12
  19. else
  20. echo "unsupported php $PHP_VERSION"
  21. exit 1
  22. fi
  23. # -----------------------------------------------------------------------------
  24. if [[ "$#" -eq 1 && "$1" == "diagnose" ]]; then
  25. php --version
  26. echo "NodeJs: $(node -v)"
  27. echo "npm: $(npm -v)"
  28. composer diagnose
  29. elif [[ "$#" -eq 1 && "$1" == "setup" ]]; then
  30. cd $WORKSPACE/
  31. echo "caching configuration"
  32. php artisan config:cache
  33. echo "caching events"
  34. php artisan event:cache
  35. echo "caching routes"
  36. php artisan route:cache
  37. echo "caching views"
  38. php artisan view:cache
  39. echo "check file permissions"
  40. mkdir storage/logs
  41. chown -R www-data:www-data bootstrap/cache storage
  42. elif [[ "$#" -eq 1 ]]; then
  43. cd $WORKSPACE/
  44. echo "run $1..."
  45. php -d memory_limit={{ app_php_memory_limit }} artisan $1
  46. else
  47. echo "unsupported args"
  48. exit 1
  49. fi
  50. exit 0