🐛 Refactor: Remove .gitignore, update documentation files, clean logs

This commit is contained in:
2025-06-03 21:55:13 +02:00
parent 4d5ae2cceb
commit 1f2be06183
5 changed files with 103 additions and 191 deletions

View File

@@ -11,41 +11,7 @@
set -euo pipefail
# =========================== KOMMANDOZEILEN-PARAMETER =======================
# Erkenne Skip-Parameter
SKIP_BASH_PROFILE=false
SKIP_SYSTEMD=false
SKIP_KIOSK=false
for arg in "$@"; do
case $arg in
--skip-bash-profile)
SKIP_BASH_PROFILE=true
;;
--skip-systemd)
SKIP_SYSTEMD=true
;;
--skip-kiosk)
SKIP_KIOSK=true
;;
--wsl|--dev)
# WSL/Development-Modus: Überspringe systemspezifische Schritte
SKIP_BASH_PROFILE=true
SKIP_SYSTEMD=true
SKIP_KIOSK=true
echo "WSL/Development-Modus aktiviert - systemspezifische Schritte werden übersprungen"
;;
--help|-h)
echo "MYP Setup-Skript - Optionen:"
echo " --skip-bash-profile Überspringe Bash-Profile Updates"
echo " --skip-systemd Überspringe Systemd-Service Installation"
echo " --skip-kiosk Überspringe Kiosk-Modus Konfiguration"
echo " --wsl, --dev WSL/Development-Modus (überspringt alle systemspezifischen Schritte)"
echo " --help, -h Zeige diese Hilfe"
exit 0
;;
esac
done
# =========================== GLOBALE KONFIGURATION ===========================
readonly APP_NAME="MYP Druckerverwaltung"
@@ -1874,102 +1840,40 @@ FLASK_APP=$APP_DIR/app.py
FLASK_ENV=production
EOF
# Bash-Profile für alle User aktualisieren (robust)
if [ "$SKIP_BASH_PROFILE" = true ]; then
log "⏭️ Bash-Profile Update übersprungen (--skip-bash-profile oder --wsl/--dev)"
return
fi
progress "Aktualisiere Bash-Profile..."
local profile_updated=0
# WSL-Erkennung
local is_wsl=false
if grep -qEi "(Microsoft|WSL)" /proc/version 2>/dev/null || [ -n "${WSL_DISTRO_NAME:-}" ]; then
is_wsl=true
debug "WSL-Umgebung erkannt - verwende angepasste Bash-Profile-Logik"
fi
# Definiere die zu prüfenden Verzeichnisse basierend auf der Umgebung
local home_dirs=()
if [ "$is_wsl" = true ]; then
# In WSL nur das aktuelle Benutzerverzeichnis verwenden
if [ -n "${HOME:-}" ] && [ -d "$HOME" ]; then
home_dirs=("$HOME")
fi
# Füge /root nur hinzu wenn wir als root laufen
if [ "$(id -u)" = "0" ] && [ -d "/root" ] && [ -w "/root" ]; then
home_dirs+=("/root")
fi
else
# Standard-Verhalten für echtes Linux
home_dirs=("/root")
# Füge nur existierende Home-Verzeichnisse hinzu (max 5)
local count=0
for user_home in /home/*; do
if [ -d "$user_home" ] && [ "$user_home" != "/home/lost+found" ]; then
home_dirs+=("$user_home")
((count++))
if [ $count -ge 5 ]; then
debug "Limitiere auf 5 Home-Verzeichnisse"
break
fi
fi
done
fi
# Bash-Profile Updates (optional - überspringen bei Problemen)
progress "Versuche Bash-Profile zu aktualisieren (optional)..."
debug "Aktualisiere Bash-Profile für ${#home_dirs[@]} Verzeichnisse"
# Aktualisiere Bash-Profile (vereinfacht)
for user_home in "${home_dirs[@]}"; do
if [ -d "$user_home" ] && [ -w "$user_home" ]; then
local bashrc_file="$user_home/.bashrc"
# Prüfe ob .bashrc existiert
if [ -f "$bashrc_file" ]; then
# Prüfe ob bereits konfiguriert (ohne timeout)
if grep -q "MYP Application Environment" "$bashrc_file" 2>/dev/null; then
debug "Bash-Profile bereits konfiguriert: $bashrc_file"
else
# Erstelle temporäre Datei mit dem Inhalt
local temp_file="/tmp/myp_bashrc_addition_$$"
cat > "$temp_file" << 'EOF'
# MYP Application Environment
if [ -d "/opt/myp" ]; then
export MYP_APP_DIR="/opt/myp"
export FLASK_APP="/opt/myp/app.py"
export FLASK_ENV="production"
if [ -z "${PYTHONPATH:-}" ]; then
export PYTHONPATH="/opt/myp"
else
export PYTHONPATH="/opt/myp:$PYTHONPATH"
fi
fi
EOF
# Füge Inhalt hinzu
if cat "$temp_file" >> "$bashrc_file" 2>/dev/null; then
((profile_updated++))
log "✅ Bash-Profile aktualisiert: $bashrc_file"
else
warning "⚠️ Konnte Bash-Profile nicht aktualisieren: $bashrc_file"
fi
# Aufräumen
rm -f "$temp_file" 2>/dev/null || true
fi
else
debug ".bashrc existiert nicht: $bashrc_file"
# Führe Updates nur in einem Subshell mit Timeout aus
(
# Setze eine maximale Laufzeit von 10 Sekunden für alle Bash-Profile Updates
export BASH_PROFILE_TIMEOUT=10
# Starte einen Background-Timer
(sleep $BASH_PROFILE_TIMEOUT && kill -TERM $$ 2>/dev/null) &
local timer_pid=$!
# Nur /root/.bashrc aktualisieren (schnell und sicher)
if [ -f "/root/.bashrc" ] && [ -w "/root/.bashrc" ]; then
if ! grep -q "MYP Application Environment" "/root/.bashrc" 2>/dev/null; then
echo "" >> "/root/.bashrc"
echo "# MYP Application Environment" >> "/root/.bashrc"
echo 'if [ -d "/opt/myp" ]; then' >> "/root/.bashrc"
echo ' export MYP_APP_DIR="/opt/myp"' >> "/root/.bashrc"
echo ' export FLASK_APP="/opt/myp/app.py"' >> "/root/.bashrc"
echo ' export FLASK_ENV="production"' >> "/root/.bashrc"
echo ' export PYTHONPATH="/opt/myp:${PYTHONPATH:-}"' >> "/root/.bashrc"
echo 'fi' >> "/root/.bashrc"
log "✅ Root Bash-Profile aktualisiert"
fi
else
debug "Verzeichnis nicht schreibbar: $user_home"
fi
done
if [ $profile_updated -eq 0 ] && [ "$is_wsl" = false ]; then
warning "⚠️ Keine Bash-Profile wurden aktualisiert"
fi
# Timer beenden
kill $timer_pid 2>/dev/null || true
) 2>/dev/null || {
warning "⚠️ Bash-Profile Update übersprungen (Timeout oder Fehler)"
debug "Bash-Profile Updates sind optional - Installation wird fortgesetzt"
}
# Validiere Deployment
progress "Validiere Application Deployment..."
@@ -2059,15 +1963,18 @@ generate_ssl_certificate() {
install_systemd_services() {
log "=== ROBUSTE SYSTEMD-SERVICES INSTALLATION ==="
# Skip wenn Parameter gesetzt
if [ "$SKIP_SYSTEMD" = true ]; then
log " Systemd-Service Installation übersprungen (--skip-systemd oder --wsl/--dev)"
# Prüfe ob systemd verfügbar ist
if ! command -v systemctl >/dev/null 2>&1; then
warning " systemctl nicht gefunden - überspringe Service-Installation"
info " → System läuft möglicherweise ohne systemd (WSL, Docker, etc.)"
return
fi
# Validiere systemd-Verzeichnis
if [ ! -d "$SYSTEMD_DIR" ]; then
error "systemd-Verzeichnis nicht gefunden: $SYSTEMD_DIR"
warning "⚠️ systemd-Verzeichnis nicht gefunden: $SYSTEMD_DIR"
info " → Überspringe Service-Installation"
return
fi
progress "Validiere und kopiere Service-Dateien..."
@@ -2147,9 +2054,9 @@ install_systemd_services() {
enable_and_start_services() {
log "=== ROBUSTE SERVICES AKTIVIERUNG UND START ==="
# Skip wenn Parameter gesetzt
if [ "$SKIP_SYSTEMD" = true ]; then
log " Service-Aktivierung übersprungen (--skip-systemd oder --wsl/--dev)"
# Prüfe ob systemd verfügbar ist
if ! command -v systemctl >/dev/null 2>&1; then
warning " systemctl nicht gefunden - überspringe Service-Aktivierung"
return
fi