This repository has been archived on 2025-06-09. You can view files and clone it, but cannot push or open issues or pull requests.

51 lines
1.2 KiB
Bash
Raw Normal View History

2025-05-29 11:23:06 +08:00
#!/bin/bash
2025-06-02 10:17:50 +08:00
cd /var/www/html
2025-05-29 11:23:06 +08:00
APP_URL="${APP_URL%/}"
2025-05-29 11:23:06 +08:00
echo "Running composer install..."
2025-05-29 11:23:06 +08:00
composer install --no-interaction --prefer-dist
if [ ! -f ".env" ]; then
echo "Copying .env.example to .env"
2025-05-29 11:23:06 +08:00
cp .env.example .env
fi
echo "Updating .env configurations..."
2025-05-29 11:23:06 +08:00
update_env_var() {
local key=$1
local value=$2
grep -q "^${key}=" .env && \
sed -i "s|^${key}=.*|${key}=${value}|" .env || \
echo "${key}=${value}" >> .env
}
2025-06-02 10:17:50 +08:00
update_env_var "APP_NAME" "$APP_NAME"
update_env_var "APP_URL" "$APP_URL"
update_env_var "DB_HOST" "$DB_HOST"
update_env_var "DB_PORT" "$DB_PORT"
2025-05-29 11:23:06 +08:00
update_env_var "DB_DATABASE" "$DB_DATABASE"
update_env_var "DB_USERNAME" "$DB_USERNAME"
update_env_var "DB_PASSWORD" "$DB_PASSWORD"
echo "Generating Laravel app key..."
2025-05-29 11:23:06 +08:00
php artisan key:generate
echo "Running migrations..."
2025-05-29 11:23:06 +08:00
php artisan migrate --force
echo "Installing npm packages..."
2025-05-29 11:23:06 +08:00
[ ! -d "node_modules" ] && npm install
echo "Building front-end assets..."
2025-05-29 11:23:06 +08:00
npm run build
echo "Setting permissions for storage and bootstrap/cache..."
chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache
chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache
2025-06-02 10:17:50 +08:00
exec "$@"