Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. set -x
  3. TIMEOUT=600
  4. INTERVAL=10
  5. NAMESERVERS=("NS1.TRANSIP.NL" "NS0.TRANSIP.NET" "NS2.TRANSIP.EU")
  6.  
  7.  
  8. wait_until_response() {
  9. timer=0
  10. while [ $timer -lt $TIMEOUT ]; do
  11. ok_response=0
  12. for NS in ${NAMESERVERS[@]}; do
  13. dig_output=$(dig +short _acme-challenge.${CERTBOT_DOMAIN} TXT @${NS})
  14. [[ ${dig_output} == \"${CERTBOT_VALIDATION}\" ]] && ok_response=$((ok_response+1))
  15. done
  16. [[ ${ok_response} -eq ${#NAMESERVERS[@]} ]] && return 0
  17. timer=$((timer+$INTERVAL))
  18. sleep $INTERVAL
  19. done
  20. echo TIMEOUT
  21. exit 255
  22. }
  23.  
  24.  
  25.  
  26. lexicon --config-dir /etc/lexicon transip \
  27. "$1" "${CERTBOT_DOMAIN}" TXT \
  28. --name "_acme-challenge.${CERTBOT_DOMAIN}" \
  29. --content "${CERTBOT_VALIDATION}" || exit 255
  30.  
  31. if [ "$1" == "create" ]; then
  32. wait_until_response
  33. fi
  34.  
  35. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement