certbot-duckdns/certbot-auth

17 lines
599 B
Text
Raw Normal View History

2020-10-29 16:38:49 +01:00
#!/usr/bin/env sh
2020-10-29 23:30:49 +01:00
echo "certbot txt record: $CERTBOT_VALIDATION" >&2
2020-10-29 16:38:49 +01:00
baseurl='https://www.duckdns.org/update?domains=%s&token=%s&txt=%s'
result="$(printf "url=$baseurl\n" "$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-29 23:30:49 +01:00
echo "waiting for txt record" >&2
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')"
echo "$val" >&2
2020-10-29 23:30:49 +01:00
test "$val" = "$CERTBOT_VALIDATION" && break
sleep 10
done
2020-10-29 16:38:49 +01:00
test "$result" = 'OK'