certbot-duckdns/certbot-auth

18 lines
654 B
Bash
Executable file

#!/usr/bin/env sh
echo "certbot txt record: $CERTBOT_VALIDATION"
baseurl='https://www.duckdns.org/update?domains=%s&token=%s&txt=%s'
result="$(printf 'url=%s\n' "$baseurl" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" "$CERTBOT_VALIDATION" | curl -K -)"
# give some time for the record to update
echo "waiting for txt record"
for _i in $(seq 0 60); do
val="$(nslookup -type=TXT "$DUCKDNS_DOMAIN.duckdns.org" | grep "$DUCKDNS_DOMAIN.duckdns.org.*text.*=.*" | sed -n 's/.*"\([^"]*\)".*/\1/p')"
echo "current txt record: $val"
test "$val" = "$CERTBOT_VALIDATION" && break
sleep 10
done
sleep "${DUCKDNS_PROPAGATION_DELAY:-0}"
test "$result" = 'OK'