🐛 Fix problems with alias domains and dns-01 challenge (#1785)

* 🐛 Fix problems with alias domains and dns-01 challenge

And add some documentation to clarify a bit.

Resolves #1331

* Fix linter issue

* Add changelog

* Update config.json

* Update config.json

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
This commit is contained in:
Ryan Meulenkamp
2021-02-09 12:14:09 +01:00
committed by GitHub
parent d291f564ce
commit a9fbb6991e
4 changed files with 29 additions and 8 deletions

View File

@@ -16,15 +16,26 @@ WAIT_TIME=$(bashio::config 'seconds')
# Function that performe a renew
function le_renew() {
local domain_args=()
local domains
local domains=''
local aliases=''
domains=$(bashio::config 'domains')
# Prepare domain for Let's Encrypt
for domain in ${domains}; do
for alias in $(jq --raw-output --exit-status "[.aliases[]|{(.alias):.domain}]|add.\"${domain}\" | select(. != null)" /data/options.json) ; do
aliases="${aliases} ${alias}"
done
done
aliases="$(echo "${aliases}" | tr ' ' '\n' | sort | uniq)"
bashio::log.info "Renew certificate for domains: $(echo -n "${domains}") and aliases: $(echo -n "${aliases}")"
for domain in $(echo "${domains}" "${aliases}" | tr ' ' '\n' | sort | uniq); do
domain_args+=("--domain" "${domain}")
done
dehydrated --cron --hook ./hooks.sh --challenge dns-01 "${domain_args[@]}" --out "${CERT_DIR}" --config "${WORK_DIR}/config" || true
LE_UPDATE="$(date +%s)"
}
@@ -56,7 +67,7 @@ while true; do
[[ ${IPV4} != *:/* ]] && ipv4=${IPV4} || ipv4=$(curl -s -m 10 "${IPV4}")
[[ ${IPV6} != *:/* ]] && ipv6=${IPV6} || ipv6=$(curl -s -m 10 "${IPV6}")
if answer="$(curl -s "https://www.duckdns.org/update?domains=${DOMAINS}&token=${TOKEN}&ip=${ipv4}&ipv6=${ipv6}&verbose=true")"; then
if answer="$(curl -s "https://www.duckdns.org/update?domains=${DOMAINS}&token=${TOKEN}&ip=${ipv4}&ipv6=${ipv6}&verbose=true")" && [ "${answer}" != 'KO' ]; then
bashio::log.info "${answer}"
else
bashio::log.warning "${answer}"