b2in/public/_cabinet/setup-logging.sh
2026-01-23 17:33:10 +01:00

118 lines
3.4 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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/bash
# Setup-Script für Cabinet Digital Signage Logging System
# Führe dieses Script einmalig aus um das Logging zu aktivieren
echo "================================================"
echo "Cabinet Digital Signage - Logging Setup"
echo "================================================"
echo ""
# Farben für Output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Arbeitsverzeichnis
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
echo "📁 Arbeitsverzeichnis: $SCRIPT_DIR"
echo ""
# 1. Logs-Verzeichnis erstellen
echo "1⃣ Erstelle logs/ Verzeichnis..."
if [ -d "logs" ]; then
echo -e "${YELLOW} ⚠️ Verzeichnis existiert bereits${NC}"
else
mkdir -p logs
echo -e "${GREEN} ✅ logs/ erstellt${NC}"
fi
# 2. Berechtigungen setzen
echo ""
echo "2⃣ Setze Berechtigungen..."
# Prüfe ob als root ausgeführt
if [ "$EUID" -ne 0 ]; then
echo -e "${YELLOW} ⚠️ Nicht als Root - verwende chmod 777 (nicht für Produktion!)${NC}"
chmod 777 logs
else
echo -e "${GREEN} ✅ Als Root - setze www-data owner${NC}"
chown -R www-data:www-data logs
chmod 755 logs
fi
# 3. Test-Log erstellen
echo ""
echo "3⃣ Erstelle Test-Log..."
TEST_LOG="logs/test_$(date +%Y-%m-%d).log"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] [INFO] Logging-System wurde eingerichtet" > "$TEST_LOG"
if [ -f "$TEST_LOG" ]; then
echo -e "${GREEN} ✅ Test-Log erfolgreich erstellt: $TEST_LOG${NC}"
else
echo -e "${RED} ❌ Test-Log konnte nicht erstellt werden${NC}"
echo -e "${YELLOW} Prüfe die Schreibrechte!${NC}"
fi
# 4. .htaccess vorbereiten
echo ""
echo "4⃣ Prüfe .htaccess..."
if [ -f ".htaccess" ]; then
echo -e "${YELLOW} ⚠️ .htaccess existiert bereits${NC}"
echo -e " Möchtest du die Beispiel-.htaccess ansehen? → .htaccess.example"
else
echo -e "${GREEN} Keine .htaccess gefunden${NC}"
echo -e " Für Passwortschutz: cp .htaccess.example .htaccess"
fi
# 5. PHP-Konfiguration prüfen
echo ""
echo "5⃣ Prüfe PHP-Konfiguration..."
if command -v php &> /dev/null; then
PHP_VERSION=$(php -v | head -n 1)
echo -e "${GREEN} ✅ PHP gefunden: $PHP_VERSION${NC}"
# Prüfe wichtige PHP-Settings
FILE_UPLOADS=$(php -r "echo ini_get('file_uploads');")
MAX_POST=$(php -r "echo ini_get('post_max_size');")
echo " 📋 file_uploads: $FILE_UPLOADS"
echo " 📋 post_max_size: $MAX_POST"
else
echo -e "${RED} ❌ PHP nicht gefunden!${NC}"
fi
# 6. Zusammenfassung
echo ""
echo "================================================"
echo "✅ Setup abgeschlossen!"
echo "================================================"
echo ""
echo "📝 Nächste Schritte:"
echo ""
echo "1. Teste das Logging:"
echo " → Öffne: https://cabinet.b2in.eu/test-logging.html"
echo ""
echo "2. Schaue die Logs an:"
echo " → Öffne: https://cabinet.b2in.eu/view-logs.php"
echo ""
echo "3. Für Produktion (empfohlen):"
echo " → Aktiviere Passwortschutz:"
echo " cp .htaccess.example .htaccess"
echo " htpasswd -c .htpasswd admin"
echo ""
echo "4. Dokumentation lesen:"
echo " → cat LOGGING_README.md"
echo ""
echo "================================================"
echo ""
# Verzeichnisstruktur anzeigen
echo "📂 Aktuelle Struktur:"
tree -L 2 -a . 2>/dev/null || ls -lah
echo ""
echo "🎉 Fertig! Das Logging-System ist bereit."