From: Guo Xiang Tan Date: Wed, 9 Mar 2016 05:05:19 +0000 (+0800) Subject: FIX: Validate and add email when registering for Let's Encrypt account. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=83d224e7d0c32198d00110a7b6c5363282556862;p=discourse_docker.git FIX: Validate and add email when registering for Let's Encrypt account. --- diff --git a/templates/web.letsencrypt.ssl.template.yml b/templates/web.letsencrypt.ssl.template.yml index e8e0d4e..d6f3d72 100644 --- a/templates/web.letsencrypt.ssl.template.yml +++ b/templates/web.letsencrypt.ssl.template.yml @@ -3,6 +3,11 @@ env: hooks: after_ssl: + - exec: + cmd: + - if [ -z "$LETSENCRYPT_ACCOUNT_EMAIL" ]; then echo "LETSENCRYPT_ACCOUNT_EMAIL ENV variable is required and has not been set."; exit 1; fi + - /bin/bash -c "if [[ ! \"$LETSENCRYPT_ACCOUNT_EMAIL\" =~ ([^@]+)@([^\.]+) ]]; then echo \"LETSENCRYPT_ACCOUNT_EMAIL is not a valid email address\"; exit 1; fi" + - exec: cmd: - cd /root && git clone https://github.com/Neilpang/le.git @@ -15,7 +20,6 @@ hooks: chmod: "+x" contents: | #!/bin/bash - set -e LE_WORKING_DIR="$$ENV_LETSENCRYPT_DIR" $$ENV_LETSENCRYPT_DIR/le.sh issue no $$ENV_DISCOURSE_HOSTNAME no 4096 LE_WORKING_DIR="$$ENV_LETSENCRYPT_DIR" $$ENV_LETSENCRYPT_DIR/le.sh installcert $$ENV_DISCOURSE_HOSTNAME /shared/ssl/$$ENV_DISCOURSE_HOSTNAME.cer /shared/ssl/$$ENV_DISCOURSE_HOSTNAME.key /shared/ssl/$$ENV_DISCOURSE_HOSTNAME.cer "sv reload nginx" # After the initial install, switch to Webroot plugin @@ -27,6 +31,12 @@ hooks: to: | ssl_certificate /shared/ssl/$$ENV_DISCOURSE_HOSTNAME.cer; + - replace: + filename: /shared/letsencrypt/account.conf + from: /#ACCOUNT_EMAIL=.+/ + to: | + ACCOUNT_EMAIL=$$ENV_LETSENCRYPT_ACCOUNT_EMAIL + - replace: filename: "/etc/nginx/conf.d/discourse.conf" from: /ssl_certificate_key.+/