From 8cdb071ef1742c80653be64f9ec3658a3dc012ed Mon Sep 17 00:00:00 2001 From: Pierre Cariou <46612673+pcarioufr@users.noreply.github.com> Date: Sat, 5 Sep 2020 22:22:23 +0200 Subject: [PATCH 1/3] Update init-letsencrypt.sh fix loop on domains for dummy certificates --- init-letsencrypt.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/init-letsencrypt.sh b/init-letsencrypt.sh index 13eaa757..a9ffbcdd 100755 --- a/init-letsencrypt.sh +++ b/init-letsencrypt.sh @@ -42,12 +42,17 @@ echo "### Starting nginx ..." docker-compose up --force-recreate -d nginx echo -echo "### Deleting dummy certificate for $domains ..." -docker-compose run --rm --entrypoint "\ - rm -Rf /etc/letsencrypt/live/$domains && \ - rm -Rf /etc/letsencrypt/archive/$domains && \ - rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot -echo +for domain in "${domains[@]}"; do + echo "### Creating dummy certificate for $domain ..." + path="/etc/letsencrypt/live/$domain" + mkdir -p "$data_path/conf/live/$domain" + docker-compose run --rm --entrypoint "\ + openssl req -x509 -nodes -newkey rsa:4096 -days 1\ + -keyout '$path/privkey.pem' \ + -out '$path/fullchain.pem' \ + -subj '/CN=localhost'" certbot + echo +done echo "### Requesting Let's Encrypt certificate for $domains ..." From 40cdf4517a6824f690abf7d17104dfa18345fecf Mon Sep 17 00:00:00 2001 From: Pierre Cariou <46612673+pcarioufr@users.noreply.github.com> Date: Sat, 5 Sep 2020 22:25:53 +0200 Subject: [PATCH 2/3] Update init-letsencrypt.sh --- init-letsencrypt.sh | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/init-letsencrypt.sh b/init-letsencrypt.sh index a9ffbcdd..57849ccb 100755 --- a/init-letsencrypt.sh +++ b/init-letsencrypt.sh @@ -27,21 +27,6 @@ if [ ! -e "$data_path/conf/options-ssl-nginx.conf" ] || [ ! -e "$data_path/conf/ echo fi -echo "### Creating dummy certificate for $domains ..." -path="/etc/letsencrypt/live/$domains" -mkdir -p "$data_path/conf/live/$domains" -docker-compose run --rm --entrypoint "\ - openssl req -x509 -nodes -newkey rsa:1024 -days 1\ - -keyout '$path/privkey.pem' \ - -out '$path/fullchain.pem' \ - -subj '/CN=localhost'" certbot -echo - - -echo "### Starting nginx ..." -docker-compose up --force-recreate -d nginx -echo - for domain in "${domains[@]}"; do echo "### Creating dummy certificate for $domain ..." path="/etc/letsencrypt/live/$domain" @@ -54,6 +39,16 @@ for domain in "${domains[@]}"; do echo done +echo "### Starting nginx ..." +docker-compose up --force-recreate -d nginx +echo + +echo "### Deleting dummy certificate for $domains ..." + docker-compose run --rm --entrypoint "\ + rm -Rf /etc/letsencrypt/live/$domains && \ + rm -Rf /etc/letsencrypt/archive/$domains && \ + rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot + echo echo "### Requesting Let's Encrypt certificate for $domains ..." #Join $domains to -d args From 77493c1f99658fb888552a6659a1e49dd3b208bb Mon Sep 17 00:00:00 2001 From: Pierre Cariou <46612673+pcarioufr@users.noreply.github.com> Date: Sat, 5 Sep 2020 23:04:32 +0200 Subject: [PATCH 3/3] Update init-letsencrypt.sh --- init-letsencrypt.sh | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/init-letsencrypt.sh b/init-letsencrypt.sh index 57849ccb..e3c4bbaf 100755 --- a/init-letsencrypt.sh +++ b/init-letsencrypt.sh @@ -43,19 +43,17 @@ echo "### Starting nginx ..." docker-compose up --force-recreate -d nginx echo -echo "### Deleting dummy certificate for $domains ..." - docker-compose run --rm --entrypoint "\ - rm -Rf /etc/letsencrypt/live/$domains && \ - rm -Rf /etc/letsencrypt/archive/$domains && \ - rm -Rf /etc/letsencrypt/renewal/$domains.conf" certbot - echo +for domain in "${domains[@]}"; do + echo "### Deleting dummy certificate for $domain ..." + docker-compose run --rm --entrypoint "\ + rm -Rf /etc/letsencrypt/live/$domain && \ + rm -Rf /etc/letsencrypt/archive/$domain && \ + rm -Rf /etc/letsencrypt/renewal/$domain.conf" certbot + echo +done echo "### Requesting Let's Encrypt certificate for $domains ..." #Join $domains to -d args -domain_args="" -for domain in "${domains[@]}"; do - domain_args="$domain_args -d $domain" -done # Select appropriate email arg case "$email" in @@ -66,15 +64,20 @@ esac # Enable staging mode if needed if [ $staging != "0" ]; then staging_arg="--staging"; fi -docker-compose run --rm --entrypoint "\ - certbot certonly --webroot -w /var/www/certbot \ - $staging_arg \ - $email_arg \ - $domain_args \ - --rsa-key-size $rsa_key_size \ - --agree-tos \ - --force-renewal" certbot -echo +for domain in "${domains[@]}"; do + domain_args="$domain_args -d $domain" + + docker-compose run --rm --entrypoint "\ + certbot certonly --webroot -w /var/www/certbot \ + $staging_arg \ + $email_arg \ + -d $domain \ + --rsa-key-size $rsa_key_size \ + --agree-tos \ + --force-renewal" certbot + echo + +done echo "### Reloading nginx ..." docker-compose exec nginx nginx -s reload