From 31998074fa71472785e70bbaed0659d7f31a886e Mon Sep 17 00:00:00 2001 From: redxef Date: Thu, 29 Oct 2020 23:30:49 +0100 Subject: [PATCH] Better waiting for record updating. --- certbot-auth | 10 ++++++++-- certbot-cleanup | 6 ++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/certbot-auth b/certbot-auth index 728a071..2e8fd52 100755 --- a/certbot-auth +++ b/certbot-auth @@ -1,9 +1,15 @@ #!/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' result="$(printf "url=$baseurl\n" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" "$CERTBOT_VALIDATION" | curl -K -)" + # 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' diff --git a/certbot-cleanup b/certbot-cleanup index 63c8fd0..3e36536 100755 --- a/certbot-cleanup +++ b/certbot-cleanup @@ -1,6 +1,4 @@ #!/usr/bin/env sh -set -x - -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' +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'