From c14f785672c4aa1229af3346f6c5126b853ec62b Mon Sep 17 00:00:00 2001 From: f Date: Mon, 7 Sep 2020 18:06:50 -0300 Subject: [PATCH] push certificates and skip non-local domains --- certbot.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/certbot.sh b/certbot.sh index a382ef8..be8e570 100644 --- a/certbot.sh +++ b/certbot.sh @@ -44,6 +44,9 @@ case $1 in # Skip already existing domains test -d "/etc/letsencrypt/live/${d}" && continue + # Ignore non local domains + nslookup "${d}" 8.8.8.8 | grep -q "${SUTTY_ADDRESS}" || continue + # Get the certificate for the domain, the webserver will need # access to this directory /usr/bin/certbot certonly --email "certbot@${SUTTY}" \ @@ -53,9 +56,16 @@ case $1 in -d "${d}" done done - - # Fix permissions, users in group ssl have read access - find /etc/letsencrypt -type d | xargs -r chmod 2750 - find /etc/letsencrypt -type f | xargs -r chmod 640 - chgrp -R ssl /etc/letsencrypt esac + +# Fix permissions, users in group ssl have read access +find /etc/letsencrypt -type d | xargs -r chmod 2750 +find /etc/letsencrypt -type f | xargs -r chmod 640 +chgrp -R ssl /etc/letsencrypt + +# Push certificates to nodes, we use SSH as a secure transport +# but this means we're synchronizing from container to host which is +# awkward. +for NODE in ${NODES}; do + rsync -avHAX --delete-after /etc/letsencrypt/ ${NODE}:/srv/sutty/etc/letsencrypt/ +done