diff --git a/scripts/setup-ssl-improved.sh b/scripts/setup-ssl-improved.sh index 12af61b..71ebfe5 100644 --- a/scripts/setup-ssl-improved.sh +++ b/scripts/setup-ssl-improved.sh @@ -96,11 +96,17 @@ ${SUDO}${DOCKER_COMPOSE} -f docker-compose-prod.yml up -d nginx echo -e "${YELLOW}⏳ Warte auf Nginx...${NC}" 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}" -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}" else + echo -e "${YELLOW}⚠️ Kein SSL-Zertifikat gefunden oder Prüfung fehlgeschlagen. Versuche Zertifikatserstellung...${NC}" # Erstelle SSL-Zertifikat echo -e "${YELLOW}🔐 Erstelle SSL-Zertifikat für $DOMAIN...${NC}" ${SUDO}${DOCKER_COMPOSE} -f docker-compose-prod.yml run --rm certbot certbot certonly \ @@ -120,16 +126,22 @@ else echo "- Domain ist nicht erreichbar" echo "- Port 80 ist blockiert" echo "- DNS-Einträge sind nicht korrekt" - exit 1 + echo "" + echo -e "${YELLOW}⚠️ Fortfahren ohne SSL-Zertifikat (HTTP-only)...${NC}" fi fi -# Erstelle HTTPS Nginx-Konfiguration -echo -e "${YELLOW}📝 Erstelle HTTPS Nginx-Konfiguration...${NC}" -# Stelle die ursprüngliche HTTPS-Konfiguration wieder her -git checkout nginx/nginx.conf -sed "s/\${DOMAIN}/$DOMAIN/g" nginx/nginx.conf > nginx/nginx.conf.tmp -mv nginx/nginx.conf.tmp nginx/nginx.conf +# Erstelle HTTPS Nginx-Konfiguration (nur wenn SSL-Zertifikat vorhanden) +if [ "$CERT_EXISTS" = true ]; then + echo -e "${YELLOW}📝 Erstelle HTTPS Nginx-Konfiguration...${NC}" + # Stelle die ursprüngliche HTTPS-Konfiguration wieder her + git checkout 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 echo -e "${YELLOW}🚀 Starte alle Services...${NC}"