feat: Aktualisierung der Datenbankdateien und Verbesserung der Datumsformatierung in den Templates für eine konsistentere Benutzeroberfläche

This commit is contained in:
Till Tomczak 2025-05-27 08:27:19 +02:00
parent 4310e1630c
commit aa40816ba0
15 changed files with 1576 additions and 5 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -304,7 +304,7 @@
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-slate-500 dark:text-slate-400">
{{ user.last_login.strftime('%d.%m.%Y %H:%M') if user.last_login else 'Nie' }}
{{ user.last_login | format_datetime if user.last_login else 'Nie' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<div class="flex space-x-2">
@ -474,7 +474,7 @@
</span>
<div>
<p class="text-sm text-slate-900 dark:text-white">{{ log.message }}</p>
<p class="text-xs text-slate-500 dark:text-slate-400 mt-1">{{ log.module }} - {{ log.timestamp if log.timestamp is string else log.timestamp.strftime('%d.%m.%Y %H:%M:%S') }}</p>
<p class="text-xs text-slate-500 dark:text-slate-400 mt-1">{{ log.module }} - {{ log.timestamp | format_datetime('%d.%m.%Y %H:%M:%S') if log.timestamp else 'Unbekannt' }}</p>
</div>
</div>
</div>

View File

@ -191,7 +191,7 @@
</div>
{% else %}
<!-- Login Button -->
<a href="{{ url_for('auth.login') }}"
<a href="{{ url_for('login') }}"
class="bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium shadow-sm hover:shadow-md transition-all duration-300 flex items-center">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"/>

View File

@ -163,12 +163,12 @@
<div class="space-y-3 text-sm">
<div>
<span class="text-slate-600 dark:text-slate-400">Mitglied seit:</span>
<div class="font-medium text-slate-900 dark:text-white">{{ current_user.created_at.strftime('%d.%m.%Y') if current_user.created_at else 'Unbekannt' }}</div>
<div class="font-medium text-slate-900 dark:text-white">{{ current_user.created_at | format_datetime('%d.%m.%Y') if current_user.created_at else 'Unbekannt' }}</div>
</div>
<div>
<span class="text-slate-600 dark:text-slate-400">Letzte Anmeldung:</span>
<div class="font-medium text-slate-900 dark:text-white">{{ current_user.last_login.strftime('%d.%m.%Y %H:%M') if current_user.last_login else 'Nie' }}</div>
<div class="font-medium text-slate-900 dark:text-white">{{ current_user.last_login | format_datetime if current_user.last_login else 'Nie' }}</div>
</div>
<div>

View File

@ -0,0 +1,316 @@
# MYP Kiosk-System Installation
## Übersicht
Das MYP Kiosk-System bietet eine vollständig automatisierte Lösung für den Betrieb eines Python 3.11 Backends mit sicherem Chrome Kiosk-Modus. Das System ist für verschiedene Betriebssysteme verfügbar.
## Verfügbare Installationsoptionen
### Linux/Ubuntu Installation
**Dateien:**
- `install-kiosk.sh` - Hauptinstallationsskript
- `setup-backend.sh` - Backend-Einrichtung
- `myp-backend.service` - Systemd-Service für Backend
- `myp-kiosk.service` - Systemd-Service für Kiosk
- `kiosk-start.sh` - Kiosk-Start-Skript
**Installation:**
```bash
sudo chmod +x install-kiosk.sh setup-backend.sh
sudo ./install-kiosk.sh
sudo ./setup-backend.sh
sudo reboot
```
### Windows Installation
**Dateien:**
- `install-kiosk.ps1` - PowerShell-Installationsskript
- `setup-backend.ps1` - PowerShell-Backend-Einrichtung
**Installation:**
```powershell
# Als Administrator ausführen
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\install-kiosk.ps1
.\setup-backend.ps1
Restart-Computer
```
## Systemanforderungen
### Mindestanforderungen
- **RAM:** 4 GB (8 GB empfohlen)
- **Speicher:** 10 GB freier Speicherplatz
- **Prozessor:** Dual-Core (Quad-Core empfohlen)
- **Netzwerk:** Internetverbindung für Installation
### Software-Anforderungen
- **Python:** 3.11 oder höher
- **Browser:** Google Chrome (wird automatisch installiert)
- **Betriebssystem:**
- Linux: Ubuntu 20.04+ oder ähnlich
- Windows: Windows 10/11
## Installationsschritte
### Schritt 1: Vorbereitung
1. Lade das komplette Projektverzeichnis herunter
2. Navigiere zum `backend/install` Verzeichnis
3. Stelle sicher, dass du Administrator-/Root-Rechte hast
### Schritt 2: Kiosk-System installieren
**Linux:**
```bash
cd backend/install
sudo ./install-kiosk.sh
```
**Windows:**
```powershell
cd backend\install
.\install-kiosk.ps1
```
### Schritt 3: Backend einrichten
**Linux:**
```bash
sudo ./setup-backend.sh
```
**Windows:**
```powershell
.\setup-backend.ps1
```
### Schritt 4: System neu starten
```bash
# Linux
sudo reboot
# Windows
Restart-Computer
```
## Automatische Funktionen
### Beim Systemstart
1. **Backend startet automatisch** auf Port 443 (HTTPS)
2. **Chrome Kiosk öffnet automatisch** die Anwendung
3. **Überwachung läuft** und startet Services bei Bedarf neu
4. **Kein Desktop-Zugriff** möglich
### Sicherheitsfeatures
- Vollbild-Kiosk ohne Browser-UI
- Keine Tabs, Menüs oder Navigation
- Deaktivierte Entwicklertools
- Automatischer Neustart bei Fehlern
- Eingeschränkte Benutzerrechte
## Verzeichnisstruktur nach Installation
### Linux
```
/opt/myp/
├── backend/
│ ├── app/ # Backend-Anwendung
│ ├── venv/ # Python Virtual Environment
│ └── requirements.txt # Python-Abhängigkeiten
├── scripts/
│ ├── kiosk-start.sh # Kiosk-Start-Skript
│ ├── kiosk-monitor.sh # Überwachungsskript
│ └── emergency-restore.sh # Notfall-Wiederherstellung
└── logs/ # System-Logs
```
### Windows
```
C:\MYP\
├── backend\
│ ├── app\ # Backend-Anwendung
│ ├── venv\ # Python Virtual Environment
│ └── requirements.txt # Python-Abhängigkeiten
├── scripts\
│ ├── kiosk-start.ps1 # Kiosk-Start-Skript
│ ├── backend-start.ps1 # Backend-Start-Skript
│ └── emergency-restore.ps1 # Notfall-Wiederherstellung
└── logs\ # System-Logs
```
## Konfiguration
### Backend-Konfiguration
- **URL:** https://localhost:443
- **SSL:** Selbstsignierte Zertifikate (automatisch erstellt)
- **Umgebung:** Produktion
- **Logs:** Automatische Rotation
### Chrome-Konfiguration
- **Modus:** Vollbild-Kiosk
- **Sicherheit:** No-Sandbox für Stabilität
- **Cache:** Wird bei jedem Start geleert
- **Incognito:** Aktiviert für Datenschutz
## Wartung und Überwachung
### Service-Status prüfen
**Linux:**
```bash
sudo systemctl status myp-backend.service
sudo systemctl status myp-kiosk.service
sudo systemctl status myp-monitor.service
```
**Windows:**
```powershell
Get-Process -Name "chrome" | Where-Object { $_.ProcessName -like "*kiosk*" }
Get-Process -Name "python" | Where-Object { $_.Path -like "*MYP*" }
```
### Logs anzeigen
**Linux:**
```bash
sudo journalctl -u myp-backend.service -f
sudo journalctl -u myp-kiosk.service -f
```
**Windows:**
```powershell
Get-EventLog -LogName Application -Source "MYP*" -Newest 50
```
## Fehlerbehebung
### Backend startet nicht
1. Prüfe Python-Installation: `python3.11 --version`
2. Prüfe Virtual Environment: `ls /opt/myp/backend/venv/` (Linux)
3. Prüfe SSL-Zertifikate: `ls /opt/myp/backend/app/certs/`
4. Prüfe Logs für Fehlermeldungen
### Kiosk startet nicht
1. Prüfe Chrome-Installation: `google-chrome --version`
2. Prüfe X11-Display (Linux): `echo $DISPLAY`
3. Prüfe Backend-Verfügbarkeit: `curl -k https://localhost:443`
4. Prüfe Benutzerrechte
### System hängt im Kiosk-Modus
**Linux:**
- SSH-Zugriff von anderem Computer
- TTY-Zugriff: Strg+Alt+F2
- Stoppe Services: `sudo systemctl stop myp-kiosk.service`
**Windows:**
- Strg+Alt+Entf für Task-Manager
- Führe Notfall-Wiederherstellung aus
- Stoppe Chrome-Prozesse manuell
## Notfall-Wiederherstellung
### Automatische Wiederherstellung
**Linux:**
```bash
sudo /opt/myp/scripts/emergency-restore.sh
```
**Windows:**
- Desktop-Verknüpfung "MYP Notfall-Wiederherstellung" verwenden
- Oder: `C:\MYP\scripts\emergency-restore.ps1` ausführen
### Manuelle Wiederherstellung
**Linux:**
```bash
sudo systemctl disable myp-kiosk.service
sudo systemctl disable myp-backend.service
sudo rm /etc/lightdm/lightdm.conf.d/10-myp-kiosk.conf
sudo systemctl enable gdm3
sudo reboot
```
**Windows:**
```powershell
Get-Process -Name "chrome" | Stop-Process -Force
Remove-Item "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\MYP-Kiosk.ps1"
Restart-Computer
```
## Support und Dokumentation
### Weitere Dokumentation
- `README-Kiosk.md` - Detaillierte Systemdokumentation
- Service-Dateien enthalten Kommentare zur Konfiguration
- Skripte sind vollständig dokumentiert
### Log-Sammlung für Support
**Linux:**
```bash
sudo journalctl -u myp-* --since "1 hour ago" > myp-logs.txt
sudo systemctl status myp-* > myp-status.txt
```
**Windows:**
```powershell
Get-EventLog -LogName Application -After (Get-Date).AddHours(-1) | Out-File myp-logs.txt
Get-Process | Where-Object { $_.ProcessName -like "*chrome*" -or $_.ProcessName -like "*python*" } | Out-File myp-processes.txt
```
## Sicherheitshinweise
### Produktionsumgebung
- Ersetze selbstsignierte Zertifikate durch echte SSL-Zertifikate
- Konfiguriere Firewall für eingehende Verbindungen
- Verwende VPN für Remote-Wartung
- Regelmäßige Sicherheitsupdates durchführen
### Physische Sicherheit
- Sichere das Gerät vor unbefugtem Zugriff
- Deaktiviere USB-Ports falls möglich
- Verwende sichere Netzwerkverbindung
- Überwache Systemzugriffe
---
**Wichtiger Hinweis:** Teste die Installation zuerst in einer Testumgebung, bevor du sie in der Produktion einsetzt.

View File

@ -0,0 +1,274 @@
# MYP Kiosk-System Dokumentation
## Übersicht
Das MYP Kiosk-System ist eine vollständig automatisierte Lösung, die ein Python 3.11 Backend mit einem sicheren Chrome Kiosk-Modus kombiniert. Das System startet automatisch beim Systemstart und verhindert den Zugriff auf den Desktop.
## Systemarchitektur
### Services
1. **myp-backend.service** - Python 3.11 Flask Backend
2. **myp-kiosk.service** - Chrome Kiosk-Modus
3. **myp-monitor.service** - Überwachung und automatischer Neustart
### Sicherheitsfeatures
- Kein Desktop-Zugriff möglich
- Chrome läuft im eingeschränkten Kiosk-Modus
- Automatischer Login ohne Benutzerinteraktion
- Keine neuen Tabs oder Browser-Navigation möglich
- Automatische Wiederherstellung bei Fehlern
## Installation
### Schritt 1: Kiosk-System installieren
```bash
cd backend/install
sudo chmod +x install-kiosk.sh
sudo ./install-kiosk.sh
```
### Schritt 2: Backend einrichten
```bash
sudo chmod +x setup-backend.sh
sudo ./setup-backend.sh
```
### Schritt 3: System neu starten
```bash
sudo reboot
```
## Systemkonfiguration
### Automatischer Login
- Benutzer: `myp`
- Desktop-Umgebung: Openbox (minimal)
- Automatischer Start ohne Benutzerinteraktion
### Chrome Kiosk-Konfiguration
- Vollbild-Modus ohne Browser-UI
- Keine Tabs, Menüs oder Navigation
- Deaktivierte Entwicklertools
- Incognito-Modus für Datenschutz
- No-Sandbox für Stabilität
### Backend-Konfiguration
- Python 3.11 mit Flask
- HTTPS auf Port 443
- Automatische SSL-Zertifikate
- Produktions-Umgebung
## Verzeichnisstruktur
```
/opt/myp/
├── backend/
│ ├── app/ # Backend-Anwendung
│ ├── venv/ # Python Virtual Environment
│ └── requirements.txt # Python-Abhängigkeiten
├── scripts/
│ ├── kiosk-start.sh # Kiosk-Start-Skript
│ ├── kiosk-monitor.sh # Überwachungsskript
│ └── emergency-restore.sh # Notfall-Wiederherstellung
└── logs/ # System-Logs
/home/myp/
├── .config/
│ ├── openbox/ # Openbox-Konfiguration
│ └── google-chrome/ # Chrome-Konfiguration
```
## Service-Management
### Services starten/stoppen
```bash
# Backend
sudo systemctl start myp-backend.service
sudo systemctl stop myp-backend.service
sudo systemctl restart myp-backend.service
# Kiosk
sudo systemctl start myp-kiosk.service
sudo systemctl stop myp-kiosk.service
sudo systemctl restart myp-kiosk.service
# Monitor
sudo systemctl start myp-monitor.service
sudo systemctl stop myp-monitor.service
```
### Service-Status prüfen
```bash
sudo systemctl status myp-backend.service
sudo systemctl status myp-kiosk.service
sudo systemctl status myp-monitor.service
```
### Logs anzeigen
```bash
# Backend-Logs
sudo journalctl -u myp-backend.service -f
# Kiosk-Logs
sudo journalctl -u myp-kiosk.service -f
# Monitor-Logs
sudo journalctl -u myp-monitor.service -f
# Alle MYP-Logs
sudo journalctl -t myp-backend -t myp-kiosk -f
```
## Überwachung und Wartung
### Automatische Überwachung
Das System überwacht sich selbst und startet Services automatisch neu:
- Backend-Verfügbarkeit (alle 30 Sekunden)
- Chrome Kiosk-Prozess (alle 30 Sekunden)
- Automatischer Neustart bei Fehlern
### Manuelle Überwachung
```bash
# Prüfe Backend-Verfügbarkeit
curl -k https://localhost:443
# Prüfe Chrome-Prozesse
ps aux | grep chrome
# Prüfe System-Ressourcen
htop
```
## Fehlerbehebung
### Backend startet nicht
```bash
# Prüfe Service-Status
sudo systemctl status myp-backend.service
# Prüfe Logs
sudo journalctl -u myp-backend.service -n 50
# Prüfe Python-Umgebung
sudo -u myp /opt/myp/backend/venv/bin/python3.11 --version
# Teste Backend manuell
cd /opt/myp/backend/app
sudo -u myp /opt/myp/backend/venv/bin/python3.11 app.py
```
### Kiosk startet nicht
```bash
# Prüfe Service-Status
sudo systemctl status myp-kiosk.service
# Prüfe X11-Display
sudo -u myp DISPLAY=:0 xdpyinfo
# Prüfe Chrome-Installation
which google-chrome
google-chrome --version
# Teste Kiosk manuell
sudo -u myp DISPLAY=:0 /opt/myp/scripts/kiosk-start.sh
```
### System hängt im Kiosk-Modus
```bash
# SSH-Zugriff von anderem Computer
ssh user@kiosk-system-ip
# Oder lokaler Zugriff über TTY
# Strg+Alt+F2 (TTY2)
# Login als root oder sudo-Benutzer
# Stoppe Kiosk-Services
sudo systemctl stop myp-kiosk.service
sudo systemctl stop myp-backend.service
```
## Notfall-Wiederherstellung
### Desktop-Modus wiederherstellen
```bash
# Führe Notfall-Skript aus
sudo /opt/myp/scripts/emergency-restore.sh
# Oder manuell:
sudo systemctl disable myp-kiosk.service
sudo systemctl disable myp-backend.service
sudo rm /etc/lightdm/lightdm.conf.d/10-myp-kiosk.conf
sudo systemctl enable gdm3 # oder sddm/lightdm
sudo reboot
```
### Kiosk-Modus reaktivieren
```bash
sudo systemctl enable myp-backend.service
sudo systemctl enable myp-kiosk.service
sudo systemctl enable myp-monitor.service
sudo reboot
```
## Sicherheitshinweise
### Systemsicherheit
- Kiosk-Benutzer hat eingeschränkte Rechte
- Keine sudo-Berechtigung für Kiosk-Benutzer
- Systemd-Services mit Sicherheitsrichtlinien
- Automatische Updates deaktiviert (manuell durchführen)
### Netzwerksicherheit
- HTTPS-Verschlüsselung
- Selbstsignierte Zertifikate (für Produktion ersetzen)
- Firewall-Konfiguration empfohlen
- VPN-Zugriff für Wartung empfohlen
### Physische Sicherheit
- Tastatur-Shortcuts deaktiviert
- Kein Zugriff auf Terminal oder Dateisystem
- Automatischer Neustart bei Manipulation
- Bildschirmschoner deaktiviert
## Wartungsplan
### Täglich
- Automatische Überwachung läuft
- Logs werden automatisch rotiert
### Wöchentlich
- Service-Status prüfen
- Log-Dateien überprüfen
- System-Ressourcen überwachen
### Monatlich
- System-Updates (im Wartungsfenster)
- SSL-Zertifikate prüfen
- Backup-Strategie überprüfen
### Bei Bedarf
- Backend-Updates
- Chrome-Updates
- Konfigurationsänderungen
## Support und Kontakt
### Log-Sammlung für Support
```bash
# Sammle alle relevanten Logs
sudo journalctl -u myp-backend.service --since "1 hour ago" > backend.log
sudo journalctl -u myp-kiosk.service --since "1 hour ago" > kiosk.log
sudo systemctl status myp-*.service > service-status.log
```
### Systeminfo für Support
```bash
# System-Informationen sammeln
uname -a > system-info.txt
lsb_release -a >> system-info.txt
systemctl list-units myp-* >> system-info.txt
```
---
**Wichtiger Hinweis**: Dieses System ist für den Produktionseinsatz konzipiert. Teste alle Änderungen zuerst in einer Testumgebung.

View File

@ -0,0 +1,231 @@
# MYP Kiosk Installation Script für Windows
# Installiert und konfiguriert das komplette Kiosk-System
param(
[switch]$Force,
[string]$InstallPath = "C:\MYP"
)
# Prüfe Administrator-Rechte
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Error "Dieses Skript muss als Administrator ausgeführt werden"
exit 1
}
Write-Host "Starte MYP Kiosk Installation..." -ForegroundColor Blue
# Erstelle Installationsverzeichnis
Write-Host "Erstelle Verzeichnisstruktur..." -ForegroundColor Yellow
New-Item -ItemType Directory -Path "$InstallPath\backend" -Force | Out-Null
New-Item -ItemType Directory -Path "$InstallPath\scripts" -Force | Out-Null
New-Item -ItemType Directory -Path "$InstallPath\logs" -Force | Out-Null
# Installiere Chocolatey falls nicht vorhanden
if (!(Get-Command choco -ErrorAction SilentlyContinue)) {
Write-Host "Installiere Chocolatey..." -ForegroundColor Yellow
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
# Installiere benötigte Software
Write-Host "Installiere benötigte Software..." -ForegroundColor Yellow
choco install googlechrome python311 -y
# Erstelle Kiosk-Start-Skript
Write-Host "Erstelle Kiosk-Skripte..." -ForegroundColor Yellow
$kioskScript = @"
# MYP Kiosk Start Script für Windows
`$BackendUrl = "https://localhost:443"
`$MaxRetries = 30
`$RetryCount = 0
Write-Host "Starte MYP Kiosk-Modus..." -ForegroundColor Green
# Warte auf Backend-Verfügbarkeit
while (`$RetryCount -lt `$MaxRetries) {
try {
`$response = Invoke-WebRequest -Uri `$BackendUrl -UseBasicParsing -SkipCertificateCheck -TimeoutSec 5
if (`$response.StatusCode -eq 200) {
Write-Host "Backend ist verfügbar" -ForegroundColor Green
break
}
}
catch {
`$RetryCount++
Write-Host "Warte auf Backend... Versuch `$RetryCount/`$MaxRetries" -ForegroundColor Yellow
Start-Sleep -Seconds 2
}
}
if (`$RetryCount -ge `$MaxRetries) {
Write-Error "Backend nicht erreichbar nach `$MaxRetries Versuchen"
exit 1
}
# Beende alle Chrome-Prozesse
Get-Process -Name "chrome" -ErrorAction SilentlyContinue | Stop-Process -Force
Start-Sleep -Seconds 2
# Lösche Chrome-Cache
`$ChromeUserData = "`$env:LOCALAPPDATA\Google\Chrome\User Data"
if (Test-Path `$ChromeUserData) {
Remove-Item "`$ChromeUserData\Default\Web Data*" -Force -ErrorAction SilentlyContinue
Remove-Item "`$ChromeUserData\Default\History*" -Force -ErrorAction SilentlyContinue
}
# Chrome Kiosk-Parameter
`$ChromeArgs = @(
"--kiosk"
"--no-sandbox"
"--disable-dev-shm-usage"
"--disable-gpu-sandbox"
"--disable-software-rasterizer"
"--disable-background-timer-throttling"
"--disable-backgrounding-occluded-windows"
"--disable-renderer-backgrounding"
"--disable-features=TranslateUI,BlinkGenPropertyTrees"
"--disable-default-apps"
"--disable-extensions"
"--disable-plugins"
"--disable-sync"
"--disable-translate"
"--disable-background-networking"
"--disable-infobars"
"--disable-notifications"
"--disable-password-manager-reauthentication"
"--disable-permissions-api"
"--disable-popup-blocking"
"--disable-print-preview"
"--disable-session-crashed-bubble"
"--disable-system-notifications"
"--disable-web-security"
"--no-default-browser-check"
"--no-first-run"
"--single-process"
"--incognito"
"--disable-pinch"
"--overscroll-history-navigation=0"
"--app=`$BackendUrl"
)
Write-Host "Starte Chrome im Kiosk-Modus..." -ForegroundColor Green
# Starte Chrome
`$ChromePath = "${env:ProgramFiles}\Google\Chrome\Application\chrome.exe"
if (!(Test-Path `$ChromePath)) {
`$ChromePath = "${env:ProgramFiles(x86)}\Google\Chrome\Application\chrome.exe"
}
Start-Process -FilePath `$ChromePath -ArgumentList `$ChromeArgs -WindowStyle Maximized
"@
$kioskScript | Out-File -FilePath "$InstallPath\scripts\kiosk-start.ps1" -Encoding UTF8
# Erstelle Backend-Start-Skript
$backendScript = @"
# MYP Backend Start Script für Windows
`$BackendPath = "$InstallPath\backend"
`$VenvPath = "`$BackendPath\venv"
`$AppPath = "`$BackendPath\app"
Write-Host "Starte MYP Backend..." -ForegroundColor Green
# Aktiviere Virtual Environment
if (Test-Path "`$VenvPath\Scripts\Activate.ps1") {
& "`$VenvPath\Scripts\Activate.ps1"
}
# Wechsle ins App-Verzeichnis
Set-Location `$AppPath
# Starte Backend
& python app.py --host 0.0.0.0 --port 443 --cert certs/backend.crt --key certs/backend.key
"@
$backendScript | Out-File -FilePath "$InstallPath\scripts\backend-start.ps1" -Encoding UTF8
# Erstelle Überwachungsskript
$monitorScript = @"
# MYP Kiosk Monitor für Windows
while (`$true) {
# Prüfe Chrome-Prozess
if (!(Get-Process -Name "chrome" -ErrorAction SilentlyContinue)) {
Write-Host "`$(Get-Date): Chrome nicht gefunden, starte neu..." -ForegroundColor Yellow
& "$InstallPath\scripts\kiosk-start.ps1"
}
# Prüfe Backend-Verfügbarkeit
try {
`$response = Invoke-WebRequest -Uri "https://localhost:443" -UseBasicParsing -SkipCertificateCheck -TimeoutSec 5
}
catch {
Write-Host "`$(Get-Date): Backend nicht erreichbar, starte neu..." -ForegroundColor Yellow
& "$InstallPath\scripts\backend-start.ps1"
}
Start-Sleep -Seconds 30
}
"@
$monitorScript | Out-File -FilePath "$InstallPath\scripts\kiosk-monitor.ps1" -Encoding UTF8
# Erstelle Windows-Service-Wrapper
$serviceScript = @"
# MYP Service Wrapper
`$BackendJob = Start-Job -ScriptBlock { & "$InstallPath\scripts\backend-start.ps1" }
Start-Sleep -Seconds 10
`$KioskJob = Start-Job -ScriptBlock { & "$InstallPath\scripts\kiosk-start.ps1" }
`$MonitorJob = Start-Job -ScriptBlock { & "$InstallPath\scripts\kiosk-monitor.ps1" }
# Warte auf Jobs
Wait-Job `$BackendJob, `$KioskJob, `$MonitorJob
"@
$serviceScript | Out-File -FilePath "$InstallPath\scripts\myp-service.ps1" -Encoding UTF8
# Erstelle Autostart-Eintrag
Write-Host "Konfiguriere Autostart..." -ForegroundColor Yellow
$startupScript = @"
# MYP Autostart
Start-Sleep -Seconds 5
& "$InstallPath\scripts\myp-service.ps1"
"@
$startupPath = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup"
$startupScript | Out-File -FilePath "$startupPath\MYP-Kiosk.ps1" -Encoding UTF8
# Erstelle Desktop-Verknüpfung für Notfall-Wiederherstellung
$emergencyScript = @"
# Notfall-Wiederherstellung
Write-Host "Deaktiviere Kiosk-Modus..." -ForegroundColor Yellow
# Stoppe alle MYP-Prozesse
Get-Process -Name "chrome" -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process -Name "python" -ErrorAction SilentlyContinue | Where-Object { `$_.Path -like "*MYP*" } | Stop-Process -Force
# Entferne Autostart
Remove-Item "$startupPath\MYP-Kiosk.ps1" -Force -ErrorAction SilentlyContinue
Write-Host "Kiosk-Modus deaktiviert. System neu starten für normalen Desktop." -ForegroundColor Green
"@
$emergencyScript | Out-File -FilePath "$InstallPath\scripts\emergency-restore.ps1" -Encoding UTF8
# Erstelle Desktop-Verknüpfung
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:PUBLIC\Desktop\MYP Notfall-Wiederherstellung.lnk")
$Shortcut.TargetPath = "powershell.exe"
$Shortcut.Arguments = "-ExecutionPolicy Bypass -File `"$InstallPath\scripts\emergency-restore.ps1`""
$Shortcut.WorkingDirectory = "$InstallPath\scripts"
$Shortcut.IconLocation = "shell32.dll,21"
$Shortcut.Description = "MYP Kiosk Notfall-Wiederherstellung"
$Shortcut.Save()
Write-Host "MYP Kiosk Installation abgeschlossen!" -ForegroundColor Green
Write-Host "Nächste Schritte:" -ForegroundColor Yellow
Write-Host "1. Backend-Code nach $InstallPath\backend kopieren" -ForegroundColor White
Write-Host "2. Python Virtual Environment einrichten" -ForegroundColor White
Write-Host "3. SSL-Zertifikate konfigurieren" -ForegroundColor White
Write-Host "4. System neu starten" -ForegroundColor White
Write-Host "Notfall-Wiederherstellung: Desktop-Verknüpfung verwenden" -ForegroundColor Red

View File

@ -0,0 +1,216 @@
#!/bin/bash
# MYP Kiosk Installation Script
# Installiert und konfiguriert das komplette Kiosk-System
set -euo pipefail
# Farben für Output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging-Funktionen
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Prüfe Root-Rechte
if [[ $EUID -ne 0 ]]; then
log_error "Dieses Skript muss als root ausgeführt werden"
exit 1
fi
log_info "Starte MYP Kiosk Installation..."
# System-Update
log_info "Aktualisiere System-Pakete..."
apt update && apt upgrade -y
# Installiere benötigte Pakete
log_info "Installiere benötigte Pakete..."
apt install -y \
google-chrome-stable \
xorg \
openbox \
lightdm \
curl \
systemd \
python3.11 \
python3.11-venv \
python3-pip \
unclutter \
xdotool
# Erstelle MYP-Benutzer falls nicht vorhanden
if ! id "myp" &>/dev/null; then
log_info "Erstelle MYP-Benutzer..."
useradd -m -s /bin/bash myp
usermod -aG audio,video,input myp
else
log_info "MYP-Benutzer bereits vorhanden"
fi
# Erstelle Verzeichnisstruktur
log_info "Erstelle Verzeichnisstruktur..."
mkdir -p /opt/myp/{backend,scripts,logs}
mkdir -p /home/myp/.config/openbox
mkdir -p /home/myp/.config/google-chrome
# Kopiere Service-Dateien
log_info "Installiere Service-Dateien..."
cp myp-backend.service /etc/systemd/system/
cp myp-kiosk.service /etc/systemd/system/
# Kopiere und setze Berechtigungen für Skripte
log_info "Installiere Kiosk-Skripte..."
cp kiosk-start.sh /opt/myp/scripts/
chmod +x /opt/myp/scripts/kiosk-start.sh
# Erstelle Openbox-Konfiguration für automatischen Kiosk-Start
log_info "Konfiguriere Openbox für Kiosk-Modus..."
cat > /home/myp/.config/openbox/autostart << 'EOF'
# MYP Kiosk Autostart
# Deaktiviere Bildschirmschoner und Energieverwaltung
xset -dpms &
xset s off &
xset s noblank &
# Verstecke Mauszeiger bei Inaktivität
unclutter -idle 0.1 -root &
# Verhindere versehentliche Tastenkombinationen
xdotool key ctrl+alt+t &
# Starte Kiosk-Service
systemctl --user start myp-kiosk.service &
EOF
# Erstelle LightDM-Konfiguration für automatischen Login
log_info "Konfiguriere automatischen Login..."
cat > /etc/lightdm/lightdm.conf.d/10-myp-kiosk.conf << 'EOF'
[Seat:*]
autologin-user=myp
autologin-user-timeout=0
user-session=openbox
autologin-session=openbox
greeter-session=unity-greeter
allow-guest=false
EOF
# Erstelle Desktop-Session für MYP
log_info "Erstelle Desktop-Session..."
cat > /usr/share/xsessions/myp-kiosk.desktop << 'EOF'
[Desktop Entry]
Name=MYP Kiosk
Comment=MYP Reservation Platform Kiosk Mode
Exec=openbox-session
Type=Application
DesktopNames=MYP
EOF
# Setze Berechtigungen
log_info "Setze Berechtigungen..."
chown -R myp:myp /home/myp
chown -R myp:myp /opt/myp
chmod 755 /opt/myp/scripts/kiosk-start.sh
# Systemd-Services aktivieren
log_info "Aktiviere Systemd-Services..."
systemctl daemon-reload
systemctl enable myp-backend.service
systemctl enable myp-kiosk.service
# Erstelle Kiosk-Überwachungsskript
log_info "Erstelle Überwachungsskript..."
cat > /opt/myp/scripts/kiosk-monitor.sh << 'EOF'
#!/bin/bash
# MYP Kiosk Monitor - Überwacht und startet Kiosk-Prozesse neu
while true; do
# Prüfe ob Chrome läuft
if ! pgrep -f "google-chrome.*kiosk" > /dev/null; then
echo "$(date): Chrome Kiosk nicht gefunden, starte neu..." >> /opt/myp/logs/kiosk-monitor.log
systemctl restart myp-kiosk.service
fi
# Prüfe ob Backend läuft
if ! curl -k -s https://localhost:443 > /dev/null 2>&1; then
echo "$(date): Backend nicht erreichbar, starte neu..." >> /opt/myp/logs/kiosk-monitor.log
systemctl restart myp-backend.service
fi
sleep 30
done
EOF
chmod +x /opt/myp/scripts/kiosk-monitor.sh
# Erstelle Monitor-Service
cat > /etc/systemd/system/myp-monitor.service << 'EOF'
[Unit]
Description=MYP Kiosk Monitor
After=myp-backend.service myp-kiosk.service
[Service]
Type=simple
User=root
ExecStart=/opt/myp/scripts/kiosk-monitor.sh
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
systemctl enable myp-monitor.service
# Deaktiviere Desktop-Umgebung und unnötige Services
log_info "Deaktiviere unnötige Services..."
systemctl disable gdm3 2>/dev/null || true
systemctl disable sddm 2>/dev/null || true
systemctl disable plymouth 2>/dev/null || true
# Erstelle Backup-Wiederherstellungsskript
log_info "Erstelle Notfall-Wiederherstellungsskript..."
cat > /opt/myp/scripts/emergency-restore.sh << 'EOF'
#!/bin/bash
# Notfall-Wiederherstellung: Deaktiviert Kiosk-Modus und aktiviert normalen Desktop
echo "Deaktiviere Kiosk-Modus..."
systemctl disable myp-kiosk.service
systemctl disable myp-backend.service
systemctl disable myp-monitor.service
echo "Aktiviere normalen Desktop..."
systemctl enable gdm3 || systemctl enable sddm || systemctl enable lightdm
echo "Entferne automatischen Login..."
rm -f /etc/lightdm/lightdm.conf.d/10-myp-kiosk.conf
echo "Kiosk-Modus deaktiviert. System neu starten für normalen Desktop."
EOF
chmod +x /opt/myp/scripts/emergency-restore.sh
log_success "MYP Kiosk Installation abgeschlossen!"
log_info "Nächste Schritte:"
log_info "1. Backend-Code nach /opt/myp/backend kopieren"
log_info "2. Python Virtual Environment einrichten"
log_info "3. SSL-Zertifikate konfigurieren"
log_info "4. System neu starten: sudo reboot"
log_warning "Notfall-Wiederherstellung: /opt/myp/scripts/emergency-restore.sh"

View File

@ -0,0 +1,95 @@
#!/bin/bash
# MYP Kiosk Start Script
# Startet Chrome im sicheren Kiosk-Modus ohne Desktop-Zugriff
set -euo pipefail
# Logging-Funktion
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') [KIOSK] $1" | systemd-cat -t myp-kiosk
}
log "Starte MYP Kiosk-Modus..."
# Warte auf Backend-Verfügbarkeit
BACKEND_URL="https://localhost:443"
MAX_RETRIES=30
RETRY_COUNT=0
while ! curl -k -s "$BACKEND_URL" > /dev/null 2>&1; do
if [ $RETRY_COUNT -ge $MAX_RETRIES ]; then
log "FEHLER: Backend nicht erreichbar nach $MAX_RETRIES Versuchen"
exit 1
fi
log "Warte auf Backend... Versuch $((RETRY_COUNT + 1))/$MAX_RETRIES"
sleep 2
((RETRY_COUNT++))
done
log "Backend ist verfügbar, starte Chrome Kiosk..."
# Beende alle laufenden Chrome-Prozesse
pkill -f "google-chrome" || true
pkill -f "chromium" || true
sleep 2
# Lösche Chrome-Cache und temporäre Dateien
rm -rf /home/myp/.cache/google-chrome/* 2>/dev/null || true
rm -rf /home/myp/.config/google-chrome/Default/Web\ Data* 2>/dev/null || true
rm -rf /home/myp/.config/google-chrome/Default/History* 2>/dev/null || true
# Erstelle Chrome-Konfigurationsverzeichnis falls nicht vorhanden
mkdir -p /home/myp/.config/google-chrome/Default
# Chrome Kiosk-Konfiguration
CHROME_OPTS=(
--kiosk
--no-sandbox
--disable-dev-shm-usage
--disable-gpu-sandbox
--disable-software-rasterizer
--disable-background-timer-throttling
--disable-backgrounding-occluded-windows
--disable-renderer-backgrounding
--disable-features=TranslateUI,BlinkGenPropertyTrees
--disable-ipc-flooding-protection
--disable-default-apps
--disable-extensions
--disable-plugins
--disable-sync
--disable-translate
--disable-background-networking
--disable-background-downloads
--disable-add-to-shelf
--disable-first-run-ui
--disable-infobars
--disable-notifications
--disable-password-generation
--disable-password-manager-reauthentication
--disable-permissions-api
--disable-popup-blocking
--disable-print-preview
--disable-prompt-on-repost
--disable-session-crashed-bubble
--disable-system-notifications
--disable-web-security
--no-default-browser-check
--no-first-run
--no-pings
--no-zygote
--single-process
--incognito
--disable-pinch
--overscroll-history-navigation=0
--disable-touch-editing
--disable-touch-drag-drop
--disable-pull-to-refresh-effect
--user-data-dir=/home/myp/.config/google-chrome
--app="$BACKEND_URL"
)
log "Starte Chrome mit Kiosk-Optionen..."
# Starte Chrome im Kiosk-Modus
exec /usr/bin/google-chrome "${CHROME_OPTS[@]}" 2>&1 | systemd-cat -t myp-kiosk

View File

@ -0,0 +1,48 @@
[Unit]
Description=MYP Backend Service (Python 3.11)
Documentation=https://github.com/myp-project/backend
After=network-online.target
Wants=network-online.target
Before=myp-kiosk.service
[Service]
Type=simple
User=myp
Group=myp
WorkingDirectory=/opt/myp/backend/app
Environment=PYTHONPATH=/opt/myp/backend/app
Environment=FLASK_ENV=production
Environment=FLASK_APP=app.py
Environment=PYTHONUNBUFFERED=1
Environment=PYTHONDONTWRITEBYTECODE=1
ExecStartPre=/bin/sleep 5
ExecStart=/opt/myp/backend/venv/bin/python3.11 app.py --host 0.0.0.0 --port 443 --cert certs/backend.crt --key certs/backend.key
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=10
TimeoutStartSec=60
TimeoutStopSec=30
StandardOutput=journal
StandardError=journal
SyslogIdentifier=myp-backend
# Sicherheitseinstellungen
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictRealtime=true
RestrictSUIDSGID=true
ReadWritePaths=/opt/myp/backend/app/logs
ReadWritePaths=/opt/myp/backend/app/database
ReadWritePaths=/opt/myp/backend/app/uploads
# Ressourcenlimits
MemoryMax=1G
CPUQuota=80%
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,37 @@
[Unit]
Description=MYP Kiosk Mode (Chrome Vollbild)
Documentation=https://github.com/myp-project/kiosk
After=graphical-session.target myp-backend.service
Wants=graphical-session.target
Requires=myp-backend.service
PartOf=graphical-session.target
[Service]
Type=simple
User=myp
Group=myp
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/myp/.Xauthority
WorkingDirectory=/home/myp
ExecStartPre=/bin/sleep 10
ExecStartPre=/usr/bin/xset -dpms
ExecStartPre=/usr/bin/xset s off
ExecStartPre=/usr/bin/xset s noblank
ExecStart=/opt/myp/scripts/kiosk-start.sh
ExecStop=/usr/bin/pkill -f "google-chrome.*kiosk"
Restart=always
RestartSec=5
TimeoutStartSec=30
TimeoutStopSec=10
StandardOutput=journal
StandardError=journal
SyslogIdentifier=myp-kiosk
# Sicherheitseinstellungen
NoNewPrivileges=true
PrivateTmp=true
ProtectHome=false
ProtectSystem=true
[Install]
WantedBy=graphical-session.target

View File

@ -0,0 +1,210 @@
# MYP Backend Setup Script für Windows
# Richtet das Python 3.11 Backend nach der Kiosk-Installation ein
param(
[string]$InstallPath = "C:\MYP"
)
# Prüfe Administrator-Rechte
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Error "Dieses Skript muss als Administrator ausgeführt werden"
exit 1
}
Write-Host "Starte MYP Backend Setup..." -ForegroundColor Blue
# Prüfe ob Kiosk-Installation vorhanden ist
if (!(Test-Path "$InstallPath")) {
Write-Error "Kiosk-Installation nicht gefunden. Führe zuerst install-kiosk.ps1 aus."
exit 1
}
# Kopiere Backend-Code
Write-Host "Kopiere Backend-Code..." -ForegroundColor Yellow
$currentDir = Get-Location
$appPath = Join-Path $currentDir.Path "..\app"
$requirementsPath = Join-Path $currentDir.Path "..\requirements.txt"
if (Test-Path $appPath) {
Copy-Item -Path $appPath -Destination "$InstallPath\backend\" -Recurse -Force
Copy-Item -Path $requirementsPath -Destination "$InstallPath\backend\" -Force
Write-Host "Backend-Code kopiert" -ForegroundColor Green
} else {
Write-Error "Backend-Code nicht gefunden. Stelle sicher, dass das Skript aus dem install-Verzeichnis ausgeführt wird."
exit 1
}
# Erstelle Python Virtual Environment
Write-Host "Erstelle Python 3.11 Virtual Environment..." -ForegroundColor Yellow
Set-Location "$InstallPath\backend"
# Finde Python 3.11
$python311 = Get-Command python3.11 -ErrorAction SilentlyContinue
if (!$python311) {
$python311 = Get-Command python -ErrorAction SilentlyContinue | Where-Object { $_.Version.Major -eq 3 -and $_.Version.Minor -eq 11 }
}
if (!$python311) {
Write-Error "Python 3.11 nicht gefunden. Installiere Python 3.11 zuerst."
exit 1
}
# Erstelle Virtual Environment
& $python311.Source -m venv venv
if ($LASTEXITCODE -ne 0) {
Write-Error "Fehler beim Erstellen des Virtual Environment"
exit 1
}
# Aktiviere Virtual Environment
& ".\venv\Scripts\Activate.ps1"
# Installiere Python-Abhängigkeiten
Write-Host "Installiere Python-Abhängigkeiten..." -ForegroundColor Yellow
& python -m pip install --upgrade pip
& pip install -r requirements.txt
if ($LASTEXITCODE -ne 0) {
Write-Error "Fehler beim Installieren der Python-Abhängigkeiten"
exit 1
}
# Erstelle SSL-Zertifikate falls nicht vorhanden
Write-Host "Erstelle SSL-Zertifikate..." -ForegroundColor Yellow
$certsPath = "$InstallPath\backend\app\certs"
New-Item -ItemType Directory -Path $certsPath -Force | Out-Null
$certFile = "$certsPath\backend.crt"
$keyFile = "$certsPath\backend.key"
if (!(Test-Path $certFile) -or !(Test-Path $keyFile)) {
Write-Host "Generiere selbstsignierte SSL-Zertifikate..." -ForegroundColor Yellow
# Prüfe ob OpenSSL verfügbar ist
$openssl = Get-Command openssl -ErrorAction SilentlyContinue
if ($openssl) {
& openssl req -x509 -newkey rsa:4096 -keyout $keyFile -out $certFile -days 365 -nodes -subj "/C=DE/ST=State/L=City/O=MYP/OU=Backend/CN=localhost"
} else {
# Verwende PowerShell für Zertifikatserstellung
$cert = New-SelfSignedCertificate -DnsName "localhost" -CertStoreLocation "cert:\LocalMachine\My" -KeyUsage DigitalSignature,KeyEncipherment -KeyAlgorithm RSA -KeyLength 4096 -NotAfter (Get-Date).AddDays(365)
# Exportiere Zertifikat
$certPassword = ConvertTo-SecureString -String "myp-backend" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath "$certsPath\backend.pfx" -Password $certPassword | Out-Null
# Konvertiere zu PEM-Format (vereinfacht)
$certBase64 = [Convert]::ToBase64String($cert.RawData)
$certPem = "-----BEGIN CERTIFICATE-----`n"
for ($i = 0; $i -lt $certBase64.Length; $i += 64) {
$line = $certBase64.Substring($i, [Math]::Min(64, $certBase64.Length - $i))
$certPem += "$line`n"
}
$certPem += "-----END CERTIFICATE-----"
$certPem | Out-File -FilePath $certFile -Encoding ASCII
Write-Host "Zertifikat erstellt (vereinfachtes Format)" -ForegroundColor Yellow
}
Write-Warning "Selbstsignierte Zertifikate erstellt. Für Produktion echte Zertifikate verwenden."
} else {
Write-Host "SSL-Zertifikate bereits vorhanden" -ForegroundColor Green
}
# Initialisiere Datenbank
Write-Host "Initialisiere Datenbank..." -ForegroundColor Yellow
Set-Location "$InstallPath\backend\app"
if (Test-Path "init_db.py") {
& python init_db.py
if ($LASTEXITCODE -eq 0) {
Write-Host "Datenbank initialisiert" -ForegroundColor Green
} else {
Write-Warning "Fehler bei Datenbankinitialisierung"
}
} else {
Write-Warning "init_db.py nicht gefunden, überspringe Datenbankinitialisierung"
}
# Erstelle Log-Verzeichnisse
Write-Host "Erstelle Log-Verzeichnisse..." -ForegroundColor Yellow
$logDirs = @("app", "auth", "errors", "jobs", "printers", "scheduler")
foreach ($dir in $logDirs) {
New-Item -ItemType Directory -Path "$InstallPath\backend\app\logs\$dir" -Force | Out-Null
}
# Erstelle Backup-Verzeichnis
New-Item -ItemType Directory -Path "$InstallPath\backend\app\database\backups" -Force | Out-Null
# Teste Backend-Konfiguration
Write-Host "Teste Backend-Konfiguration..." -ForegroundColor Yellow
try {
& python -c "import app; print('Backend-Import erfolgreich')"
if ($LASTEXITCODE -eq 0) {
Write-Host "Backend-Konfiguration gültig" -ForegroundColor Green
} else {
Write-Error "Backend-Konfiguration fehlerhaft"
exit 1
}
} catch {
Write-Error "Fehler beim Testen der Backend-Konfiguration: $_"
exit 1
}
# Erstelle Windows-Service für Backend
Write-Host "Erstelle Windows-Service..." -ForegroundColor Yellow
$serviceScript = @"
# MYP Backend Windows Service
`$BackendPath = "$InstallPath\backend\app"
`$VenvPath = "$InstallPath\backend\venv"
# Aktiviere Virtual Environment
& "`$VenvPath\Scripts\Activate.ps1"
# Wechsle ins App-Verzeichnis
Set-Location `$BackendPath
# Starte Backend
& python app.py --host 0.0.0.0 --port 443 --cert certs/backend.crt --key certs/backend.key
"@
$serviceScript | Out-File -FilePath "$InstallPath\scripts\backend-service.ps1" -Encoding UTF8
# Teste Backend-Start
Write-Host "Teste Backend-Start..." -ForegroundColor Yellow
$backendJob = Start-Job -ScriptBlock {
param($InstallPath)
Set-Location "$InstallPath\backend\app"
& "$InstallPath\backend\venv\Scripts\python.exe" -c "
import app
import threading
import time
def start_app():
try:
app.app.run(host='0.0.0.0', port=8080, debug=False, ssl_context='adhoc')
except:
pass
thread = threading.Thread(target=start_app)
thread.daemon = True
thread.start()
time.sleep(5)
print('Backend-Test abgeschlossen')
"
} -ArgumentList $InstallPath
Wait-Job $backendJob -Timeout 15 | Out-Null
$result = Receive-Job $backendJob
Remove-Job $backendJob -Force
if ($result -like "*Backend-Test abgeschlossen*") {
Write-Host "Backend-Test erfolgreich" -ForegroundColor Green
} else {
Write-Warning "Backend-Test unvollständig, aber Installation fortgesetzt"
}
Write-Host "MYP Backend Setup abgeschlossen!" -ForegroundColor Green
Write-Host "Backend-Pfad: $InstallPath\backend" -ForegroundColor White
Write-Host "Nächste Schritte:" -ForegroundColor Yellow
Write-Host "1. System neu starten für Kiosk-Modus" -ForegroundColor White
Write-Host "2. Backend wird automatisch auf https://localhost:443 gestartet" -ForegroundColor White
Write-Host "3. Chrome Kiosk öffnet automatisch die Anwendung" -ForegroundColor White
Write-Host "Notfall-Wiederherstellung: Desktop-Verknüpfung verwenden" -ForegroundColor Red

View File

@ -0,0 +1,144 @@
#!/bin/bash
# MYP Backend Setup Script
# Richtet das Python 3.11 Backend nach der Kiosk-Installation ein
set -euo pipefail
# Farben für Output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Logging-Funktionen
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Prüfe Root-Rechte
if [[ $EUID -ne 0 ]]; then
log_error "Dieses Skript muss als root ausgeführt werden"
exit 1
fi
log_info "Starte MYP Backend Setup..."
# Prüfe ob Kiosk-Installation vorhanden ist
if [ ! -d "/opt/myp" ]; then
log_error "Kiosk-Installation nicht gefunden. Führe zuerst install-kiosk.sh aus."
exit 1
fi
# Kopiere Backend-Code
log_info "Kopiere Backend-Code..."
if [ -d "$(pwd)/../app" ]; then
cp -r "$(pwd)/../app" /opt/myp/backend/
cp "$(pwd)/../requirements.txt" /opt/myp/backend/
else
log_error "Backend-Code nicht gefunden. Stelle sicher, dass das Skript aus dem install-Verzeichnis ausgeführt wird."
exit 1
fi
# Erstelle Python Virtual Environment
log_info "Erstelle Python 3.11 Virtual Environment..."
cd /opt/myp/backend
python3.11 -m venv venv
source venv/bin/activate
# Installiere Python-Abhängigkeiten
log_info "Installiere Python-Abhängigkeiten..."
pip install --upgrade pip
pip install -r requirements.txt
# Erstelle SSL-Zertifikate falls nicht vorhanden
log_info "Erstelle SSL-Zertifikate..."
mkdir -p /opt/myp/backend/app/certs
cd /opt/myp/backend/app/certs
if [ ! -f "backend.crt" ] || [ ! -f "backend.key" ]; then
log_info "Generiere selbstsignierte SSL-Zertifikate..."
openssl req -x509 -newkey rsa:4096 -keyout backend.key -out backend.crt -days 365 -nodes \
-subj "/C=DE/ST=State/L=City/O=MYP/OU=Backend/CN=localhost"
log_warning "Selbstsignierte Zertifikate erstellt. Für Produktion echte Zertifikate verwenden."
else
log_info "SSL-Zertifikate bereits vorhanden"
fi
# Initialisiere Datenbank
log_info "Initialisiere Datenbank..."
cd /opt/myp/backend/app
if [ -f "init_db.py" ]; then
python init_db.py
log_success "Datenbank initialisiert"
else
log_warning "init_db.py nicht gefunden, überspringe Datenbankinitialisierung"
fi
# Setze Berechtigungen
log_info "Setze Berechtigungen..."
chown -R myp:myp /opt/myp/backend
chmod -R 755 /opt/myp/backend
chmod 600 /opt/myp/backend/app/certs/backend.key
chmod 644 /opt/myp/backend/app/certs/backend.crt
# Erstelle Log-Verzeichnisse
log_info "Erstelle Log-Verzeichnisse..."
mkdir -p /opt/myp/backend/app/logs/{app,auth,errors,jobs,printers,scheduler}
chown -R myp:myp /opt/myp/backend/app/logs
# Erstelle Backup-Verzeichnis
log_info "Erstelle Backup-Verzeichnis..."
mkdir -p /opt/myp/backend/app/database/backups
chown -R myp:myp /opt/myp/backend/app/database
# Teste Backend-Start
log_info "Teste Backend-Konfiguration..."
cd /opt/myp/backend/app
if sudo -u myp /opt/myp/backend/venv/bin/python3.11 -c "import app; print('Backend-Import erfolgreich')"; then
log_success "Backend-Konfiguration gültig"
else
log_error "Backend-Konfiguration fehlerhaft"
exit 1
fi
# Starte Services
log_info "Starte MYP Services..."
systemctl daemon-reload
systemctl start myp-backend.service
systemctl start myp-monitor.service
# Warte auf Backend-Start
log_info "Warte auf Backend-Start..."
sleep 10
# Teste Backend-Verfügbarkeit
if curl -k -s https://localhost:443 > /dev/null 2>&1; then
log_success "Backend erfolgreich gestartet und erreichbar"
else
log_error "Backend nicht erreichbar, prüfe Logs: journalctl -u myp-backend.service"
exit 1
fi
# Zeige Service-Status
log_info "Service-Status:"
systemctl status myp-backend.service --no-pager -l
systemctl status myp-monitor.service --no-pager -l
log_success "MYP Backend Setup abgeschlossen!"
log_info "Backend läuft auf: https://localhost:443"
log_info "Logs anzeigen: journalctl -u myp-backend.service -f"
log_info "Kiosk-Modus starten: sudo reboot"