52 lines
1.8 KiB
Bash
52 lines
1.8 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
cd /var/www
|
|
|
|
# Sicherstellen, dass /tmp jederzeit beschreibbar ist (tempnam, Sessions, Logs)
|
|
chmod 1777 /tmp 2>/dev/null || true
|
|
|
|
# Storage + bootstrap/cache anlegen und auf www-data setzen
|
|
mkdir -p \
|
|
storage/framework/cache/data \
|
|
storage/framework/sessions \
|
|
storage/framework/views \
|
|
storage/logs \
|
|
storage/app/audio \
|
|
storage/app/public \
|
|
storage/app/voices \
|
|
bootstrap/cache
|
|
|
|
# Log-Datei explizit anlegen + auf www-data setzen (Append-Mode-Fehler vermeiden)
|
|
touch storage/logs/laravel.log 2>/dev/null || true
|
|
|
|
chown -R www-data:www-data storage bootstrap/cache 2>/dev/null || true
|
|
chmod -R ug+rwX storage bootstrap/cache 2>/dev/null || true
|
|
|
|
# Docker-Socket Zugriff für www-data: socket-GID vom Host übernehmen
|
|
# damit `docker exec fox-whisper ...` aus PHP klappt.
|
|
if [ -S /var/run/docker.sock ]; then
|
|
SOCK_GID=$(stat -c '%g' /var/run/docker.sock 2>/dev/null || echo "")
|
|
if [ -n "$SOCK_GID" ]; then
|
|
if ! getent group "$SOCK_GID" >/dev/null 2>&1; then
|
|
groupadd -g "$SOCK_GID" dockerhost 2>/dev/null || addgroup -g "$SOCK_GID" dockerhost 2>/dev/null || true
|
|
fi
|
|
usermod -aG "$SOCK_GID" www-data 2>/dev/null || adduser www-data $(getent group "$SOCK_GID" | cut -d: -f1) 2>/dev/null || true
|
|
fi
|
|
fi
|
|
|
|
# Permission-Watchdog: storage drifet manchmal zurück auf User 1000 (z.B. wenn vom
|
|
# Host npm install läuft). Alle 10s nachziehen damit /fox/tts nicht 500't.
|
|
# Nur im app-Container laufen (sonst chown'en 4 Container parallel).
|
|
if [ "${WATCHDOG_OWNER:-1}" = "1" ]; then
|
|
(
|
|
while true; do
|
|
sleep 10
|
|
chown -R www-data:www-data /var/www/storage /var/www/bootstrap/cache 2>/dev/null || true
|
|
chmod -R ug+rwX /var/www/storage /var/www/bootstrap/cache 2>/dev/null || true
|
|
done
|
|
) &
|
|
fi
|
|
|
|
exec "$@"
|