Remove deprecated backend files and documentation, including Docker configurations, environment variables, and various scripts, to streamline the project structure and eliminate unused components.
This commit is contained in:
806
backend/setup_myp.sh
Executable file
806
backend/setup_myp.sh
Executable file
@@ -0,0 +1,806 @@
|
||||
#!/usr/bin/env bash
|
||||
# MYP V2 - Command Center
|
||||
# Ein umfassendes Verwaltungsskript für MYP V2 (Manage Your Printer)
|
||||
|
||||
# Fehlerabbruch aktivieren
|
||||
set -e
|
||||
|
||||
# Farben für bessere Lesbarkeit
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Funktion für Titel
|
||||
print_header() {
|
||||
clear
|
||||
echo -e "${BLUE}================================================================${NC}"
|
||||
echo -e "${BLUE} MYP V2 - Manage Your Printer ${NC}"
|
||||
echo -e "${BLUE} Command Center ${NC}"
|
||||
echo -e "${BLUE}================================================================${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Funktion zum Überprüfen, ob der Benutzer Root-Rechte hat
|
||||
check_root() {
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo -e "${RED}Dieses Skript muss mit Root-Rechten ausgeführt werden.${NC}"
|
||||
echo -e "${YELLOW}Bitte mit 'sudo ./setup_myp.sh' neu starten.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Funktion zum Überprüfen, ob MYP installiert ist
|
||||
is_myp_installed() {
|
||||
if [ -d "/opt/myp" ]; then
|
||||
return 0 # true
|
||||
else
|
||||
return 1 # false
|
||||
fi
|
||||
}
|
||||
|
||||
# Hauptmenü
|
||||
show_main_menu() {
|
||||
print_header
|
||||
echo -e "${GREEN}Willkommen zum MYP V2 Command Center${NC}"
|
||||
echo ""
|
||||
echo -e "Bitte wählen Sie eine Option:"
|
||||
echo ""
|
||||
echo -e "${YELLOW}INSTALLATION & KONFIGURATION${NC}"
|
||||
echo "1) MYP V2 Standardinstallation"
|
||||
echo "2) MYP V2 Kiosk-Modus Installation"
|
||||
echo "3) MYP V2 deinstallieren"
|
||||
echo ""
|
||||
echo -e "${YELLOW}NETZWERK & SYSTEM${NC}"
|
||||
echo "4) Netzwerkeinstellungen konfigurieren"
|
||||
echo "5) DNS-Server konfigurieren"
|
||||
echo "6) System-Status anzeigen"
|
||||
echo ""
|
||||
echo -e "${YELLOW}WARTUNG & HILFE${NC}"
|
||||
echo "7) MYP-Dienst starten/stoppen/neustarten"
|
||||
echo "8) Logs anzeigen"
|
||||
echo "9) Dokumentation anzeigen"
|
||||
echo ""
|
||||
echo "q) Beenden"
|
||||
echo ""
|
||||
read -p "Ihre Auswahl: " main_option
|
||||
process_main_menu "$main_option"
|
||||
}
|
||||
|
||||
# Verarbeiten der Hauptmenü-Auswahl
|
||||
process_main_menu() {
|
||||
case $1 in
|
||||
1)
|
||||
standard_installation
|
||||
;;
|
||||
2)
|
||||
kiosk_installation
|
||||
;;
|
||||
3)
|
||||
uninstall_myp
|
||||
;;
|
||||
4)
|
||||
network_configuration
|
||||
;;
|
||||
5)
|
||||
dns_configuration
|
||||
;;
|
||||
6)
|
||||
system_status
|
||||
;;
|
||||
7)
|
||||
service_management
|
||||
;;
|
||||
8)
|
||||
show_logs
|
||||
;;
|
||||
9)
|
||||
show_documentation
|
||||
;;
|
||||
q|Q)
|
||||
echo -e "${GREEN}Auf Wiedersehen!${NC}"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Ungültige Option.${NC}"
|
||||
sleep 2
|
||||
show_main_menu
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# 1) MYP V2 Standardinstallation
|
||||
standard_installation() {
|
||||
print_header
|
||||
echo -e "${GREEN}MYP V2 Standardinstallation${NC}"
|
||||
echo ""
|
||||
|
||||
if is_myp_installed; then
|
||||
echo -e "${YELLOW}MYP ist bereits installiert!${NC}"
|
||||
read -p "Möchten Sie die Installation aktualisieren? (j/n): " update_option
|
||||
if [[ "$update_option" != "j" && "$update_option" != "J" ]]; then
|
||||
show_main_menu
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Installiere MYP V2..."
|
||||
|
||||
# Benötigte System-Pakete installieren
|
||||
echo "Installiere System-Abhängigkeiten..."
|
||||
apt update
|
||||
apt install -y python3.11 python3.11-pip python3.11-venv python3.11-dev \
|
||||
build-essential git curl
|
||||
|
||||
# Verzeichnis für MYP erstellen/aktualisieren
|
||||
mkdir -p /opt/myp
|
||||
|
||||
# Basispfad ermitteln
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# Komplette Projektstruktur kopieren
|
||||
echo "Kopiere Projektdateien..."
|
||||
cp -r "$SCRIPT_DIR/app" /opt/myp/
|
||||
cp -r "$SCRIPT_DIR/docs" /opt/myp/
|
||||
cp -r "$SCRIPT_DIR/install" /opt/myp/
|
||||
cp "$SCRIPT_DIR/requirements.txt" /opt/myp/
|
||||
cp "$SCRIPT_DIR/README.md" /opt/myp/
|
||||
cp "$SCRIPT_DIR/ROADMAP.md" /opt/myp/
|
||||
cp "$SCRIPT_DIR/COMMON_ERRORS.md" /opt/myp/
|
||||
|
||||
# Log-Verzeichnisse erstellen
|
||||
echo "Erstelle Log-Verzeichnisse..."
|
||||
mkdir -p /opt/myp/logs/{app,auth,jobs,printers,scheduler}
|
||||
|
||||
# Datenbank-Verzeichnis erstellen
|
||||
mkdir -p /opt/myp/data
|
||||
|
||||
# Python-Umgebung und Abhängigkeiten einrichten
|
||||
echo "Richte Python-Umgebung ein..."
|
||||
cd /opt/myp
|
||||
if [ ! -d ".venv" ]; then
|
||||
python3.11 -m venv .venv
|
||||
fi
|
||||
source .venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Berechtigungen setzen
|
||||
echo "Setze Berechtigungen..."
|
||||
chown -R www-data:www-data /opt/myp
|
||||
chmod -R 755 /opt/myp
|
||||
chmod -R 775 /opt/myp/logs
|
||||
chmod -R 775 /opt/myp/data
|
||||
|
||||
echo -e "${GREEN}Installation abgeschlossen.${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Nächste Schritte:${NC}"
|
||||
echo "1. Konfiguration anpassen: /opt/myp/app/config/settings.py"
|
||||
echo "2. MYP starten:"
|
||||
echo " cd /opt/myp && source .venv/bin/activate && python3.11 app/app.py"
|
||||
echo ""
|
||||
echo -e "${BLUE}Oder verwenden Sie Option 7 für Dienst-Management${NC}"
|
||||
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# 2) MYP V2 Kiosk-Modus Installation
|
||||
kiosk_installation() {
|
||||
print_header
|
||||
echo -e "${GREEN}MYP V2 Kiosk-Modus Installation${NC}"
|
||||
echo ""
|
||||
|
||||
# Benötigte Pakete installieren
|
||||
echo "Installiere benötigte Pakete..."
|
||||
apt update
|
||||
apt install -y python3.11 python3.11-pip python3.11-venv python3.11-dev \
|
||||
build-essential chromium-browser unclutter xdotool \
|
||||
xscreensaver git curl nginx
|
||||
|
||||
# Verzeichnis für MYP erstellen und Projekt kopieren
|
||||
echo "Kopiere MYP V2 nach /opt/myp..."
|
||||
mkdir -p /opt/myp
|
||||
|
||||
# Basispfad ermitteln
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# Komplette Projektstruktur kopieren
|
||||
cp -r "$SCRIPT_DIR/app" /opt/myp/
|
||||
cp -r "$SCRIPT_DIR/docs" /opt/myp/
|
||||
cp -r "$SCRIPT_DIR/install" /opt/myp/
|
||||
cp "$SCRIPT_DIR/requirements.txt" /opt/myp/
|
||||
cp "$SCRIPT_DIR/README.md" /opt/myp/
|
||||
cp "$SCRIPT_DIR/ROADMAP.md" /opt/myp/
|
||||
cp "$SCRIPT_DIR/COMMON_ERRORS.md" /opt/myp/
|
||||
|
||||
# Log-Verzeichnisse erstellen
|
||||
mkdir -p /opt/myp/logs/{app,auth,jobs,printers,scheduler}
|
||||
|
||||
# Datenbank-Verzeichnis erstellen
|
||||
mkdir -p /opt/myp/data
|
||||
|
||||
# Python-Umgebung und Abhängigkeiten einrichten
|
||||
echo "Richte Python-Umgebung ein..."
|
||||
cd /opt/myp
|
||||
python3.11 -m venv .venv
|
||||
source .venv/bin/activate
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
pip install gunicorn # Für Produktionsserver
|
||||
|
||||
# Systemd-Dienst für Flask-Backend einrichten
|
||||
echo "Richte Flask-Backend-Dienst ein..."
|
||||
|
||||
# Service-File erstellen
|
||||
cat > /etc/systemd/system/myp.service << EOF
|
||||
[Unit]
|
||||
Description=MYP V2 Flask Application
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=www-data
|
||||
Group=www-data
|
||||
WorkingDirectory=/opt/myp
|
||||
Environment=PATH=/opt/myp/.venv/bin
|
||||
ExecStart=/opt/myp/.venv/bin/python3.11 /opt/myp/app/app.py
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Berechtigungen setzen
|
||||
chown -R www-data:www-data /opt/myp
|
||||
chmod -R 755 /opt/myp
|
||||
chmod -R 775 /opt/myp/logs
|
||||
chmod -R 775 /opt/myp/data
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable myp.service
|
||||
systemctl start myp.service
|
||||
|
||||
# Nginx-Konfiguration für Reverse Proxy
|
||||
echo "Konfiguriere Nginx..."
|
||||
cat > /etc/nginx/sites-available/myp << EOF
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:5000;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
}
|
||||
|
||||
location /static {
|
||||
alias /opt/myp/app/static;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
ln -sf /etc/nginx/sites-available/myp /etc/nginx/sites-enabled/
|
||||
rm -f /etc/nginx/sites-enabled/default
|
||||
systemctl restart nginx
|
||||
|
||||
# Kiosk-Script einrichten
|
||||
echo "Richte Kiosk-Script ein..."
|
||||
|
||||
cat > /opt/myp/kiosk.sh << 'EOF'
|
||||
#!/bin/bash
|
||||
# MYP V2 Kiosk-Modus Script
|
||||
|
||||
# Bildschirmschoner deaktivieren
|
||||
xset s off
|
||||
xset -dpms
|
||||
xset s noblank
|
||||
|
||||
# Mauszeiger verstecken
|
||||
unclutter -idle 0.5 -root &
|
||||
|
||||
# Chromium im Kiosk-Modus starten
|
||||
chromium-browser \
|
||||
--noerrdialogs \
|
||||
--disable-infobars \
|
||||
--kiosk \
|
||||
--disable-session-crashed-bubble \
|
||||
--disable-restore-session-state \
|
||||
--disable-background-timer-throttling \
|
||||
--disable-backgrounding-occluded-windows \
|
||||
--disable-renderer-backgrounding \
|
||||
--disable-features=TranslateUI \
|
||||
--disable-ipc-flooding-protection \
|
||||
--disable-background-networking \
|
||||
--disable-sync \
|
||||
--disable-default-apps \
|
||||
--no-first-run \
|
||||
--fast \
|
||||
--fast-start \
|
||||
--disable-gpu \
|
||||
--no-sandbox \
|
||||
http://localhost/
|
||||
EOF
|
||||
|
||||
chmod +x /opt/myp/kiosk.sh
|
||||
|
||||
# Autostart für Kiosk-Modus einrichten
|
||||
mkdir -p /home/pi/.config/autostart
|
||||
cat > /home/pi/.config/autostart/myp-kiosk.desktop << EOF
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=MYP Kiosk
|
||||
Exec=/opt/myp/kiosk.sh
|
||||
Hidden=false
|
||||
NoDisplay=false
|
||||
X-GNOME-Autostart-enabled=true
|
||||
EOF
|
||||
|
||||
chown -R pi:pi /home/pi/.config
|
||||
|
||||
echo -e "${GREEN}Kiosk-Installation abgeschlossen.${NC}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}Das System wird beim nächsten Start automatisch im Kiosk-Modus starten.${NC}"
|
||||
echo -e "${BLUE}MYP V2 ist unter http://localhost erreichbar${NC}"
|
||||
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# 3) MYP V2 deinstallieren
|
||||
uninstall_myp() {
|
||||
print_header
|
||||
echo -e "${RED}MYP V2 deinstallieren${NC}"
|
||||
echo ""
|
||||
|
||||
if ! is_myp_installed; then
|
||||
echo -e "${YELLOW}MYP ist nicht installiert.${NC}"
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
return
|
||||
fi
|
||||
|
||||
read -p "Sind Sie sicher, dass Sie MYP komplett deinstallieren möchten? (j/n): " confirm
|
||||
if [[ "$confirm" != "j" && "$confirm" != "J" ]]; then
|
||||
show_main_menu
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Stoppe MYP-Dienste..."
|
||||
systemctl stop myp.service 2>/dev/null || true
|
||||
systemctl disable myp.service 2>/dev/null || true
|
||||
rm -f /etc/systemd/system/myp.service
|
||||
systemctl daemon-reload
|
||||
|
||||
echo "Entferne Kiosk-Modus Komponenten..."
|
||||
rm -f /home/pi/kiosk.sh
|
||||
rm -f /home/pi/.config/autostart/myp-kiosk.desktop
|
||||
|
||||
echo "Entferne MYP-Dateien..."
|
||||
rm -rf /opt/myp
|
||||
|
||||
echo -e "${GREEN}MYP wurde vollständig deinstalliert.${NC}"
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# 4) Netzwerkeinstellungen konfigurieren
|
||||
network_configuration() {
|
||||
print_header
|
||||
echo -e "${GREEN}Netzwerkeinstellungen konfigurieren${NC}"
|
||||
echo ""
|
||||
|
||||
# Netzwerkschnittstellen anzeigen
|
||||
echo -e "${YELLOW}Verfügbare Netzwerkschnittstellen:${NC}"
|
||||
ip -o link show | awk -F': ' '{print $2}'
|
||||
echo ""
|
||||
|
||||
read -p "Welche Schnittstelle möchten Sie konfigurieren? (z.B. eth0, wlan0): " interface
|
||||
|
||||
# Prüfen, ob die Schnittstelle existiert
|
||||
if ! ip link show "$interface" &>/dev/null; then
|
||||
echo -e "${RED}Die angegebene Schnittstelle existiert nicht.${NC}"
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
return
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}Konfiguration für $interface:${NC}"
|
||||
echo "1) DHCP (automatische IP-Adresse)"
|
||||
echo "2) Statische IP-Adresse"
|
||||
echo "3) WLAN konfigurieren (für wlan0)"
|
||||
echo "4) Zurück zum Hauptmenü"
|
||||
echo ""
|
||||
read -p "Ihre Auswahl: " network_option
|
||||
|
||||
case $network_option in
|
||||
1)
|
||||
# DHCP konfigurieren
|
||||
echo "Konfiguriere DHCP für $interface..."
|
||||
cat > "/etc/network/interfaces.d/$interface" << EOF
|
||||
auto $interface
|
||||
iface $interface inet dhcp
|
||||
EOF
|
||||
if [ "$interface" == "wlan0" ]; then
|
||||
echo "Für WLAN bitte auch SSID und Passwort konfigurieren."
|
||||
network_configuration
|
||||
return
|
||||
fi
|
||||
systemctl restart networking
|
||||
echo -e "${GREEN}DHCP wurde für $interface konfiguriert.${NC}"
|
||||
;;
|
||||
2)
|
||||
# Statische IP-Adresse konfigurieren
|
||||
read -p "IP-Adresse (z.B. 192.168.1.100): " ip_address
|
||||
read -p "Netzmaske (z.B. 255.255.255.0): " netmask
|
||||
read -p "Gateway (z.B. 192.168.1.1): " gateway
|
||||
|
||||
cat > "/etc/network/interfaces.d/$interface" << EOF
|
||||
auto $interface
|
||||
iface $interface inet static
|
||||
address $ip_address
|
||||
netmask $netmask
|
||||
gateway $gateway
|
||||
EOF
|
||||
systemctl restart networking
|
||||
echo -e "${GREEN}Statische IP-Adresse wurde für $interface konfiguriert.${NC}"
|
||||
;;
|
||||
3)
|
||||
# WLAN konfigurieren
|
||||
if [ "$interface" != "wlan0" ]; then
|
||||
echo -e "${RED}Diese Option ist nur für wlan0 verfügbar.${NC}"
|
||||
network_configuration
|
||||
return
|
||||
fi
|
||||
|
||||
read -p "SSID (Netzwerkname): " ssid
|
||||
read -s -p "Passwort: " password
|
||||
echo ""
|
||||
|
||||
# wpa_supplicant.conf erstellen/aktualisieren
|
||||
wpa_passphrase "$ssid" "$password" > /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
|
||||
# Netzwerk-Interface konfigurieren
|
||||
cat > "/etc/network/interfaces.d/wlan0" << EOF
|
||||
auto wlan0
|
||||
allow-hotplug wlan0
|
||||
iface wlan0 inet dhcp
|
||||
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
EOF
|
||||
|
||||
# WLAN neustarten
|
||||
systemctl restart networking
|
||||
wpa_cli -i wlan0 reconfigure
|
||||
|
||||
echo -e "${GREEN}WLAN wurde konfiguriert und verbunden.${NC}"
|
||||
;;
|
||||
4)
|
||||
show_main_menu
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Ungültige Option.${NC}"
|
||||
network_configuration
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# 5) DNS-Server konfigurieren
|
||||
dns_configuration() {
|
||||
print_header
|
||||
echo -e "${GREEN}DNS-Server konfigurieren${NC}"
|
||||
echo ""
|
||||
|
||||
# Aktuelle DNS-Server anzeigen
|
||||
echo -e "${YELLOW}Aktuelle DNS-Server:${NC}"
|
||||
if [ -f "/etc/resolv.conf" ]; then
|
||||
grep "nameserver" /etc/resolv.conf || echo "Keine DNS-Server konfiguriert."
|
||||
else
|
||||
echo "Die Datei /etc/resolv.conf existiert nicht."
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "1) DNS-Server automatisch beziehen (über DHCP)"
|
||||
echo "2) Manuelle DNS-Server konfigurieren"
|
||||
echo "3) Zurück zum Hauptmenü"
|
||||
echo ""
|
||||
read -p "Ihre Auswahl: " dns_option
|
||||
|
||||
case $dns_option in
|
||||
1)
|
||||
# Automatische DNS-Konfiguration
|
||||
if [ -f "/etc/dhcp/dhclient.conf" ]; then
|
||||
sed -i 's/^prepend domain-name-servers.*//' /etc/dhcp/dhclient.conf
|
||||
echo -e "${GREEN}DNS-Server werden jetzt automatisch über DHCP bezogen.${NC}"
|
||||
systemctl restart networking
|
||||
else
|
||||
echo -e "${RED}Die Datei /etc/dhcp/dhclient.conf existiert nicht.${NC}"
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
# Manuelle DNS-Konfiguration
|
||||
read -p "Primärer DNS-Server (z.B. 8.8.8.8): " primary_dns
|
||||
read -p "Sekundärer DNS-Server (z.B. 8.8.4.4, leer lassen wenn nicht benötigt): " secondary_dns
|
||||
|
||||
# resolv.conf direkt bearbeiten
|
||||
echo "nameserver $primary_dns" > /etc/resolv.conf
|
||||
if [ -n "$secondary_dns" ]; then
|
||||
echo "nameserver $secondary_dns" >> /etc/resolv.conf
|
||||
fi
|
||||
|
||||
# Für persistente Konfiguration
|
||||
if [ -f "/etc/dhcp/dhclient.conf" ]; then
|
||||
if [ -n "$secondary_dns" ]; then
|
||||
sed -i "s/^prepend domain-name-servers.*/prepend domain-name-servers $primary_dns, $secondary_dns;/" /etc/dhcp/dhclient.conf
|
||||
if ! grep -q "prepend domain-name-servers" /etc/dhcp/dhclient.conf; then
|
||||
echo "prepend domain-name-servers $primary_dns, $secondary_dns;" >> /etc/dhcp/dhclient.conf
|
||||
fi
|
||||
else
|
||||
sed -i "s/^prepend domain-name-servers.*/prepend domain-name-servers $primary_dns;/" /etc/dhcp/dhclient.conf
|
||||
if ! grep -q "prepend domain-name-servers" /etc/dhcp/dhclient.conf; then
|
||||
echo "prepend domain-name-servers $primary_dns;" >> /etc/dhcp/dhclient.conf
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}DNS-Server wurden konfiguriert.${NC}"
|
||||
;;
|
||||
3)
|
||||
show_main_menu
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Ungültige Option.${NC}"
|
||||
dns_configuration
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# 6) System-Status anzeigen
|
||||
system_status() {
|
||||
print_header
|
||||
echo -e "${GREEN}System-Status${NC}"
|
||||
echo ""
|
||||
|
||||
# MYP-Status
|
||||
echo -e "${YELLOW}MYP-Status:${NC}"
|
||||
if is_myp_installed; then
|
||||
echo "MYP ist installiert in /opt/myp"
|
||||
if systemctl is-active --quiet myp.service; then
|
||||
echo -e "MYP-Dienst: ${GREEN}Aktiv${NC}"
|
||||
else
|
||||
echo -e "MYP-Dienst: ${RED}Inaktiv${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "MYP ist ${RED}nicht installiert${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# Netzwerkstatus
|
||||
echo -e "${YELLOW}Netzwerkstatus:${NC}"
|
||||
ip -o addr show | awk '$3 == "inet" {print $2 ": " $4}'
|
||||
echo ""
|
||||
|
||||
# DNS-Server
|
||||
echo -e "${YELLOW}DNS-Server:${NC}"
|
||||
grep "nameserver" /etc/resolv.conf 2>/dev/null || echo "Keine DNS-Server konfiguriert."
|
||||
echo ""
|
||||
|
||||
# Systemressourcen
|
||||
echo -e "${YELLOW}Systemressourcen:${NC}"
|
||||
echo "CPU-Auslastung:"
|
||||
top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "% genutzt"}'
|
||||
echo "Speichernutzung:"
|
||||
free -h | grep "Mem:" | awk '{print $3 " von " $2 " genutzt"}'
|
||||
echo "Festplattenbelegung:"
|
||||
df -h / | grep -v "Filesystem" | awk '{print $3 " von " $2 " genutzt (" $5 ")"}'
|
||||
echo ""
|
||||
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# 7) MYP-Dienst starten/stoppen/neustarten
|
||||
service_management() {
|
||||
print_header
|
||||
echo -e "${GREEN}MYP-Dienst verwalten${NC}"
|
||||
echo ""
|
||||
|
||||
if ! is_myp_installed; then
|
||||
echo -e "${YELLOW}MYP ist nicht installiert.${NC}"
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
return
|
||||
fi
|
||||
|
||||
# Aktuellen Dienststatus anzeigen
|
||||
echo -e "${YELLOW}Aktueller Status:${NC}"
|
||||
if systemctl is-active --quiet myp.service; then
|
||||
echo -e "MYP-Dienst: ${GREEN}Aktiv${NC}"
|
||||
else
|
||||
echo -e "MYP-Dienst: ${RED}Inaktiv${NC}"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "1) MYP-Dienst starten"
|
||||
echo "2) MYP-Dienst stoppen"
|
||||
echo "3) MYP-Dienst neustarten"
|
||||
echo "4) Zurück zum Hauptmenü"
|
||||
echo ""
|
||||
read -p "Ihre Auswahl: " service_option
|
||||
|
||||
case $service_option in
|
||||
1)
|
||||
echo "Starte MYP-Dienst..."
|
||||
systemctl start myp.service
|
||||
echo -e "${GREEN}MYP-Dienst wurde gestartet.${NC}"
|
||||
;;
|
||||
2)
|
||||
echo "Stoppe MYP-Dienst..."
|
||||
systemctl stop myp.service
|
||||
echo -e "${GREEN}MYP-Dienst wurde gestoppt.${NC}"
|
||||
;;
|
||||
3)
|
||||
echo "Starte MYP-Dienst neu..."
|
||||
systemctl restart myp.service
|
||||
echo -e "${GREEN}MYP-Dienst wurde neugestartet.${NC}"
|
||||
;;
|
||||
4)
|
||||
show_main_menu
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Ungültige Option.${NC}"
|
||||
service_management
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# 8) Logs anzeigen
|
||||
show_logs() {
|
||||
print_header
|
||||
echo -e "${GREEN}Logs anzeigen${NC}"
|
||||
echo ""
|
||||
|
||||
echo "1) MYP-Anwendungslogs"
|
||||
echo "2) Systemd-Dienstlogs"
|
||||
echo "3) Watchdog-Logs"
|
||||
echo "4) Zurück zum Hauptmenü"
|
||||
echo ""
|
||||
read -p "Ihre Auswahl: " logs_option
|
||||
|
||||
case $logs_option in
|
||||
1)
|
||||
if [ -f "/opt/myp/myp.log" ]; then
|
||||
echo -e "${YELLOW}MYP-Anwendungslogs (letzte 20 Zeilen):${NC}"
|
||||
tail -n 20 /opt/myp/myp.log
|
||||
else
|
||||
echo -e "${RED}MYP-Logdatei nicht gefunden.${NC}"
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
echo -e "${YELLOW}Systemd-Dienstlogs für MYP:${NC}"
|
||||
journalctl -u myp.service -n 20 --no-pager
|
||||
;;
|
||||
3)
|
||||
if [ -f "/home/pi/myp-watchdog.log" ]; then
|
||||
echo -e "${YELLOW}Watchdog-Logs (letzte 20 Zeilen):${NC}"
|
||||
tail -n 20 /home/pi/myp-watchdog.log
|
||||
else
|
||||
echo -e "${RED}Watchdog-Logdatei nicht gefunden.${NC}"
|
||||
fi
|
||||
;;
|
||||
4)
|
||||
show_main_menu
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Ungültige Option.${NC}"
|
||||
show_logs
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# 9) Dokumentation anzeigen
|
||||
show_documentation() {
|
||||
print_header
|
||||
echo -e "${GREEN}Dokumentation${NC}"
|
||||
echo ""
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
echo "Verfügbare Dokumentation:"
|
||||
echo "1) Allgemeine README"
|
||||
echo "2) Kiosk-Modus Anleitung"
|
||||
echo "3) Fehlerbehebung"
|
||||
echo "4) Entwicklungsplan"
|
||||
echo "5) Zurück zum Hauptmenü"
|
||||
echo ""
|
||||
read -p "Ihre Auswahl: " doc_option
|
||||
|
||||
case $doc_option in
|
||||
1)
|
||||
if [ -f "$SCRIPT_DIR/docs/README.md" ]; then
|
||||
if command -v less &>/dev/null; then
|
||||
less "$SCRIPT_DIR/docs/README.md"
|
||||
else
|
||||
cat "$SCRIPT_DIR/docs/README.md"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}README nicht gefunden.${NC}"
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
if [ -f "$SCRIPT_DIR/docs/KIOSK-SETUP.md" ]; then
|
||||
if command -v less &>/dev/null; then
|
||||
less "$SCRIPT_DIR/docs/KIOSK-SETUP.md"
|
||||
else
|
||||
cat "$SCRIPT_DIR/docs/KIOSK-SETUP.md"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}Kiosk-Anleitung nicht gefunden.${NC}"
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
if [ -f "$SCRIPT_DIR/docs/COMMON_ERRORS.md" ]; then
|
||||
if command -v less &>/dev/null; then
|
||||
less "$SCRIPT_DIR/docs/COMMON_ERRORS.md"
|
||||
else
|
||||
cat "$SCRIPT_DIR/docs/COMMON_ERRORS.md"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}Fehlerbehebungsdokumentation nicht gefunden.${NC}"
|
||||
fi
|
||||
;;
|
||||
4)
|
||||
if [ -f "$SCRIPT_DIR/docs/ROADMAP.md" ]; then
|
||||
if command -v less &>/dev/null; then
|
||||
less "$SCRIPT_DIR/docs/ROADMAP.md"
|
||||
else
|
||||
cat "$SCRIPT_DIR/docs/ROADMAP.md"
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}Entwicklungsplan nicht gefunden.${NC}"
|
||||
fi
|
||||
;;
|
||||
5)
|
||||
show_main_menu
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Ungültige Option.${NC}"
|
||||
show_documentation
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
read -p "Drücken Sie eine Taste, um zum Hauptmenü zurückzukehren..."
|
||||
show_main_menu
|
||||
}
|
||||
|
||||
# Hauptprogramm
|
||||
check_root
|
||||
show_main_menu
|
||||
Reference in New Issue
Block a user