Steuerkram/docker-entrypoint.sh

40 lines
1.8 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
DATA=/var/www/html/data
BELEGE="$DATA/belege"
LOGO="$DATA/logo"
LEGACY="$DATA/legacy-uploads"
WEBROOT_UPLOADS=/var/www/html/public/static/uploads
mkdir -p "$BELEGE" "$LOGO" 2>/dev/null || true
# ── Einmalige Übernahme von Altbeständen ────────────────────────────────────
# Belege und Logo lagen früher gemeinsam in einem uploads-Verzeichnis (bzw. davor
# im Web-Root). Beide Fälle werden hier automatisch übernommen, damit ein reines
# "git pull + docker compose up" (z.B. über scripts/update.sh) nicht in einer
# Installation endet, deren Dateien nicht mehr gefunden werden.
# Idempotent: Nach dem Umzug sind die Quellverzeichnisse leer.
# Die eigentliche Übernahme liegt in scripts/intern/uploads-uebernahme.sh –
# dieses Verzeichnis ist als Volume gemountet, der Entrypoint dagegen steckt
# im Image. So wirkt eine Korrektur am Umzug auch ohne Rebuild.
UEBERNAHME=/var/www/html/scripts/intern/uploads-uebernahme.sh
# Logo aus dem alten Web-Root (Stand vor Fix #116). Übergeben wird direkt der
# logo-Ordner – alles darin ist Logo, deshalb steht data/logo an beiden Zielstellen.
# Andere Dateien im Web-Root bleiben so unangetastet.
if [ -d "$WEBROOT_UPLOADS/logo" ] && [ -n "$(ls -A "$WEBROOT_UPLOADS/logo" 2>/dev/null)" ]; then
echo "Migration: Logo aus dem Web-Root -> data/logo/"
sh "$UEBERNAHME" "$WEBROOT_UPLOADS/logo" "$LOGO" "$LOGO" || true
rmdir "$WEBROOT_UPLOADS/logo" 2>/dev/null || true
fi
# Gemeinsame uploads-Ablage (Stand nach #116, vor der Trennung in belege/logo)
sh "$UEBERNAHME" "$LEGACY" "$BELEGE" "$LOGO" || true
# Fix ownership of volume-mounted data directories at container start
chown -R www-data:www-data "$BELEGE" "$LOGO" 2>/dev/null || true
# Datenbank-Migrationen automatisch einspielen
php /var/www/html/scripts/intern/migrate.php
exec "$@"