From 8c52b3a83410d87ecae990ab4335645696b78a73 Mon Sep 17 00:00:00 2001 From: redxef Date: Fri, 30 Oct 2020 11:58:53 +0100 Subject: [PATCH] Fixed timout and other stuff. --- certbot-auth | 9 ++++++--- certbot-duckdns | 13 ++++++++----- duckdns | 4 +--- start-certbot-duckdns.sh | 4 +--- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/certbot-auth b/certbot-auth index 7c7db8c..8c68680 100755 --- a/certbot-auth +++ b/certbot-auth @@ -1,16 +1,19 @@ #!/usr/bin/env sh -echo "certbot txt record: $CERTBOT_VALIDATION" >&2 +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 -)" # give some time for the record to update -echo "waiting for txt record" >&2 +echo "waiting for txt record" 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 "$val" >&2 + echo "current txt record: $val" test "$val" = "$CERTBOT_VALIDATION" && break sleep 10 done + +echo "waiting 60s for propagation" +sleep 60 test "$result" = 'OK' diff --git a/certbot-duckdns b/certbot-duckdns index 9526099..d265818 100755 --- a/certbot-duckdns +++ b/certbot-duckdns @@ -1,10 +1,13 @@ #!/usr/bin/env sh certbot certonly --manual --preferred-challenges dns-01 --keep \ - --email="$LE_EMAIL" --domains="$DUCKDNS_DOMAIN.duckdns.org,*.$DUCKDNS_DOMAIN.duckdns.org" \ + --email="$LE_EMAIL" --domains="$DUCKDNS_DOMAIN.duckdns.org" \ --agree-tos --no-eff-email --manual-public-ip-logging-ok \ - --manual-auth-hook=certbot-auth --manual-cleanup-hook=certbot-cleanup + --manual-auth-hook=certbot-auth --manual-cleanup-hook=certbot-cleanup \ + "$@" -logfile=/var/log/duckdns.log -baseurl='https://www.duckdns.org/update?domains=%s&token=%s&txt=%s' -printf "url=$baseurl\n" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" "$txt" | curl -o "$logfile" -K - +certbot certonly --manual --preferred-challenges dns-01 --keep \ + --email="$LE_EMAIL" --domains="*.$DUCKDNS_DOMAIN.duckdns.org" \ + --agree-tos --no-eff-email --manual-public-ip-logging-ok \ + --manual-auth-hook=certbot-auth --manual-cleanup-hook=certbot-cleanup \ + "$@" diff --git a/duckdns b/duckdns index 82c8db3..fab219e 100755 --- a/duckdns +++ b/duckdns @@ -1,7 +1,5 @@ #!/usr/bin/env sh -set -x - logfile=/var/log/duckdns.log -baseurl='https://www.duckdns.org/update?domains=%s&token=%s&ip=' +baseurl='https://www.duckdns.org/update?domains=%s&token=%s' printf "url=$baseurl\n" "$DUCKDNS_DOMAIN" "$DUCKDNS_TOKEN" | curl -o "$logfile" -K - diff --git a/start-certbot-duckdns.sh b/start-certbot-duckdns.sh index d095594..a4a0de9 100755 --- a/start-certbot-duckdns.sh +++ b/start-certbot-duckdns.sh @@ -1,13 +1,11 @@ #!/usr/bin/env sh -set -x - dhparamfile='/etc/letsencrypt/ssl-dhparams.pem' ssl_includefile='/etc/letsencrypt/options-ssl-nginx.conf' echo "Updating duckdns record" duckdns echo "Acquiering letsencrypt certificates" -certbot-duckdns +certbot-duckdns "$@" echo "Starting crond" exec crond -f