| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/bin/bash
- set -e
- # -----------------------------------------------------------------------------
- if [[ "$EUID" -ne 0 ]]; then
- echo "please run this script as root."
- exit 1
- fi
- . /etc/os-release
- if [[ "$ID" != "ubuntu" ]]; then
- echo "unsupported distribution $ID"
- exit 1
- fi
- . $HOME/.nvm/nvm.sh
- # -----------------------------------------------------------------------------
- export PHP_VERSION="$(php -r 'echo PHP_VERSION;')"
- if [[ "$PHP_VERSION" == "8.1.34" ]]; then
- export WORKSPACE={{ app_deploy_target }}/api-v8
- elif [[ "$PHP_VERSION" == "8.4.16" ]]; then
- export WORKSPACE={{ app_deploy_target }}/api-v12
- else
- echo "unsupported php $PHP_VERSION"
- exit 1
- fi
- # -----------------------------------------------------------------------------
- if [[ "$#" -eq 1 && "$1" == "diagnose" ]]; then
- echo "workspace: $WORKSPACE"
- php --version
- echo "NodeJs: $(node -v)"
- echo "npm: $(npm -v)"
- composer diagnose
- elif [[ "$#" -eq 1 && "$1" == "setup" ]]; then
- cd $WORKSPACE/
- echo "caching configuration"
- php artisan config:cache
- echo "caching events"
- php artisan event:cache
- echo "caching routes"
- php artisan route:cache
- echo "caching views"
- php artisan view:cache
- echo "check file permissions"
- chown -R www-data:www-data bootstrap/cache storage
- elif [[ "$#" -eq 1 ]]; then
- cd $WORKSPACE/
- echo "run $1..."
- php -d memory_limit={{ app_php_memory_limit }} artisan $1
- else
- echo "unsupported args"
- exit 1
- fi
- exit 0
|