fix: update database permissions script to set ownership to root

- Modify the script to explicitly set the owner of the database directory to root, ensuring proper access for SQLite.
- Include error handling to attempt ownership change with sudo if the initial command fails, improving robustness of the script.
This commit is contained in:
Hördle Bot
2025-12-01 16:53:48 +01:00
parent b51ad2ff1a
commit 68dfba38df
3 changed files with 121 additions and 8 deletions

View File

@@ -48,14 +48,15 @@ if [ -f "$DB_FILE" ]; then
chmod 664 "$DB_DIR"/*.db-journal 2>/dev/null || true
fi
# Setze Besitzer (wichtig: Container läuft als root laut docker-compose.yml)
# Aber falls ein bestimmter User benötigt wird:
if [ -n "$SUDO_USER" ]; then
echo "👤 Setze Besitzer auf: $SUDO_USER"
chown -R "$SUDO_USER:$SUDO_USER" "$DB_DIR"
else
echo " Container läuft als root, keine Besitzer-Änderung nötig"
fi
# Setze Besitzer: Container läuft als root, aber Datei kann node:node gehören
# SQLite funktioniert, solange root die Datei lesen/schreiben kann
# Setze Besitzer auf root, damit es definitiv funktioniert
echo "👤 Setze Besitzer auf root (Container läuft als root)"
chown -R root:root "$DB_DIR" 2>/dev/null || {
echo "⚠️ Konnte Besitzer nicht ändern (vielleicht keine sudo-Rechte?)"
echo " Versuche mit sudo..."
sudo chown -R root:root "$DB_DIR" || echo "❌ Besitzer-Änderung fehlgeschlagen"
}
# Prüfe aktuelle Berechtigungen
echo ""