Add env variable to specify propagation delay.

This commit is contained in:
redxef 2024-01-16 18:08:21 +01:00
parent 4d6fc272ac
commit 4aa03ad93d
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
4 changed files with 6 additions and 4 deletions

View file

@ -30,6 +30,7 @@ under the following locations respectively:
- DUCKDNS_DOMAIN: The domain to update, ex: DUCKDNS_DOMAIN=redxef for redxef.duckdns.org - DUCKDNS_DOMAIN: The domain to update, ex: DUCKDNS_DOMAIN=redxef for redxef.duckdns.org
- DUCKDNS_TOKEN: Your duckdns api token - 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 - LE_EMAIL: Your email for certificate related notifications
## SOURCE ## SOURCE

View file

@ -3,15 +3,16 @@
echo "certbot txt record: $CERTBOT_VALIDATION" echo "certbot txt record: $CERTBOT_VALIDATION"
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=%s\n' "$baseurl" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" "$CERTBOT_VALIDATION" | curl -K -)"
# give some time for the record to update # give some time for the record to update
echo "waiting for txt record" 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')" val="$(nslookup -type=TXT "$DUCKDNS_DOMAIN.duckdns.org" | grep "$DUCKDNS_DOMAIN.duckdns.org.*text.*=.*" | sed -n 's/.*"\([^"]*\)".*/\1/p')"
echo "current txt record: $val" echo "current txt record: $val"
test "$val" = "$CERTBOT_VALIDATION" && break test "$val" = "$CERTBOT_VALIDATION" && break
sleep 10 sleep 10
done done
sleep "${DUCKDNS_PROPAGATION_DELAY:-0}"
test "$result" = 'OK' test "$result" = 'OK'

View file

@ -1,4 +1,4 @@
#!/usr/bin/env sh #!/usr/bin/env sh
baseurl='https://www.duckdns.org/update?domains=%s&token=%s&txt=&clear=True' 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'

View file

@ -2,4 +2,4 @@
logfile=/var/log/duckdns.log logfile=/var/log/duckdns.log
baseurl='https://www.duckdns.org/update?domains=%s&token=%s' 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 -