| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- #!/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
- # -----------------------------------------------------------------------------
- export PHP_VERSION="$(php -r 'echo PHP_VERSION;')"
- if [[ "$PHP_VERSION" == "8.1.34" ]]; then
- export WORKSPACE=$PWD/api-v8
- if [[ "$PHP_VERSION" == "8.4.16" ]]; then
- export WORKSPACE=$PWD/api-v12
- else
- echo "unsupported php $PHP_VERSION"
- exit 1
- fi
- # -----------------------------------------------------------------------------
- if [[ "$#" -eq 1 && "$1" == "diagnose" ]]; then
- 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"
- mkdir storage/logs
- 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
|