chore: improve fix.sh and composer permission handling

This commit is contained in:
root
2026-05-19 18:50:40 +02:00
parent e5e8e050a0
commit 8567ce6951
2 changed files with 13 additions and 21 deletions
+2
View File
@@ -71,10 +71,12 @@
"@php artisan filament:upgrade"
],
"post-install-cmd": [
"@php artisan optimize:clear",
"bash fix.sh"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force",
"@php artisan optimize:clear",
"bash fix.sh"
],
"post-root-package-install": [
+11 -21
View File
@@ -1,29 +1,19 @@
#!/bin/bash
set -e
echo "=========================================="
echo " AtomCMS Quick Fix Script"
echo "=========================================="
PROJECT_DIR="/var/www/atomcms"
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"
WEB_USER="www-data"
cd "$PROJECT_DIR"
cd "$PROJECT_DIR" || exit 1
echo "[1/4] Clearing all caches..."
php artisan optimize:clear
echo "Fixing permissions..."
echo "[2/4] Fixing file permissions..."
chown -R "$WEB_USER":"$WEB_USER" storage bootstrap/cache public/build 2>/dev/null || true
chmod -R 775 storage bootstrap/cache public/build 2>/dev/null || true
# Fix ownership (only if running as root/sudo, skip otherwise)
if [ "$(id -u)" -eq 0 ]; then
chown -R "$WEB_USER":"$WEB_USER" storage bootstrap/cache 2>/dev/null || true
fi
echo "[3/4] Clearing OPcache..."
php -r "if (function_exists('opcache_reset')) { opcache_reset(); echo 'OPcache cleared'.PHP_EOL; } else { echo 'OPcache not enabled'.PHP_EOL; }"
# Fix directory permissions
find storage bootstrap/cache -type d -exec chmod 775 {} + 2>/dev/null || true
find storage bootstrap/cache -type f -exec chmod 664 {} + 2>/dev/null || true
echo "[4/4] Rebuilding view cache..."
php artisan view:cache
echo "=========================================="
echo " Fix complete!"
echo "=========================================="
echo "Permissions fixed."