From 8567ce69516730457b1d62ee488c91ba4c3c7653 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 19 May 2026 18:50:40 +0200 Subject: [PATCH] chore: improve fix.sh and composer permission handling --- composer.json | 2 ++ fix.sh | 32 +++++++++++--------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index da19a88..1954669 100755 --- a/composer.json +++ b/composer.json @@ -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": [ diff --git a/fix.sh b/fix.sh index 736691b..10351bc 100755 --- a/fix.sh +++ b/fix.sh @@ -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."