diff --git a/scripts/update.sh b/scripts/update.sh index 5e364e2..d294c25 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -169,25 +169,28 @@ _sudoers_add(){ chmod 440 "$file" } fix_permissions(){ - chown -R "${APP_USER}:${APP_GROUP}" \ - "${APP_DIR}/bootstrap/cache" \ - "${APP_DIR}/storage" \ - "${APP_DIR}/public/build" 2>/dev/null || true - chmod -R ug+rwX \ - "${APP_DIR}/bootstrap/cache" \ - "${APP_DIR}/storage" 2>/dev/null || true + # Alle App-Dateien dem APP_USER zuweisen (git läuft als root → neue Dateien wären sonst root-owned) + # node_modules + vendor ausklammern (zu groß, werden separat behandelt) + for d in app bootstrap config database public resources routes scripts storage; do + [[ -e "${APP_DIR}/${d}" ]] && chown -R "${APP_USER}:${APP_GROUP}" "${APP_DIR}/${d}" 2>/dev/null || true + done + for f in artisan composer.json composer.lock package.json package-lock.json .env vite.config.js vite.config.ts; do + [[ -e "${APP_DIR}/${f}" ]] && chown "${APP_USER}:${APP_GROUP}" "${APP_DIR}/${f}" 2>/dev/null || true + done + + chmod -R ug+rwX "${APP_DIR}/bootstrap/cache" "${APP_DIR}/storage" 2>/dev/null || true find "${APP_DIR}/bootstrap/cache" "${APP_DIR}/storage" \ -type d -exec chmod g+s {} \; 2>/dev/null || true - # Frontend-Assets fehlen → automatisch neu bauen (z.B. nach fehlgeschlagenem Update) + # Frontend fehlt → rebuild if [[ ! -f "${APP_DIR}/public/build/manifest.json" ]]; then echo "[!] manifest.json fehlt — Frontend wird neu gebaut …" frontend_build_quiet || true fi - sudo -u "${APP_GROUP}" php "${APP_DIR}/artisan" optimize:clear --quiet 2>/dev/null || true - sudo -u "${APP_GROUP}" php "${APP_DIR}/artisan" config:cache --quiet 2>/dev/null || true - sudo -u "${APP_GROUP}" php "${APP_DIR}/artisan" route:cache --quiet 2>/dev/null || true + # Nur leeren — KEIN config:cache/route:cache (kaputte Cache-Datei → 404/500) + # Laravel lädt Config + Routes beim nächsten Request automatisch frisch + sudo -u "${APP_USER}" php "${APP_DIR}/artisan" optimize:clear --quiet 2>/dev/null || true } ensure_system(){