use *.*.conf glob to match only domain conf files for cert issuance

This commit is contained in:
2026-03-20 16:55:52 -04:00
parent 4b39eaaf06
commit 729eadee33
+2 -6
View File
@@ -88,10 +88,8 @@ fi
if [ "$APP" = "nginx" ]; then if [ "$APP" = "nginx" ]; then
# Issue certs for any new domains (brief nginx downtime while certbot binds port 80) # Issue certs for any new domains (brief nginx downtime while certbot binds port 80)
missing_certs=false missing_certs=false
for conf in /opt/hantim/docker/nginx/conf.d/*.conf; do for conf in /opt/hantim/docker/nginx/conf.d/*.*.conf; do
cert_name=$(basename "$conf" .conf) cert_name=$(basename "$conf" .conf)
# skip catch-all default server blocks (server_name _)
grep -qP 'server_name\s+_\s*;' "$conf" && continue
if [ ! -d "/etc/letsencrypt/live/$cert_name" ]; then if [ ! -d "/etc/letsencrypt/live/$cert_name" ]; then
missing_certs=true missing_certs=true
break break
@@ -100,10 +98,8 @@ if [ "$APP" = "nginx" ]; then
if [ "$missing_certs" = true ]; then if [ "$missing_certs" = true ]; then
docker stop nginx 2>/dev/null || true docker stop nginx 2>/dev/null || true
trap 'docker start nginx 2>/dev/null || true' EXIT trap 'docker start nginx 2>/dev/null || true' EXIT
for conf in /opt/hantim/docker/nginx/conf.d/*.conf; do for conf in /opt/hantim/docker/nginx/conf.d/*.*.conf; do
cert_name=$(basename "$conf" .conf) cert_name=$(basename "$conf" .conf)
# skip catch-all default server blocks (server_name _)
grep -qP 'server_name\s+_\s*;' "$conf" && continue
if [ ! -d "/etc/letsencrypt/live/$cert_name" ]; then if [ ! -d "/etc/letsencrypt/live/$cert_name" ]; then
domains=$(grep -oP 'server_name\s+\K[^;]+' "$conf" | tr ' ' '\n' | sort -u) domains=$(grep -oP 'server_name\s+\K[^;]+' "$conf" | tr ' ' '\n' | sort -u)
domain_args="" domain_args=""