Better waiting for record updating.

This commit is contained in:
redxef 2020-10-29 23:30:49 +01:00
parent d5254e5e8f
commit 31998074fa
2 changed files with 10 additions and 6 deletions

View file

@ -1,9 +1,15 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -x echo "certbot txt record: $CERTBOT_VALIDATION" >&2
baseurl='https://www.duckdns.org/update?domains=%s&token=%s&txt=%s' 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 -)" result="$(printf "url=$baseurl\n" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" "$CERTBOT_VALIDATION" | curl -K -)"
# give some time for the record to update # give some time for the record to update
sleep 300 echo "waiting for txt record" >&2
for i in $(seq 0 60); do
val="$(dig -t txt redxef2.duckdns.org | grep -A 1 ';; ANSWER SECTION:' | tail -n1 | sed -n 's/.*"\([^"]*\)".*/\1/p')"
test "$val" = "$CERTBOT_VALIDATION" && break
sleep 10
done
test "$result" = 'OK' test "$result" = 'OK'

View file

@ -1,6 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -x baseurl='https://www.duckdns.org/update?domains=%s&token=%s&txt=&clear=True'
test "$(printf "url=$baseurl\n" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" | curl -K -)" = 'OK'
baseurl='https://www.duckdns.org/update?domains=%s&token=%s&txt=&clear=True%s'
test "$(printf "url=$baseurl\n" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" "$CERTBOT_VALIDATION" | curl -K -)" = 'OK'