🎉 Feat(docs): Rename and reorganize documentation files 🎉
This commit is contained in:
parent
dfbab0488c
commit
8b7f16cd93
@ -1,20 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# ===================================================================
|
# ===================================================================
|
||||||
# MYP Druckerverwaltung - Konsolidiertes Installations- und Kiosk-Setup
|
# MYP Druckerverwaltung - Installer für Raspbian Kiosk-System
|
||||||
# Kombiniert alle .sh-Skripte und implementiert Kiosk-Modus für Raspberry Pi
|
# Entwickelt auf Windows, ausführbar auf Raspberry Pi / Debian
|
||||||
# Automatischer Start ohne Benutzeranmeldung über systemd
|
# OHNE virtualenv - verwendet System-Python mit --break-system-packages
|
||||||
# ===================================================================
|
# ===================================================================
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# =========================== KONFIGURATION ===========================
|
# =========================== KONFIGURATION ===========================
|
||||||
KIOSK_USER="kiosk"
|
APP_NAME="MYP Druckerverwaltung"
|
||||||
APP_USER="myp"
|
APP_DIR="/opt/myp"
|
||||||
APP_DIR="/opt/myp-druckerverwaltung"
|
SERVICE_NAME="myp-kiosk"
|
||||||
CURRENT_DIR="$(pwd)"
|
CURRENT_DIR="$(pwd)"
|
||||||
INSTALL_LOG="/var/log/myp-kiosk-install.log"
|
INSTALL_LOG="/var/log/myp-install.log"
|
||||||
CHROMIUM_BIN=""
|
|
||||||
|
|
||||||
# Farben für Ausgabe
|
# Farben für Ausgabe
|
||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
@ -54,564 +53,309 @@ check_root() {
|
|||||||
export PATH="/usr/sbin:/sbin:/usr/bin:/bin:/usr/local/bin:$PATH"
|
export PATH="/usr/sbin:/sbin:/usr/bin:/bin:/usr/local/bin:$PATH"
|
||||||
}
|
}
|
||||||
|
|
||||||
detect_system() {
|
check_debian_system() {
|
||||||
log "Erkenne System-Umgebung..."
|
if [ ! -f /etc/debian_version ]; then
|
||||||
|
error "Dieses Skript ist nur für Debian/Raspbian-Systeme geeignet!"
|
||||||
# Aktuelle Position ermitteln
|
|
||||||
CURRENT_DIR="$(pwd)"
|
|
||||||
log "Aktuelles Verzeichnis: $CURRENT_DIR"
|
|
||||||
|
|
||||||
# System-Info sammeln
|
|
||||||
info "System: $(uname -a)"
|
|
||||||
info "Distribution: $(lsb_release -d 2>/dev/null || cat /etc/os-release | head -1 || echo 'Unbekannt')"
|
|
||||||
|
|
||||||
# Internetverbindung testen
|
|
||||||
if ! ping -c 1 google.com &> /dev/null; then
|
|
||||||
error "Keine Internetverbindung verfügbar!"
|
|
||||||
fi
|
fi
|
||||||
|
log "✅ Debian/Raspbian-System erkannt"
|
||||||
log "✅ System-Checks erfolgreich"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ========================== SYSTEM-UPDATE ==========================
|
# ========================== ABHÄNGIGKEITEN INSTALLIEREN ==========================
|
||||||
update_system() {
|
install_system_dependencies() {
|
||||||
log "=== SYSTEM-UPDATE ==="
|
log "=== INSTALLIERE SYSTEM-ABHÄNGIGKEITEN ==="
|
||||||
|
|
||||||
progress "Aktualisiere Paketlisten..."
|
progress "Aktualisiere Paketlisten..."
|
||||||
apt-get update -y || error "APT Update fehlgeschlagen"
|
apt-get update -y || error "APT Update fehlgeschlagen"
|
||||||
|
|
||||||
progress "Upgrade bestehender Pakete..."
|
progress "Installiere Python 3 und grundlegende Pakete..."
|
||||||
apt-get upgrade -y || warning "APT Upgrade teilweise fehlgeschlagen"
|
|
||||||
|
|
||||||
progress "Installiere essenzielle System-Tools..."
|
|
||||||
apt-get install -y \
|
apt-get install -y \
|
||||||
ca-certificates gnupg lsb-release software-properties-common \
|
python3 \
|
||||||
apt-transport-https curl wget git unzip nano htop rsync \
|
python3-pip \
|
||||||
sudo cron logrotate tree zip keyboard-configuration \
|
python3-dev \
|
||||||
console-setup console-data kbd locales \
|
python3-setuptools \
|
||||||
|| error "Essenzielle Pakete Installation fehlgeschlagen"
|
build-essential \
|
||||||
|
libssl-dev \
|
||||||
|
libffi-dev \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
wget \
|
||||||
|
nano \
|
||||||
|
htop \
|
||||||
|
rsync \
|
||||||
|
unzip \
|
||||||
|
sudo \
|
||||||
|
systemd \
|
||||||
|
ca-certificates \
|
||||||
|
gnupg \
|
||||||
|
lsb-release \
|
||||||
|
sqlite3 \
|
||||||
|
|| error "System-Pakete Installation fehlgeschlagen"
|
||||||
|
|
||||||
log "✅ System-Update abgeschlossen"
|
progress "Installiere Python-Abhängigkeiten mit --break-system-packages..."
|
||||||
|
|
||||||
|
# Core Flask Framework
|
||||||
|
pip3 install --break-system-packages Flask==3.1.1 || error "Flask Installation fehlgeschlagen"
|
||||||
|
pip3 install --break-system-packages Flask-Login==0.6.3 || error "Flask-Login Installation fehlgeschlagen"
|
||||||
|
pip3 install --break-system-packages Flask-WTF==1.2.1 || error "Flask-WTF Installation fehlgeschlagen"
|
||||||
|
|
||||||
|
# Datenbank
|
||||||
|
pip3 install --break-system-packages SQLAlchemy==2.0.36 || error "SQLAlchemy Installation fehlgeschlagen"
|
||||||
|
|
||||||
|
# Sicherheit
|
||||||
|
pip3 install --break-system-packages bcrypt==4.2.1 || error "bcrypt Installation fehlgeschlagen"
|
||||||
|
pip3 install --break-system-packages cryptography==44.0.0 || error "cryptography Installation fehlgeschlagen"
|
||||||
|
pip3 install --break-system-packages Werkzeug==3.1.3 || error "Werkzeug Installation fehlgeschlagen"
|
||||||
|
|
||||||
|
# Smart Plug Steuerung
|
||||||
|
pip3 install --break-system-packages PyP100 || warning "PyP100 Installation fehlgeschlagen (optional)"
|
||||||
|
|
||||||
|
# HTTP Requests
|
||||||
|
pip3 install --break-system-packages requests==2.32.3 || error "requests Installation fehlgeschlagen"
|
||||||
|
|
||||||
|
# System Monitoring
|
||||||
|
pip3 install --break-system-packages psutil==6.1.1 || error "psutil Installation fehlgeschlagen"
|
||||||
|
|
||||||
|
# Redis (optional)
|
||||||
|
pip3 install --break-system-packages redis==5.2.1 || warning "redis Installation fehlgeschlagen (optional)"
|
||||||
|
|
||||||
|
# Weitere Core-Abhängigkeiten
|
||||||
|
pip3 install --break-system-packages MarkupSafe==3.0.2 || error "MarkupSafe Installation fehlgeschlagen"
|
||||||
|
|
||||||
|
# Produktions-Server
|
||||||
|
pip3 install --break-system-packages gunicorn==23.0.0 || error "gunicorn Installation fehlgeschlagen"
|
||||||
|
|
||||||
|
log "✅ Alle Abhängigkeiten erfolgreich installiert"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ========================== PAKETE INSTALLIEREN ==========================
|
# ========================== PRODUKTIONS-KIOSK SETUP ==========================
|
||||||
install_packages() {
|
setup_production_kiosk() {
|
||||||
log "=== SYSTEM-PAKETE INSTALLATION ==="
|
log "=== RICHTE PRODUKTIONS-KIOSK-MODUS EIN ==="
|
||||||
|
|
||||||
progress "Installiere Basis-Pakete..."
|
# Zuerst Abhängigkeiten installieren
|
||||||
apt-get install -y \
|
install_system_dependencies
|
||||||
python3 python3-pip python3-venv python3-dev \
|
|
||||||
build-essential libssl-dev libffi-dev \
|
|
||||||
sqlite3 nginx supervisor \
|
|
||||||
xorg xinit openbox \
|
|
||||||
xserver-xorg-video-all \
|
|
||||||
x11-xserver-utils xdotool unclutter \
|
|
||||||
lightdm lightdm-gtk-greeter \
|
|
||||||
pulseaudio alsa-utils \
|
|
||||||
fonts-liberation fonts-dejavu \
|
|
||||||
systemd-timesyncd ufw fail2ban \
|
|
||||||
|| error "Basis-Pakete Installation fehlgeschlagen"
|
|
||||||
|
|
||||||
log "✅ System-Pakete installiert"
|
progress "Erstelle Zielverzeichnis /opt/myp..."
|
||||||
}
|
mkdir -p "$APP_DIR" || error "Konnte Zielverzeichnis nicht erstellen"
|
||||||
|
|
||||||
# ========================== CHROMIUM INSTALLATION ==========================
|
progress "Kopiere Projektdateien selektiv nach $APP_DIR..."
|
||||||
install_chromium() {
|
|
||||||
log "=== CHROMIUM INSTALLATION ==="
|
|
||||||
|
|
||||||
progress "Installiere Chromium Browser..."
|
# Liste der zu kopierenden Dateien/Ordner (ohne unnötige Inhalte)
|
||||||
|
declare -a COPY_ITEMS=(
|
||||||
|
"app.py"
|
||||||
|
"models.py"
|
||||||
|
"requirements.txt"
|
||||||
|
"blueprints/"
|
||||||
|
"config/"
|
||||||
|
"database/"
|
||||||
|
"docs/"
|
||||||
|
"static/"
|
||||||
|
"templates/"
|
||||||
|
"uploads/"
|
||||||
|
"utils/"
|
||||||
|
"logs/"
|
||||||
|
"certs/"
|
||||||
|
)
|
||||||
|
|
||||||
if apt-get install -y chromium 2>/dev/null; then
|
# Sichere selektive Kopie
|
||||||
CHROMIUM_BIN="/usr/bin/chromium"
|
for item in "${COPY_ITEMS[@]}"; do
|
||||||
log "✅ Chromium via APT installiert"
|
if [ -e "$CURRENT_DIR/$item" ]; then
|
||||||
elif apt-get install -y chromium-browser 2>/dev/null; then
|
progress "Kopiere: $item"
|
||||||
CHROMIUM_BIN="/usr/bin/chromium-browser"
|
cp -r "$CURRENT_DIR/$item" "$APP_DIR/" || warning "Fehler beim Kopieren von $item"
|
||||||
log "✅ Chromium-Browser via APT installiert"
|
|
||||||
else
|
else
|
||||||
error "❌ Chromium konnte nicht installiert werden!"
|
info "Überspringe nicht vorhandenes Element: $item"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
log "✅ Chromium-Installation abgeschlossen: $CHROMIUM_BIN"
|
# Spezielle Dateien einzeln kopieren (falls vorhanden)
|
||||||
}
|
for file in "package.json" "package-lock.json" "tailwind.config.js" "postcss.config.js"; do
|
||||||
|
if [ -f "$CURRENT_DIR/$file" ]; then
|
||||||
# ========================== BENUTZER ERSTELLEN ==========================
|
cp "$CURRENT_DIR/$file" "$APP_DIR/" || warning "Fehler beim Kopieren von $file"
|
||||||
create_users() {
|
|
||||||
log "=== BENUTZER-ERSTELLUNG ==="
|
|
||||||
|
|
||||||
# App-Benutzer erstellen
|
|
||||||
progress "Erstelle App-Benutzer: $APP_USER"
|
|
||||||
if ! id "$APP_USER" &>/dev/null; then
|
|
||||||
if ! useradd -m -s /bin/bash "$APP_USER" 2>/dev/null; then
|
|
||||||
adduser --disabled-password --gecos "" "$APP_USER" || error "Kann App-Benutzer nicht erstellen"
|
|
||||||
fi
|
|
||||||
usermod -aG sudo "$APP_USER" 2>/dev/null || true
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# Kiosk-Benutzer erstellen
|
# Stelle sicher, dass app.py ausführbar ist
|
||||||
progress "Erstelle Kiosk-Benutzer: $KIOSK_USER"
|
chmod +x "$APP_DIR/app.py" || error "Konnte app.py nicht ausführbar machen"
|
||||||
if ! id "$KIOSK_USER" &>/dev/null; then
|
|
||||||
if ! useradd -m -s /bin/bash "$KIOSK_USER" 2>/dev/null; then
|
|
||||||
adduser --disabled-password --gecos "" "$KIOSK_USER" || error "Kann Kiosk-Benutzer nicht erstellen"
|
|
||||||
fi
|
|
||||||
usermod -aG audio,video,input "$KIOSK_USER" 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "✅ Benutzer erstellt: $APP_USER, $KIOSK_USER"
|
# Erstelle notwendige Verzeichnisse falls sie nicht existieren
|
||||||
}
|
mkdir -p "$APP_DIR/database/backups"
|
||||||
|
mkdir -p "$APP_DIR/logs/app"
|
||||||
|
mkdir -p "$APP_DIR/logs/auth"
|
||||||
|
mkdir -p "$APP_DIR/logs/errors"
|
||||||
|
mkdir -p "$APP_DIR/uploads/temp"
|
||||||
|
|
||||||
# ========================== ANWENDUNG INSTALLIEREN ==========================
|
# Berechtigungen setzen
|
||||||
install_application() {
|
chown -R root:root "$APP_DIR"
|
||||||
log "=== ANWENDUNGS-INSTALLATION ==="
|
chmod -R 755 "$APP_DIR"
|
||||||
|
chmod 750 "$APP_DIR/database"
|
||||||
|
chmod 750 "$APP_DIR/logs"
|
||||||
|
chmod 755 "$APP_DIR/uploads"
|
||||||
|
|
||||||
# Verzeichnisse erstellen
|
progress "Erstelle Systemd-Service myp-kiosk.service..."
|
||||||
mkdir -p "$APP_DIR"
|
cat > "/etc/systemd/system/${SERVICE_NAME}.service" << EOF
|
||||||
|
|
||||||
# Anwendung kopieren falls vorhanden
|
|
||||||
if [ -f "$CURRENT_DIR/app.py" ]; then
|
|
||||||
progress "Kopiere Anwendung von $CURRENT_DIR nach $APP_DIR"
|
|
||||||
rsync -av --exclude='.git' --exclude='__pycache__' --exclude='node_modules' "$CURRENT_DIR"/ "$APP_DIR/"
|
|
||||||
else
|
|
||||||
# Erstelle einfache Flask-App als Platzhalter
|
|
||||||
progress "Erstelle einfache Flask-App als Platzhalter..."
|
|
||||||
cat > "$APP_DIR/app.py" << 'EOF'
|
|
||||||
#!/usr/bin/python3
|
|
||||||
from flask import Flask, render_template_string
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
|
||||||
|
|
||||||
@app.route('/')
|
|
||||||
def home():
|
|
||||||
return render_template_string("""
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>MYP Druckerverwaltung</title>
|
|
||||||
<style>
|
|
||||||
body { font-family: Arial, sans-serif; margin: 0; padding: 0; background: #f5f5f5; }
|
|
||||||
.container { max-width: 800px; margin: 0 auto; padding: 20px; }
|
|
||||||
h1 { color: #333; }
|
|
||||||
.box { background: white; border-radius: 5px; padding: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<h1>MYP Druckerverwaltung</h1>
|
|
||||||
<div class="box">
|
|
||||||
<h2>System erfolgreich gestartet</h2>
|
|
||||||
<p>Die MYP Druckerverwaltung läuft im Kiosk-Modus.</p>
|
|
||||||
<p>Sie können diese Anwendung nun durch Ihre eigentliche Anwendung ersetzen.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
""")
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
app.run(host='0.0.0.0', port=5000)
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
chmod +x "$APP_DIR/app.py"
|
|
||||||
chown -R "$APP_USER:$APP_USER" "$APP_DIR"
|
|
||||||
|
|
||||||
# Python-Dependencies installieren
|
|
||||||
progress "Installiere Python-Dependencies..."
|
|
||||||
python3 -m pip install --upgrade pip --break-system-packages
|
|
||||||
python3 -m pip install flask --break-system-packages
|
|
||||||
|
|
||||||
log "✅ Anwendung installiert"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ========================== SYSTEMD-SERVICES ERSTELLEN ==========================
|
|
||||||
create_systemd_services() {
|
|
||||||
log "=== SYSTEMD-SERVICES ERSTELLEN ==="
|
|
||||||
|
|
||||||
# MYP-Anwendung Service
|
|
||||||
progress "Erstelle myp-druckerverwaltung.service..."
|
|
||||||
cat > "/etc/systemd/system/myp-druckerverwaltung.service" << EOF
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=MYP Druckerverwaltung Flask Application
|
Description=MYP Druckerverwaltung Kiosk-Modus
|
||||||
After=network.target
|
After=network.target network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
Requires=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=$APP_USER
|
User=root
|
||||||
Group=$APP_USER
|
Group=root
|
||||||
WorkingDirectory=$APP_DIR
|
WorkingDirectory=$APP_DIR
|
||||||
Environment=PATH=/usr/local/bin:/usr/bin:/bin
|
ExecStart=/usr/bin/python3 $APP_DIR/app.py --debug
|
||||||
Environment=PYTHONPATH=$APP_DIR
|
|
||||||
ExecStart=/usr/bin/python3 $APP_DIR/app.py
|
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=5
|
||||||
|
StartLimitBurst=5
|
||||||
|
StartLimitInterval=60
|
||||||
|
|
||||||
|
# Umgebungsvariablen
|
||||||
|
Environment=PYTHONUNBUFFERED=1
|
||||||
|
Environment=FLASK_ENV=production
|
||||||
|
Environment=FLASK_HOST=0.0.0.0
|
||||||
|
Environment=FLASK_PORT=5000
|
||||||
|
Environment=PYTHONPATH=$APP_DIR
|
||||||
|
Environment=LC_ALL=C.UTF-8
|
||||||
|
Environment=LANG=C.UTF-8
|
||||||
|
|
||||||
|
# Logging
|
||||||
StandardOutput=journal
|
StandardOutput=journal
|
||||||
StandardError=journal
|
StandardError=journal
|
||||||
|
SyslogIdentifier=myp-kiosk
|
||||||
|
|
||||||
|
# Security-Einstellungen
|
||||||
|
NoNewPrivileges=true
|
||||||
|
PrivateTmp=false
|
||||||
|
ProtectSystem=strict
|
||||||
|
ReadWritePaths=$APP_DIR
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Kiosk-Service für automatischen Chromium-Start
|
progress "Lade Systemd-Konfiguration neu..."
|
||||||
progress "Erstelle kiosk-chromium.service..."
|
systemctl daemon-reload || error "Systemd Reload fehlgeschlagen"
|
||||||
cat > "/etc/systemd/system/kiosk-chromium.service" << EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Kiosk Chromium Browser
|
|
||||||
After=graphical-session.target myp-druckerverwaltung.service
|
|
||||||
Wants=myp-druckerverwaltung.service
|
|
||||||
Requires=graphical-session.target
|
|
||||||
|
|
||||||
[Service]
|
progress "Aktiviere und starte $SERVICE_NAME Service..."
|
||||||
Type=simple
|
systemctl enable "$SERVICE_NAME.service" || error "Service Enable fehlgeschlagen"
|
||||||
User=$KIOSK_USER
|
systemctl start "$SERVICE_NAME.service" || error "Service Start fehlgeschlagen"
|
||||||
Group=$KIOSK_USER
|
|
||||||
Environment=DISPLAY=:0
|
|
||||||
Environment=XAUTHORITY=/home/$KIOSK_USER/.Xauthority
|
|
||||||
ExecStartPre=/bin/bash -c 'while ! curl -s http://localhost:5000 >/dev/null 2>&1; do sleep 2; done'
|
|
||||||
ExecStartPre=/bin/sleep 5
|
|
||||||
ExecStart=/home/$KIOSK_USER/start-kiosk.sh
|
|
||||||
Restart=always
|
|
||||||
RestartSec=10
|
|
||||||
|
|
||||||
[Install]
|
# Service-Status prüfen
|
||||||
WantedBy=graphical-session.target
|
sleep 5
|
||||||
EOF
|
if systemctl is-active --quiet "$SERVICE_NAME.service"; then
|
||||||
|
log "✅ $SERVICE_NAME Service läuft erfolgreich"
|
||||||
|
info "Service-Status: $(systemctl is-active $SERVICE_NAME.service)"
|
||||||
|
info "Port 5000: Flask-App läuft im Debug-Modus"
|
||||||
|
info "Projektverzeichnis: $APP_DIR"
|
||||||
|
|
||||||
# Systemd-Services aktivieren
|
# Test der Anwendung
|
||||||
systemctl daemon-reload
|
progress "Teste Anwendungserreichbarkeit..."
|
||||||
systemctl enable myp-druckerverwaltung.service
|
|
||||||
systemctl enable kiosk-chromium.service
|
|
||||||
|
|
||||||
log "✅ Systemd-Services erstellt und aktiviert"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ========================== AUTOLOGIN KONFIGURIEREN ==========================
|
|
||||||
configure_autologin() {
|
|
||||||
log "=== AUTOLOGIN KONFIGURIEREN ==="
|
|
||||||
|
|
||||||
progress "Konfiguriere LightDM für automatischen Login..."
|
|
||||||
|
|
||||||
# LightDM Konfiguration
|
|
||||||
cat > "/etc/lightdm/lightdm.conf" << EOF
|
|
||||||
[Seat:*]
|
|
||||||
autologin-user=$KIOSK_USER
|
|
||||||
autologin-user-timeout=0
|
|
||||||
autologin-session=openbox
|
|
||||||
user-session=openbox
|
|
||||||
session-wrapper=/etc/X11/Xsession
|
|
||||||
greeter-session=lightdm-gtk-greeter
|
|
||||||
allow-guest=false
|
|
||||||
greeter-hide-users=true
|
|
||||||
greeter-show-manual-login=false
|
|
||||||
autologin-in-background=false
|
|
||||||
xserver-command=X -s 0 -dpms
|
|
||||||
|
|
||||||
[SeatDefaults]
|
|
||||||
autologin-user=$KIOSK_USER
|
|
||||||
autologin-user-timeout=0
|
|
||||||
autologin-session=openbox
|
|
||||||
greeter-hide-users=true
|
|
||||||
greeter-show-manual-login=false
|
|
||||||
allow-user-switching=false
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Graphical Target als Standard setzen
|
|
||||||
systemctl set-default graphical.target
|
|
||||||
systemctl enable lightdm.service
|
|
||||||
|
|
||||||
log "✅ Autologin konfiguriert"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ========================== KIOSK-KONFIGURATION ==========================
|
|
||||||
configure_kiosk() {
|
|
||||||
log "=== KIOSK-KONFIGURATION ==="
|
|
||||||
|
|
||||||
KIOSK_HOME="/home/$KIOSK_USER"
|
|
||||||
|
|
||||||
# Openbox-Konfiguration
|
|
||||||
progress "Konfiguriere Openbox für Kiosk..."
|
|
||||||
sudo -u "$KIOSK_USER" mkdir -p "$KIOSK_HOME/.config/openbox"
|
|
||||||
|
|
||||||
cat > "$KIOSK_HOME/.config/openbox/rc.xml" << 'EOF'
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<openbox_config xmlns="http://openbox.org/3.4/rc">
|
|
||||||
<applications>
|
|
||||||
<application name="chromium*">
|
|
||||||
<decor>no</decor>
|
|
||||||
<fullscreen>yes</fullscreen>
|
|
||||||
<maximized>yes</maximized>
|
|
||||||
<skip_pager>yes</skip_pager>
|
|
||||||
<skip_taskbar>yes</skip_taskbar>
|
|
||||||
</application>
|
|
||||||
</applications>
|
|
||||||
<keyboard>
|
|
||||||
<!-- Alle Shortcuts deaktiviert für Kiosk-Sicherheit -->
|
|
||||||
</keyboard>
|
|
||||||
</openbox_config>
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Kiosk-Starter-Skript
|
|
||||||
progress "Erstelle Kiosk-Starter-Skript..."
|
|
||||||
cat > "$KIOSK_HOME/start-kiosk.sh" << EOF
|
|
||||||
#!/bin/bash
|
|
||||||
export DISPLAY=:0
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
exec > >(tee -a /var/log/kiosk-session.log) 2>&1
|
|
||||||
echo "\$(date): Kiosk-Session gestartet"
|
|
||||||
|
|
||||||
# Bildschirmschoner deaktivieren
|
|
||||||
xset s off
|
|
||||||
xset s noblank
|
|
||||||
xset s noexpose
|
|
||||||
xset -dpms
|
|
||||||
|
|
||||||
# Mauszeiger verstecken
|
|
||||||
unclutter -idle 0.5 -root &
|
|
||||||
|
|
||||||
# Warte auf Anwendung
|
|
||||||
echo "Warte auf MYP-Anwendung..."
|
|
||||||
WAIT_COUNT=0
|
|
||||||
while ! curl -s http://localhost:5000 > /dev/null; do
|
|
||||||
echo "Warte auf MYP-Anwendung... (\$WAIT_COUNT/30)"
|
|
||||||
sleep 2
|
|
||||||
WAIT_COUNT=\$((WAIT_COUNT + 1))
|
|
||||||
if [ \$WAIT_COUNT -gt 30 ]; then
|
|
||||||
echo "FEHLER: MYP-Anwendung nach 60s nicht erreichbar!"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Prüfe verfügbare Ports
|
|
||||||
if curl -s http://localhost:8080 > /dev/null; then
|
|
||||||
KIOSK_URL="http://localhost:8080"
|
|
||||||
elif curl -s http://localhost:5000 > /dev/null; then
|
|
||||||
KIOSK_URL="http://localhost:5000"
|
|
||||||
else
|
|
||||||
KIOSK_URL="http://localhost:5000"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Starte Chromium im Kiosk-Modus mit URL: \$KIOSK_URL"
|
|
||||||
|
|
||||||
# Chromium-Flags für Kiosk-Modus
|
|
||||||
CHROMIUM_FLAGS="
|
|
||||||
--kiosk
|
|
||||||
--no-sandbox
|
|
||||||
--disable-infobars
|
|
||||||
--disable-session-crashed-bubble
|
|
||||||
--disable-restore-session-state
|
|
||||||
--disable-web-security
|
|
||||||
--disable-features=TranslateUI
|
|
||||||
--disable-extensions
|
|
||||||
--disable-plugins
|
|
||||||
--disable-popup-blocking
|
|
||||||
--disable-prompt-on-repost
|
|
||||||
--disable-sync
|
|
||||||
--disable-translate
|
|
||||||
--noerrdialogs
|
|
||||||
--no-first-run
|
|
||||||
--no-default-browser-check
|
|
||||||
--autoplay-policy=no-user-gesture-required
|
|
||||||
--start-fullscreen
|
|
||||||
--window-position=0,0
|
|
||||||
--user-data-dir=$KIOSK_HOME/.chromium-kiosk
|
|
||||||
--disable-background-mode
|
|
||||||
--force-device-scale-factor=1.0
|
|
||||||
--disable-pinch
|
|
||||||
--overscroll-history-navigation=0
|
|
||||||
"
|
|
||||||
|
|
||||||
# Chromium starten
|
|
||||||
$CHROMIUM_BIN \$CHROMIUM_FLAGS "\$KIOSK_URL"
|
|
||||||
|
|
||||||
echo "\$(date): Kiosk-Session beendet"
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Desktop-Autostart
|
|
||||||
sudo -u "$KIOSK_USER" mkdir -p "$KIOSK_HOME/.config/autostart"
|
|
||||||
cat > "$KIOSK_HOME/.config/autostart/myp-kiosk.desktop" << EOF
|
|
||||||
[Desktop Entry]
|
|
||||||
Type=Application
|
|
||||||
Name=MYP Kiosk Application
|
|
||||||
Exec=/home/$KIOSK_USER/start-kiosk.sh
|
|
||||||
Hidden=false
|
|
||||||
NoDisplay=false
|
|
||||||
X-GNOME-Autostart-enabled=true
|
|
||||||
StartupNotify=false
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Berechtigungen setzen
|
|
||||||
chmod +x "$KIOSK_HOME/start-kiosk.sh"
|
|
||||||
chown -R "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/.config"
|
|
||||||
chown "$KIOSK_USER:$KIOSK_USER" "$KIOSK_HOME/start-kiosk.sh"
|
|
||||||
|
|
||||||
log "✅ Kiosk-Konfiguration erstellt"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ========================== RASPBERRY PI OPTIMIERUNGEN ==========================
|
|
||||||
optimize_raspberry_pi() {
|
|
||||||
log "=== RASPBERRY PI OPTIMIERUNGEN ==="
|
|
||||||
|
|
||||||
# Prüfe ob es sich um einen Raspberry Pi handelt
|
|
||||||
if ! grep -q "Raspberry Pi" /proc/cpuinfo 2>/dev/null; then
|
|
||||||
info "Kein Raspberry Pi erkannt - überspringe Pi-spezifische Optimierungen"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
progress "Raspberry Pi erkannt - aktiviere Hardware-Optimierungen..."
|
|
||||||
|
|
||||||
# Boot-Konfiguration optimieren
|
|
||||||
if [ -f "/boot/config.txt" ]; then
|
|
||||||
cp /boot/config.txt /boot/config.txt.backup
|
|
||||||
|
|
||||||
# GPU Memory für bessere Browser-Performance
|
|
||||||
if ! grep -q "gpu_mem=" /boot/config.txt; then
|
|
||||||
echo "" >> /boot/config.txt
|
|
||||||
echo "# MYP Kiosk Optimierungen" >> /boot/config.txt
|
|
||||||
echo "gpu_mem=128" >> /boot/config.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Disable Splash
|
|
||||||
if ! grep -q "disable_splash=1" /boot/config.txt; then
|
|
||||||
echo "disable_splash=1" >> /boot/config.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
# HDMI Force Hotplug
|
|
||||||
if ! grep -q "hdmi_force_hotplug=1" /boot/config.txt; then
|
|
||||||
echo "hdmi_force_hotplug=1" >> /boot/config.txt
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Disable Overscan
|
|
||||||
if ! grep -q "disable_overscan=1" /boot/config.txt; then
|
|
||||||
echo "disable_overscan=1" >> /boot/config.txt
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Console Blanking deaktivieren
|
|
||||||
if [ -f "/boot/cmdline.txt" ]; then
|
|
||||||
cp /boot/cmdline.txt /boot/cmdline.txt.backup
|
|
||||||
if ! grep -q "consoleblank=0" /boot/cmdline.txt; then
|
|
||||||
sed -i 's/$/ consoleblank=0/' /boot/cmdline.txt
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
log "✅ Raspberry Pi Optimierungen abgeschlossen"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ========================== WARTUNGSTOOLS ERSTELLEN ==========================
|
|
||||||
create_maintenance_tools() {
|
|
||||||
log "=== WARTUNGSTOOLS ERSTELLEN ==="
|
|
||||||
|
|
||||||
# Wartungsskript
|
|
||||||
cat > "/usr/local/bin/myp-maintenance" << 'EOF'
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
echo "Starte alle MYP-Services..."
|
|
||||||
systemctl start myp-druckerverwaltung
|
|
||||||
systemctl start lightdm
|
|
||||||
echo "Services gestartet."
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
echo "Stoppe alle MYP-Services..."
|
|
||||||
systemctl stop lightdm
|
|
||||||
systemctl stop myp-druckerverwaltung
|
|
||||||
echo "Services gestoppt."
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
echo "Starte alle MYP-Services neu..."
|
|
||||||
systemctl restart myp-druckerverwaltung
|
|
||||||
sleep 3
|
sleep 3
|
||||||
systemctl restart lightdm
|
if curl -s http://localhost:5000 > /dev/null 2>&1; then
|
||||||
echo "Services neugestartet."
|
log "✅ Anwendung ist unter http://localhost:5000 erreichbar"
|
||||||
;;
|
|
||||||
status)
|
|
||||||
echo "=== MYP SYSTEM STATUS ==="
|
|
||||||
echo "📱 Anwendung:"
|
|
||||||
systemctl status myp-druckerverwaltung --no-pager -l
|
|
||||||
echo "🖥️ Display Manager:"
|
|
||||||
systemctl status lightdm --no-pager -l
|
|
||||||
echo "🌐 Anwendung erreichbar:"
|
|
||||||
if curl -s http://localhost:5000 > /dev/null; then
|
|
||||||
echo "✅ http://localhost:5000 erreichbar"
|
|
||||||
else
|
else
|
||||||
echo "❌ http://localhost:5000 NICHT erreichbar"
|
warning "⚠️ Anwendung noch nicht erreichbar (möglicherweise noch beim Starten)"
|
||||||
fi
|
fi
|
||||||
if curl -s http://localhost:8080 > /dev/null; then
|
|
||||||
echo "✅ http://localhost:8080 erreichbar"
|
|
||||||
else
|
else
|
||||||
echo "❌ http://localhost:8080 NICHT erreichbar"
|
error "$SERVICE_NAME Service konnte nicht gestartet werden - prüfen Sie die Logs: journalctl -u $SERVICE_NAME -f"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log "✅ Produktions-Kiosk-Modus erfolgreich eingerichtet"
|
||||||
|
log "🎯 Anwendung erreichbar unter: http://localhost:5000"
|
||||||
|
log "📋 Service-Befehle:"
|
||||||
|
log " • Status: sudo systemctl status $SERVICE_NAME"
|
||||||
|
log " • Stoppen: sudo systemctl stop $SERVICE_NAME"
|
||||||
|
log " • Starten: sudo systemctl start $SERVICE_NAME"
|
||||||
|
log " • Neustarten: sudo systemctl restart $SERVICE_NAME"
|
||||||
|
log " • Logs: sudo journalctl -u $SERVICE_NAME -f"
|
||||||
|
log " • Service-Info: sudo journalctl -u $SERVICE_NAME --no-pager"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ========================== HAUPTMENÜ ==========================
|
||||||
|
show_menu() {
|
||||||
|
clear
|
||||||
|
echo -e "${BLUE}=================================================================${NC}"
|
||||||
|
echo -e "${GREEN} $APP_NAME - Installer für Raspbian${NC}"
|
||||||
|
echo -e "${BLUE}=================================================================${NC}"
|
||||||
|
echo ""
|
||||||
|
echo -e "${YELLOW}Aktuelles Verzeichnis:${NC} $CURRENT_DIR"
|
||||||
|
echo -e "${YELLOW}Systemzeit:${NC} $(date)"
|
||||||
|
echo -e "${YELLOW}Zielverzeichnis:${NC} $APP_DIR"
|
||||||
|
echo ""
|
||||||
|
echo -e "${PURPLE}Wählen Sie eine Option:${NC}"
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}1)${NC} System vorbereiten (Abhängigkeiten installieren)"
|
||||||
|
echo -e " → Installiert Python 3, pip und alle benötigten Pakete"
|
||||||
|
echo -e " → Verwendet: pip install --break-system-packages"
|
||||||
|
echo -e " → Keine virtualenv, direktes System-Python"
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}2)${NC} Produktions-Kiosk-Modus installieren"
|
||||||
|
echo -e " → Führt System-Vorbereitung durch"
|
||||||
|
echo -e " → Verschiebt Dateien selektiv nach /opt/myp/"
|
||||||
|
echo -e " → Erstellt systemd-Service: myp-kiosk.service"
|
||||||
|
echo -e " → Startet Flask-App mit --debug auf Port 5000"
|
||||||
|
echo -e " → Testet Anwendungserreichbarkeit"
|
||||||
|
echo ""
|
||||||
|
echo -e "${RED}0)${NC} Beenden"
|
||||||
|
echo ""
|
||||||
|
echo -e "${BLUE}=================================================================${NC}"
|
||||||
|
echo -n "Ihre Wahl [0-2]: "
|
||||||
|
}
|
||||||
|
|
||||||
|
# ========================== MAIN LOGIC ==========================
|
||||||
|
main() {
|
||||||
|
# System-Checks
|
||||||
|
check_root
|
||||||
|
check_debian_system
|
||||||
|
|
||||||
|
# Erstelle Log-Datei
|
||||||
|
mkdir -p "$(dirname "$INSTALL_LOG")"
|
||||||
|
touch "$INSTALL_LOG"
|
||||||
|
|
||||||
|
log "=== MYP INSTALLER GESTARTET ==="
|
||||||
|
log "Arbeitsverzeichnis: $CURRENT_DIR"
|
||||||
|
log "Zielverzeichnis: $APP_DIR"
|
||||||
|
log "Service-Name: $SERVICE_NAME"
|
||||||
|
log "System: $(uname -a)"
|
||||||
|
log "Debian-Version: $(cat /etc/debian_version 2>/dev/null || echo 'Unbekannt')"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
show_menu
|
||||||
|
read -r choice
|
||||||
|
|
||||||
|
case $choice in
|
||||||
|
1)
|
||||||
|
clear
|
||||||
|
log "=== OPTION 1: SYSTEM VORBEREITEN ==="
|
||||||
|
install_system_dependencies
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}✅ System-Vorbereitung abgeschlossen!${NC}"
|
||||||
|
echo -e "${YELLOW}Drücken Sie Enter, um fortzufahren...${NC}"
|
||||||
|
read -r
|
||||||
;;
|
;;
|
||||||
logs)
|
2)
|
||||||
echo "=== ANWENDUNGS-LOGS ==="
|
clear
|
||||||
journalctl -u myp-druckerverwaltung -f
|
log "=== OPTION 2: PRODUKTIONS-KIOSK-MODUS ==="
|
||||||
|
setup_production_kiosk
|
||||||
|
echo ""
|
||||||
|
echo -e "${GREEN}✅ Produktions-Kiosk-Modus erfolgreich eingerichtet!${NC}"
|
||||||
|
echo -e "${BLUE}ℹ️ Die Anwendung startet automatisch bei jedem Systemstart.${NC}"
|
||||||
|
echo -e "${YELLOW}Drücken Sie Enter, um fortzufahren...${NC}"
|
||||||
|
read -r
|
||||||
|
;;
|
||||||
|
0)
|
||||||
|
log "=== INSTALLER BEENDET ==="
|
||||||
|
echo -e "${GREEN}Auf Wiedersehen!${NC}"
|
||||||
|
echo -e "${BLUE}Log-Datei: $INSTALL_LOG${NC}"
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "MYP Druckerverwaltung - Wartungstool"
|
echo -e "${RED}Ungültige Eingabe. Bitte wählen Sie 0-2.${NC}"
|
||||||
echo "VERWENDUNG: $0 {start|stop|restart|status|logs}"
|
sleep 2
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
EOF
|
done
|
||||||
|
|
||||||
chmod +x "/usr/local/bin/myp-maintenance"
|
|
||||||
|
|
||||||
# Log-Dateien erstellen
|
|
||||||
touch /var/log/kiosk-session.log
|
|
||||||
chmod 666 /var/log/kiosk-session.log
|
|
||||||
|
|
||||||
log "✅ Wartungstools erstellt"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ========================== HAUPTFUNKTION ==========================
|
# Script starten
|
||||||
main() {
|
|
||||||
log "=== MYP KIOSK-INSTALLATION GESTARTET ==="
|
|
||||||
|
|
||||||
check_root
|
|
||||||
detect_system
|
|
||||||
update_system
|
|
||||||
install_packages
|
|
||||||
install_chromium
|
|
||||||
create_users
|
|
||||||
install_application
|
|
||||||
create_systemd_services
|
|
||||||
configure_autologin
|
|
||||||
configure_kiosk
|
|
||||||
optimize_raspberry_pi
|
|
||||||
create_maintenance_tools
|
|
||||||
|
|
||||||
log "=== INSTALLATION ABGESCHLOSSEN ==="
|
|
||||||
log ""
|
|
||||||
log "🎉 MYP KIOSK-INSTALLATION ERFOLGREICH!"
|
|
||||||
log ""
|
|
||||||
log "📋 ZUSAMMENFASSUNG:"
|
|
||||||
log " ✅ System-Pakete installiert"
|
|
||||||
log " ✅ Chromium Browser installiert"
|
|
||||||
log " ✅ Benutzer erstellt ($APP_USER, $KIOSK_USER)"
|
|
||||||
log " ✅ Anwendung installiert"
|
|
||||||
log " ✅ Systemd-Services erstellt"
|
|
||||||
log " ✅ Autologin konfiguriert"
|
|
||||||
log " ✅ Kiosk-Modus konfiguriert"
|
|
||||||
log " ✅ Raspberry Pi optimiert"
|
|
||||||
log " ✅ Wartungstools erstellt"
|
|
||||||
log ""
|
|
||||||
log "🔄 NEUSTART ERFORDERLICH:"
|
|
||||||
log " sudo reboot"
|
|
||||||
log ""
|
|
||||||
log "📊 NACH DEM NEUSTART:"
|
|
||||||
log " - System startet automatisch ohne Anmeldung"
|
|
||||||
log " - Kiosk-Modus wird automatisch gestartet"
|
|
||||||
log " - Chromium öffnet http://localhost:8080 oder http://localhost:5000"
|
|
||||||
log " - Vollbildmodus ohne UI-Elemente"
|
|
||||||
log " - Mauszeiger wird automatisch versteckt"
|
|
||||||
log ""
|
|
||||||
log "🔧 WARTUNG:"
|
|
||||||
log " sudo myp-maintenance status # System-Status prüfen"
|
|
||||||
log " sudo myp-maintenance logs # Logs anzeigen"
|
|
||||||
log " sudo myp-maintenance restart # Services neustarten"
|
|
||||||
log ""
|
|
||||||
|
|
||||||
warning "WICHTIG: Führen Sie jetzt 'sudo reboot' aus, um die Kiosk-Konfiguration zu aktivieren!"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Skript ausführen
|
|
||||||
main "$@"
|
main "$@"
|
@ -1,293 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# ===================================================================
|
|
||||||
# MYP Kiosk-Setup Test und Validierung
|
|
||||||
# Testet alle Komponenten der Kiosk-Installation
|
|
||||||
# ===================================================================
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Farben für Ausgabe
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
BLUE='\033[0;34m'
|
|
||||||
NC='\033[0m'
|
|
||||||
|
|
||||||
# Test-Funktionen
|
|
||||||
test_passed() {
|
|
||||||
echo -e "${GREEN}✅ $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
test_failed() {
|
|
||||||
echo -e "${RED}❌ $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
test_warning() {
|
|
||||||
echo -e "${YELLOW}⚠️ $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
test_info() {
|
|
||||||
echo -e "${BLUE}ℹ️ $1${NC}"
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "====================================================================="
|
|
||||||
echo "🧪 MYP Kiosk-Setup Validierung"
|
|
||||||
echo "====================================================================="
|
|
||||||
echo
|
|
||||||
|
|
||||||
# ========================== SYSTEM-TESTS ==========================
|
|
||||||
echo "🔍 SYSTEM-TESTS"
|
|
||||||
echo "---------------------------------------------------------------------"
|
|
||||||
|
|
||||||
# Benutzer-Tests
|
|
||||||
if id "kiosk" &>/dev/null; then
|
|
||||||
test_passed "Kiosk-Benutzer existiert"
|
|
||||||
else
|
|
||||||
test_failed "Kiosk-Benutzer fehlt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if id "myp" &>/dev/null; then
|
|
||||||
test_passed "MYP-Benutzer existiert"
|
|
||||||
else
|
|
||||||
test_failed "MYP-Benutzer fehlt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Verzeichnis-Tests
|
|
||||||
if [ -d "/opt/myp-druckerverwaltung" ]; then
|
|
||||||
test_passed "MYP-Anwendungsverzeichnis existiert"
|
|
||||||
else
|
|
||||||
test_failed "MYP-Anwendungsverzeichnis fehlt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "/opt/myp-druckerverwaltung/app.py" ]; then
|
|
||||||
test_passed "Flask-Anwendung gefunden"
|
|
||||||
else
|
|
||||||
test_warning "Flask-Anwendung nicht gefunden (wird erstellt)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ========================== SERVICE-TESTS ==========================
|
|
||||||
echo
|
|
||||||
echo "🔧 SERVICE-TESTS"
|
|
||||||
echo "---------------------------------------------------------------------"
|
|
||||||
|
|
||||||
# Systemd-Services prüfen
|
|
||||||
services=("myp-druckerverwaltung" "lightdm" "kiosk-chromium")
|
|
||||||
|
|
||||||
for service in "${services[@]}"; do
|
|
||||||
if systemctl is-enabled --quiet "$service" 2>/dev/null; then
|
|
||||||
test_passed "Service '$service' ist aktiviert"
|
|
||||||
|
|
||||||
if systemctl is-active --quiet "$service" 2>/dev/null; then
|
|
||||||
test_passed "Service '$service' läuft"
|
|
||||||
else
|
|
||||||
test_warning "Service '$service' läuft nicht (normal vor Reboot)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
test_failed "Service '$service' ist nicht aktiviert"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# ========================== KONFIGURATION-TESTS ==========================
|
|
||||||
echo
|
|
||||||
echo "⚙️ KONFIGURATION-TESTS"
|
|
||||||
echo "---------------------------------------------------------------------"
|
|
||||||
|
|
||||||
# LightDM-Konfiguration
|
|
||||||
if [ -f "/etc/lightdm/lightdm.conf" ]; then
|
|
||||||
if grep -q "autologin-user=kiosk" /etc/lightdm/lightdm.conf; then
|
|
||||||
test_passed "LightDM Autologin konfiguriert"
|
|
||||||
else
|
|
||||||
test_failed "LightDM Autologin nicht konfiguriert"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
test_failed "LightDM-Konfiguration fehlt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Kiosk-Skript
|
|
||||||
if [ -f "/home/kiosk/start-kiosk.sh" ]; then
|
|
||||||
if [ -x "/home/kiosk/start-kiosk.sh" ]; then
|
|
||||||
test_passed "Kiosk-Starter-Skript vorhanden und ausführbar"
|
|
||||||
else
|
|
||||||
test_failed "Kiosk-Starter-Skript nicht ausführbar"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
test_failed "Kiosk-Starter-Skript fehlt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Openbox-Konfiguration
|
|
||||||
if [ -f "/home/kiosk/.config/openbox/rc.xml" ]; then
|
|
||||||
test_passed "Openbox-Konfiguration vorhanden"
|
|
||||||
else
|
|
||||||
test_failed "Openbox-Konfiguration fehlt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Desktop-Autostart
|
|
||||||
if [ -f "/home/kiosk/.config/autostart/myp-kiosk.desktop" ]; then
|
|
||||||
test_passed "Desktop-Autostart konfiguriert"
|
|
||||||
else
|
|
||||||
test_failed "Desktop-Autostart fehlt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ========================== PAKET-TESTS ==========================
|
|
||||||
echo
|
|
||||||
echo "📦 PAKET-TESTS"
|
|
||||||
echo "---------------------------------------------------------------------"
|
|
||||||
|
|
||||||
# Wichtige Pakete prüfen
|
|
||||||
packages=("chromium" "openbox" "lightdm" "python3" "unclutter" "xorg")
|
|
||||||
|
|
||||||
for package in "${packages[@]}"; do
|
|
||||||
if dpkg -l | grep -q "^ii.*$package" 2>/dev/null; then
|
|
||||||
test_passed "Paket '$package' installiert"
|
|
||||||
elif command -v "$package" &>/dev/null; then
|
|
||||||
test_passed "Programm '$package' verfügbar"
|
|
||||||
else
|
|
||||||
test_failed "Paket/Programm '$package' fehlt"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Chromium-Binary finden
|
|
||||||
if command -v chromium &>/dev/null; then
|
|
||||||
test_passed "Chromium-Binary gefunden: $(which chromium)"
|
|
||||||
elif command -v chromium-browser &>/dev/null; then
|
|
||||||
test_passed "Chromium-Browser-Binary gefunden: $(which chromium-browser)"
|
|
||||||
else
|
|
||||||
test_failed "Kein Chromium-Binary gefunden"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ========================== NETZWERK-TESTS ==========================
|
|
||||||
echo
|
|
||||||
echo "🌐 NETZWERK-TESTS"
|
|
||||||
echo "---------------------------------------------------------------------"
|
|
||||||
|
|
||||||
# Internetverbindung
|
|
||||||
if ping -c 1 google.com &>/dev/null; then
|
|
||||||
test_passed "Internetverbindung verfügbar"
|
|
||||||
else
|
|
||||||
test_warning "Keine Internetverbindung (optional)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Lokale Ports testen (falls Services laufen)
|
|
||||||
if systemctl is-active --quiet myp-druckerverwaltung 2>/dev/null; then
|
|
||||||
if curl -s --connect-timeout 5 http://localhost:5000 >/dev/null 2>&1; then
|
|
||||||
test_passed "Port 5000 erreichbar"
|
|
||||||
else
|
|
||||||
test_warning "Port 5000 nicht erreichbar"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if curl -s --connect-timeout 5 http://localhost:8080 >/dev/null 2>&1; then
|
|
||||||
test_passed "Port 8080 erreichbar"
|
|
||||||
else
|
|
||||||
test_info "Port 8080 nicht verfügbar (optional)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
test_info "Backend-Service nicht aktiv - Port-Tests übersprungen"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ========================== RASPBERRY PI TESTS ==========================
|
|
||||||
echo
|
|
||||||
echo "🍓 RASPBERRY PI TESTS"
|
|
||||||
echo "---------------------------------------------------------------------"
|
|
||||||
|
|
||||||
if grep -q "Raspberry Pi" /proc/cpuinfo 2>/dev/null; then
|
|
||||||
test_passed "Raspberry Pi erkannt"
|
|
||||||
|
|
||||||
# Boot-Konfiguration prüfen
|
|
||||||
if [ -f "/boot/config.txt" ]; then
|
|
||||||
if grep -q "gpu_mem=" /boot/config.txt; then
|
|
||||||
GPU_MEM=$(grep "gpu_mem=" /boot/config.txt | cut -d= -f2)
|
|
||||||
test_passed "GPU Memory Split konfiguriert: ${GPU_MEM}MB"
|
|
||||||
else
|
|
||||||
test_warning "GPU Memory Split nicht konfiguriert"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -q "disable_splash=1" /boot/config.txt; then
|
|
||||||
test_passed "Boot-Splash deaktiviert"
|
|
||||||
else
|
|
||||||
test_warning "Boot-Splash nicht deaktiviert"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
test_warning "/boot/config.txt nicht gefunden"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Temperatur prüfen
|
|
||||||
if command -v vcgencmd &>/dev/null; then
|
|
||||||
TEMP=$(vcgencmd measure_temp 2>/dev/null | cut -d= -f2 | cut -d"'" -f1)
|
|
||||||
if [ -n "$TEMP" ]; then
|
|
||||||
test_passed "CPU Temperatur: ${TEMP}°C"
|
|
||||||
if (( $(echo "$TEMP > 70" | bc -l 2>/dev/null || echo 0) )); then
|
|
||||||
test_warning "Hohe CPU Temperatur: ${TEMP}°C"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
test_info "Kein Raspberry Pi - Pi-spezifische Tests übersprungen"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ========================== WARTUNGSTOOLS-TESTS ==========================
|
|
||||||
echo
|
|
||||||
echo "🔧 WARTUNGSTOOLS-TESTS"
|
|
||||||
echo "---------------------------------------------------------------------"
|
|
||||||
|
|
||||||
if [ -f "/usr/local/bin/myp-maintenance" ]; then
|
|
||||||
if [ -x "/usr/local/bin/myp-maintenance" ]; then
|
|
||||||
test_passed "Wartungstool verfügbar"
|
|
||||||
else
|
|
||||||
test_failed "Wartungstool nicht ausführbar"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
test_failed "Wartungstool fehlt"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Log-Verzeichnisse
|
|
||||||
if [ -f "/var/log/kiosk-session.log" ]; then
|
|
||||||
test_passed "Kiosk-Session-Log verfügbar"
|
|
||||||
else
|
|
||||||
test_warning "Kiosk-Session-Log nicht vorhanden"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ========================== ZUSAMMENFASSUNG ==========================
|
|
||||||
echo
|
|
||||||
echo "====================================================================="
|
|
||||||
echo "📊 TEST-ZUSAMMENFASSUNG"
|
|
||||||
echo "====================================================================="
|
|
||||||
|
|
||||||
# Zähle Tests
|
|
||||||
TOTAL_TESTS=$(grep -E "(test_passed|test_failed|test_warning)" "$0" | wc -l)
|
|
||||||
echo "Gesamte Tests durchgeführt: $TOTAL_TESTS"
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "🎯 NÄCHSTE SCHRITTE:"
|
|
||||||
echo "---------------------------------------------------------------------"
|
|
||||||
|
|
||||||
if systemctl is-active --quiet lightdm 2>/dev/null; then
|
|
||||||
echo "✅ System ist bereits im Kiosk-Modus"
|
|
||||||
echo " - Kiosk läuft bereits"
|
|
||||||
echo " - Verwenden Sie 'sudo myp-maintenance status' für Details"
|
|
||||||
else
|
|
||||||
echo "🔄 System-Neustart erforderlich:"
|
|
||||||
echo " sudo reboot"
|
|
||||||
echo
|
|
||||||
echo "📋 Nach dem Neustart:"
|
|
||||||
echo " - System startet automatisch ohne Login"
|
|
||||||
echo " - Chromium öffnet im Kiosk-Modus"
|
|
||||||
echo " - Anwendung ist unter http://localhost:5000 oder :8080 verfügbar"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "🔧 WARTUNG:"
|
|
||||||
echo " sudo myp-maintenance status # System-Status"
|
|
||||||
echo " sudo myp-maintenance logs # Live-Logs"
|
|
||||||
echo " sudo myp-maintenance restart # Services neustarten"
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "📋 LOG-DATEIEN:"
|
|
||||||
echo " tail -f /var/log/kiosk-session.log"
|
|
||||||
echo " journalctl -u myp-druckerverwaltung -f"
|
|
||||||
echo " journalctl -u lightdm -f"
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "====================================================================="
|
|
||||||
echo "🏁 Test abgeschlossen"
|
|
||||||
echo "====================================================================="
|
|
Loading…
x
Reference in New Issue
Block a user