Fix: fix_permissions ohne route:cache/config:cache – kein 404/500 mehr nach Update
- Chownt alle App-Verzeichnisse (app, bootstrap, config, db, public, resources, routes, scripts, storage) + Key-Files nach jedem git-Pull - Entfernt config:cache + route:cache aus fix_permissions (Fehlerquelle für 404/500) - Nur noch optimize:clear – Laravel lazy-rebuilt Config/Routes beim nächsten Request - APP_GROUP-Bug korrigiert: optimize:clear lief als APP_GROUP statt APP_USER Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main v1.1.318
parent
9d40597842
commit
a771f97516
|
|
@ -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(){
|
||||
|
|
|
|||
Loading…
Reference in New Issue