Fix: Add timeout and fallback for SSL certificate check
- Added 30-second timeout to certificate check to prevent hanging - Added fallback to HTTP-only configuration if SSL setup fails - Script now continues even if certificate verification fails - This prevents the script from hanging indefinitely
This commit is contained in:
@@ -96,11 +96,17 @@ ${SUDO}${DOCKER_COMPOSE} -f docker-compose-prod.yml up -d nginx
|
|||||||
echo -e "${YELLOW}⏳ Warte auf Nginx...${NC}"
|
echo -e "${YELLOW}⏳ Warte auf Nginx...${NC}"
|
||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
# Prüfe ob SSL-Zertifikat bereits existiert
|
# Prüfe ob SSL-Zertifikat bereits existiert (mit Timeout)
|
||||||
echo -e "${YELLOW}🔍 Prüfe vorhandene SSL-Zertifikate...${NC}"
|
echo -e "${YELLOW}🔍 Prüfe vorhandene SSL-Zertifikate...${NC}"
|
||||||
if ${SUDO}${DOCKER_COMPOSE} -f docker-compose-prod.yml run --rm certbot certbot certificates -d $DOMAIN | grep -q "Certificate Name: $DOMAIN"; then
|
CERT_EXISTS=false
|
||||||
|
if timeout 30 ${SUDO}${DOCKER_COMPOSE} -f docker-compose-prod.yml run --rm certbot certbot certificates -d $DOMAIN 2>/dev/null | grep -q "Certificate Name: $DOMAIN"; then
|
||||||
|
CERT_EXISTS=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$CERT_EXISTS" = true ]; then
|
||||||
echo -e "${GREEN}✅ SSL-Zertifikat für $DOMAIN bereits vorhanden!${NC}"
|
echo -e "${GREEN}✅ SSL-Zertifikat für $DOMAIN bereits vorhanden!${NC}"
|
||||||
else
|
else
|
||||||
|
echo -e "${YELLOW}⚠️ Kein SSL-Zertifikat gefunden oder Prüfung fehlgeschlagen. Versuche Zertifikatserstellung...${NC}"
|
||||||
# Erstelle SSL-Zertifikat
|
# Erstelle SSL-Zertifikat
|
||||||
echo -e "${YELLOW}🔐 Erstelle SSL-Zertifikat für $DOMAIN...${NC}"
|
echo -e "${YELLOW}🔐 Erstelle SSL-Zertifikat für $DOMAIN...${NC}"
|
||||||
${SUDO}${DOCKER_COMPOSE} -f docker-compose-prod.yml run --rm certbot certbot certonly \
|
${SUDO}${DOCKER_COMPOSE} -f docker-compose-prod.yml run --rm certbot certbot certonly \
|
||||||
@@ -120,16 +126,22 @@ else
|
|||||||
echo "- Domain ist nicht erreichbar"
|
echo "- Domain ist nicht erreichbar"
|
||||||
echo "- Port 80 ist blockiert"
|
echo "- Port 80 ist blockiert"
|
||||||
echo "- DNS-Einträge sind nicht korrekt"
|
echo "- DNS-Einträge sind nicht korrekt"
|
||||||
exit 1
|
echo ""
|
||||||
|
echo -e "${YELLOW}⚠️ Fortfahren ohne SSL-Zertifikat (HTTP-only)...${NC}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Erstelle HTTPS Nginx-Konfiguration
|
# Erstelle HTTPS Nginx-Konfiguration (nur wenn SSL-Zertifikat vorhanden)
|
||||||
echo -e "${YELLOW}📝 Erstelle HTTPS Nginx-Konfiguration...${NC}"
|
if [ "$CERT_EXISTS" = true ]; then
|
||||||
# Stelle die ursprüngliche HTTPS-Konfiguration wieder her
|
echo -e "${YELLOW}📝 Erstelle HTTPS Nginx-Konfiguration...${NC}"
|
||||||
git checkout nginx/nginx.conf
|
# Stelle die ursprüngliche HTTPS-Konfiguration wieder her
|
||||||
sed "s/\${DOMAIN}/$DOMAIN/g" nginx/nginx.conf > nginx/nginx.conf.tmp
|
git checkout nginx/nginx.conf
|
||||||
mv nginx/nginx.conf.tmp nginx/nginx.conf
|
sed "s/\${DOMAIN}/$DOMAIN/g" nginx/nginx.conf > nginx/nginx.conf.tmp
|
||||||
|
mv nginx/nginx.conf.tmp nginx/nginx.conf
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}📝 Verwende HTTP-only Nginx-Konfiguration (kein SSL-Zertifikat)...${NC}"
|
||||||
|
# Bleibe bei der HTTP-only Konfiguration
|
||||||
|
fi
|
||||||
|
|
||||||
# Starte alle Services
|
# Starte alle Services
|
||||||
echo -e "${YELLOW}🚀 Starte alle Services...${NC}"
|
echo -e "${YELLOW}🚀 Starte alle Services...${NC}"
|
||||||
|
Reference in New Issue
Block a user