From 4aa03ad93d0edbc0c573978682f4864982ebd20e Mon Sep 17 00:00:00 2001 From: redxef Date: Tue, 16 Jan 2024 18:08:21 +0100 Subject: [PATCH] Add env variable to specify propagation delay. --- README.md | 1 + certbot-auth | 5 +++-- certbot-cleanup | 2 +- duckdns | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 569ce87..6171967 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ under the following locations respectively: - DUCKDNS_DOMAIN: The domain to update, ex: DUCKDNS_DOMAIN=redxef for redxef.duckdns.org - DUCKDNS_TOKEN: Your duckdns api token +- DUCKDNS_PROPAGATION_DELAY: Wait this many seconds after the TXT record was updated - LE_EMAIL: Your email for certificate related notifications ## SOURCE diff --git a/certbot-auth b/certbot-auth index e5605cd..5b8c94a 100755 --- a/certbot-auth +++ b/certbot-auth @@ -3,15 +3,16 @@ echo "certbot txt record: $CERTBOT_VALIDATION" 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=%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 +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' diff --git a/certbot-cleanup b/certbot-cleanup index 3e36536..54b3a5b 100755 --- a/certbot-cleanup +++ b/certbot-cleanup @@ -1,4 +1,4 @@ #!/usr/bin/env sh 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' +test "$(printf "url=%s\n" "$baseurl" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" | curl -K -)" = 'OK' diff --git a/duckdns b/duckdns index fab219e..e4a8b8f 100755 --- a/duckdns +++ b/duckdns @@ -2,4 +2,4 @@ logfile=/var/log/duckdns.log baseurl='https://www.duckdns.org/update?domains=%s&token=%s' -printf "url=$baseurl\n" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" | curl -o "$logfile" -K - +printf 'url=%s\n' "$baseurl" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" | curl -o "$logfile" -K -