certbot-duckdns/certbot-auth

19 lines
654 B
Text
Raw Normal View History

2020-10-29 16:38:49 +01:00
#!/usr/bin/env sh
2020-10-30 11:58:53 +01:00
echo "certbot txt record: $CERTBOT_VALIDATION"
2020-10-29 16:38:49 +01:00
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 -)"
2020-10-29 23:30:49 +01:00
2020-10-29 16:38:49 +01:00
# give some time for the record to update
2020-10-30 11:58:53 +01:00
echo "waiting for txt record"
for _i in $(seq 0 60); do
2020-10-29 23:58:52 +01:00
val="$(nslookup -type=TXT "$DUCKDNS_DOMAIN.duckdns.org" | grep "$DUCKDNS_DOMAIN.duckdns.org.*text.*=.*" | sed -n 's/.*"\([^"]*\)".*/\1/p')"
2020-10-30 11:58:53 +01:00
echo "current txt record: $val"
2020-10-29 23:30:49 +01:00
test "$val" = "$CERTBOT_VALIDATION" && break
sleep 10
done
sleep "${DUCKDNS_PROPAGATION_DELAY:-0}"
2020-10-30 11:58:53 +01:00
2020-10-29 16:38:49 +01:00
test "$result" = 'OK'