Fix: Handle existing SSL certificates in setup script
- Added check for existing SSL certificates before attempting to create new ones - Restore original HTTPS nginx.conf after certificate verification - This prevents the script from hanging when certificates already exist
This commit is contained in:
@@ -96,6 +96,11 @@ ${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
|
||||||
|
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
|
||||||
|
echo -e "${GREEN}✅ SSL-Zertifikat für $DOMAIN bereits vorhanden!${NC}"
|
||||||
|
else
|
||||||
# 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 \
|
||||||
@@ -117,9 +122,12 @@ else
|
|||||||
echo "- DNS-Einträge sind nicht korrekt"
|
echo "- DNS-Einträge sind nicht korrekt"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Erstelle HTTPS Nginx-Konfiguration
|
# Erstelle HTTPS Nginx-Konfiguration
|
||||||
echo -e "${YELLOW}📝 Erstelle HTTPS Nginx-Konfiguration...${NC}"
|
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
|
sed "s/\${DOMAIN}/$DOMAIN/g" nginx/nginx.conf > nginx/nginx.conf.tmp
|
||||||
mv nginx/nginx.conf.tmp nginx/nginx.conf
|
mv nginx/nginx.conf.tmp nginx/nginx.conf
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user