105 lines
3.1 KiB
Bash
105 lines
3.1 KiB
Bash
#!/bin/bash
|
|
# MYP Quick Fix - Connection Refused
|
|
# Schnelle Reparatur der häufigsten Verbindungsprobleme
|
|
|
|
set -e
|
|
|
|
# Farben
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m'
|
|
|
|
echo -e "${BLUE}🚀 MYP QUICK FIX - Connection Refused${NC}"
|
|
echo "=============================================="
|
|
|
|
# 1. Services stoppen und neu starten
|
|
echo -e "${YELLOW}🔄 Schritt 1: Services neu starten${NC}"
|
|
services=("myp-kiosk" "myp-https" "myp-app")
|
|
|
|
for service in "${services[@]}"; do
|
|
if systemctl is-enabled "$service" >/dev/null 2>&1; then
|
|
echo " Stoppe $service..."
|
|
systemctl stop "$service" 2>/dev/null || true
|
|
sleep 1
|
|
echo " Starte $service..."
|
|
systemctl start "$service" 2>/dev/null || true
|
|
sleep 2
|
|
|
|
if systemctl is-active "$service" >/dev/null 2>&1; then
|
|
echo -e " ✅ $service läuft"
|
|
else
|
|
echo -e " ❌ $service Fehler"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
# 2. Ports freigeben
|
|
echo -e "${YELLOW}🔥 Schritt 2: Firewall-Ports öffnen${NC}"
|
|
if command -v ufw >/dev/null 2>&1; then
|
|
ufw allow 443 >/dev/null 2>&1 || true
|
|
ufw allow 5000 >/dev/null 2>&1 || true
|
|
ufw allow 80 >/dev/null 2>&1 || true
|
|
echo " ✅ Ports 443, 5000, 80 geöffnet"
|
|
fi
|
|
|
|
# 3. SSL-Zertifikate prüfen/erstellen
|
|
echo -e "${YELLOW}🔐 Schritt 3: SSL-Zertifikate prüfen${NC}"
|
|
SSL_DIR="/opt/myp/ssl"
|
|
mkdir -p "$SSL_DIR"
|
|
|
|
if [ ! -f "$SSL_DIR/cert.pem" ] || [ ! -f "$SSL_DIR/key.pem" ]; then
|
|
echo " Erstelle SSL-Zertifikate..."
|
|
cd "$SSL_DIR"
|
|
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes \
|
|
-subj "/C=DE/ST=BW/L=Stuttgart/O=Mercedes/CN=m040tbaraspi001" >/dev/null 2>&1
|
|
chmod 644 cert.pem
|
|
chmod 600 key.pem
|
|
echo " ✅ SSL-Zertifikate erstellt"
|
|
else
|
|
echo " ✅ SSL-Zertifikate vorhanden"
|
|
fi
|
|
|
|
# 4. Python-Abhängigkeiten prüfen
|
|
echo -e "${YELLOW}🐍 Schritt 4: Python-Module prüfen${NC}"
|
|
cd /opt/myp
|
|
if [ -f "requirements.txt" ]; then
|
|
python3 -m pip install -r requirements.txt --break-system-packages --quiet >/dev/null 2>&1 || true
|
|
echo " ✅ Python-Module aktualisiert"
|
|
fi
|
|
|
|
# 5. App manuell testen
|
|
echo -e "${YELLOW}🧪 Schritt 5: App-Test${NC}"
|
|
cd /opt/myp
|
|
timeout 5 python3 -c "
|
|
import sys
|
|
sys.path.insert(0, '/opt/myp')
|
|
try:
|
|
from app import app
|
|
print(' ✅ App-Import erfolgreich')
|
|
except Exception as e:
|
|
print(f' ❌ App-Import-Fehler: {e}')
|
|
" 2>/dev/null || echo " ⚠️ App-Test unvollständig"
|
|
|
|
# 6. Verbindungstest
|
|
echo -e "${YELLOW}🌐 Schritt 6: Verbindungstest${NC}"
|
|
sleep 3
|
|
|
|
for port in 5000 443; do
|
|
if timeout 3 bash -c "</dev/tcp/localhost/$port" 2>/dev/null; then
|
|
echo -e " ✅ Port $port erreichbar"
|
|
else
|
|
echo -e " ❌ Port $port nicht erreichbar"
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
echo -e "${GREEN}🏁 Quick Fix abgeschlossen!${NC}"
|
|
echo ""
|
|
echo -e "${BLUE}Teste jetzt:${NC}"
|
|
echo " Browser: https://localhost"
|
|
echo " Kiosk sollte sich verbinden können"
|
|
echo ""
|
|
echo -e "${BLUE}Falls Problem weiterhin besteht:${NC}"
|
|
echo " sudo ./debug_connection_refused.sh" |