diff options
Diffstat (limited to 'roles/apache_server/templates/deploy_static_site_certs')
-rw-r--r-- | roles/apache_server/templates/deploy_static_site_certs | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/roles/apache_server/templates/deploy_static_site_certs b/roles/apache_server/templates/deploy_static_site_certs index b0227e8..440fe23 100644 --- a/roles/apache_server/templates/deploy_static_site_certs +++ b/roles/apache_server/templates/deploy_static_site_certs @@ -3,28 +3,37 @@ set -eu -domains() -{ - cd /etc/letsencrypt/static_sites - ls -} - opts() { - domains | while read domain alias + cat "$1" | while read domain alias do - echo -w "/srv/letsencrypt/$domain" -d "$domain" + printf "%s" "-w /srv/letsencrypt/$domain -d $domain" if [ -n "$alias" ] then - echo -d "$alias" + printf "%s" " -d $alias" fi + printf "\n" done } -certbot certonly \ - --noninteractive \ - --email "{{ letsencrypt_email }}" \ - --agree-tos \ - --expand \ - --cert-name static_sites \ - --webroot $(opts) + +run_certbot() +{ + local list="$1" + local certname="$2" + certbot certonly \ + --standalone \ + --noninteractive \ + --email "{{ letsencrypt_email }}" \ + --agree-tos \ + --expand \ + --cert-name "$certname" \ + $(opts "$list") +} + + +for list in /etc/letsencrypt/*.list +do + certname="$(basename "$list" .list)" + run_certbot "$list" "$certname" +done |