email now optional, and wildcard defaults to false
This commit is contained in:
parent
00cc1484a3
commit
aa97821190
3 changed files with 25 additions and 19 deletions
|
@ -4,10 +4,10 @@ Automatically generates Let's Encrypt certificates using a lightweight Docker co
|
|||
|
||||
Variables:
|
||||
|
||||
* `DUCKDNS_TOKEN`: Duck DNS Account Token
|
||||
* `DUCKDNS_TOKEN`: Duck DNS account token (obtained from [Duck DNS](https://www.duckdns.org))
|
||||
* `DUCKDNS_DOMAIN`: Full Duck DNS domain (e.g. `test.duckdns.org`)
|
||||
* `LETSENCRYPT_EMAIL`: Email used for certificate renewal notifications (optional)
|
||||
* `LETSENCRYPT_WILDCARD`: `true` or `false`, indicating whether the SSL certificate should be for all subdomains of `DUCKDNS_DOMAIN` (i.e. `*.test.duckdns.org`), or just the main domain (i.e. `test.duckdns.org`)
|
||||
* `LETSENCRYPT_WILDCARD`: `true` or `false`, indicating whether the SSL certificate should be for all subdomains of `DUCKDNS_DOMAIN` (i.e. `*.test.duckdns.org`), or just the main domain (i.e. `test.duckdns.org`) (default: `false`)
|
||||
|
||||
**Note:** The format of `DUCKDNS_DOMAIN` should be the same regardless of the value of `LETSENCRYPT_WILDCARD`.
|
||||
|
||||
|
@ -17,5 +17,5 @@ Volumes:
|
|||
|
||||
**Note:** If a hosted volume is used, the volume should be mounted in an unused directory in another container to prevent access conflicts.
|
||||
|
||||
#### TODO:
|
||||
### TODO:
|
||||
* Implement tests so `depends_on` can be used in docker-compose to prevent other containers from initialising until certificates are ready
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
# TODO: Make email an optional parameter
|
||||
# Check what happens when both -m and registration without email are supplied
|
||||
if [ -z "$LETSENCRYPT_EMAIL" ]; then
|
||||
export EMAIL_PARAM="--register-unsafely-without-email"
|
||||
else
|
||||
export EMAIL_PARAM="-m ${LETSENCRYPT_EMAIL} --no-eff-email"
|
||||
fi
|
||||
|
||||
if [ ! -z "$TESTING" ]; then
|
||||
echo NOTICE: Generating staging certificate
|
||||
export TEST_PARAM="--staging"
|
||||
fi
|
||||
|
||||
# Initial check for certificates
|
||||
certbot certonly --manual --preferred-challenges dns --manual-auth-hook \
|
||||
/scripts/auth.sh --manual-cleanup-hook /scripts/cleanup.sh \
|
||||
-m "${LETSENCRYPT_EMAIL}" --no-eff-email -d "${LETSENCRYPT_DOMAIN}" \
|
||||
--agree-tos --manual-public-ip-logging-ok --keep
|
||||
"${EMAIL_PARAM}" -d "${LETSENCRYPT_DOMAIN}" \
|
||||
--agree-tos --manual-public-ip-logging-ok --keep ${TEST_PARAM}
|
||||
|
||||
# Basic check for successful certificate generation
|
||||
if [ ! -d "/etc/letsencrypt/live" ]; then
|
||||
if [ ! -d "/etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}" ] || \
|
||||
[ ! -f "/etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/fullchain.pem" ] || \
|
||||
[ ! -f "/etc/letsencrypt/live/${LETSENCRYPT_DOMAIN}/privkey.pem" ]; then
|
||||
echo ERROR: Failed to create SSL certificates
|
||||
exit 1
|
||||
fi
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Check variables DUCKDNS_TOKEN, DUCKDNS_DOMAIN, LETSENCRYPT_EMAIL, LETSENCRYPT_WILDCARD
|
||||
# Check variables DUCKDNS_TOKEN, DUCKDNS_DOMAIN
|
||||
if [ -z "$DUCKDNS_TOKEN" ]; then
|
||||
echo ERROR: Variable DUCKDNS_TOKEN is unset
|
||||
exit 1
|
||||
|
@ -11,30 +11,26 @@ if [ -z "$DUCKDNS_DOMAIN" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$LETSENCRYPT_WILDCARD" ]; then
|
||||
echo ERROR: Variable LETSENCRYPT_WILDCARD is unset
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Print email notice if applicable
|
||||
if [ -z "$LETSENCRYPT_EMAIL" ]; then
|
||||
echo NOTICE: You will not receive SSL certificate expiration notices
|
||||
fi
|
||||
|
||||
# Set certificate url based on LETSENCRYPT_WILDCARD value
|
||||
if [ "$LETSENCRYPT_WILDCARD" = "true" ]; then
|
||||
echo NOTICE: A wildcard SSL certificate will be created
|
||||
export LETSENCRYPT_DOMAIN=*.${DUCKDNS_DOMAIN}
|
||||
elif [ "$LETSENCRYPT_WILDCARD" = "false" ]; then
|
||||
export LETSENCRYPT_DOMAIN=${DUCKDNS_DOMAIN}
|
||||
export WILDCARD_STR="true"
|
||||
else
|
||||
echo ERROR: Invalid value for LETSENCRYPT_WILDCARD
|
||||
exit 1
|
||||
export LETSENCRYPT_DOMAIN=${DUCKDNS_DOMAIN}
|
||||
export WILDCARD_STR="false"
|
||||
fi
|
||||
|
||||
# Print variables
|
||||
echo DUCKDNS_TOKEN: $DUCKDNS_TOKEN
|
||||
echo DUCKDNS_DOMAIN: $DUCKDNS_DOMAIN
|
||||
echo LETSENCRYPT_EMAIL: $LETSENCRYPT_EMAIL
|
||||
echo LETSENCRYPT_WILDCARD: $LETSENCRYPT_WILDCARD
|
||||
echo LETSENCRYPT_WILDCARD: $WILDCARD_STR \(Input: \"${LETSENCRYPT_WILDCARD}\"\)
|
||||
|
||||
# Start automatic ssl certificate generation
|
||||
/bin/sh /scripts/cert.sh
|
||||
|
|
Loading…
Reference in a new issue