laravel.sh.j2 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. . $HOME/.nvm/nvm.sh
  14. # -----------------------------------------------------------------------------
  15. export PHP_VERSION="$(php -r 'echo PHP_VERSION;')"
  16. if [[ "$PHP_VERSION" == "8.1.34" ]]; then
  17. export WORKSPACE={{ app_deploy_target }}/api-v8
  18. elif [[ "$PHP_VERSION" == "8.4.16" ]]; then
  19. export WORKSPACE={{ app_deploy_target }}/api-v12
  20. else
  21. echo "unsupported php $PHP_VERSION"
  22. exit 1
  23. fi
  24. # -----------------------------------------------------------------------------
  25. if [[ "$#" -eq 1 && "$1" == "diagnose" ]]; then
  26. echo "workspace: $WORKSPACE"
  27. php --version
  28. echo "NodeJs: $(node -v)"
  29. echo "npm: $(npm -v)"
  30. composer diagnose
  31. elif [[ "$#" -eq 1 && "$1" == "setup" ]]; then
  32. cd $WORKSPACE/
  33. echo "caching configuration"
  34. php artisan config:cache
  35. echo "caching events"
  36. php artisan event:cache
  37. echo "caching routes"
  38. php artisan route:cache
  39. echo "caching views"
  40. php artisan view:cache
  41. echo "check file permissions"
  42. chown -R www-data:www-data bootstrap/cache storage
  43. elif [[ "$#" -eq 1 ]]; then
  44. cd $WORKSPACE/
  45. echo "run $1..."
  46. php -d memory_limit={{ app_php_memory_limit }} artisan $1
  47. else
  48. echo "unsupported args"
  49. exit 1
  50. fi
  51. exit 0