Advertisement
Guest User

Untitled

a guest
Oct 9th, 2019
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.70 KB | None | 0 0
  1. --- dehydrated.0.6.5    2019-10-09 10:47:26.300469301 +0200
  2. +++ dehydrated  2019-10-09 10:38:48.859796485 +0200
  3. @@ -154,7 +154,9 @@
  4.    DEHYDRATED_USER=
  5.    DEHYDRATED_GROUP=
  6.    API="auto"
  7. -
  8. +  HTTP_RETRY_COUNT="5"
  9. +  HTTP_RETRY_DELAY="1"
  10. +  
  11.    if [[ -z "${CONFIG:-}" ]]; then
  12.      echo "#" >&2
  13.      echo "# !! WARNING !! No main config file found, using default config!" >&2
  14. @@ -528,16 +530,46 @@
  15.    fi
  16.  
  17.    set +e
  18. -  if [[ "${1}" = "head" ]]; then
  19. -    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydrated/${VERSION} curl/${CURL_VERSION}" -s -w "%{http_code}" -o "${tempcont}" "${2}" -I)"
  20. -    curlret="${?}"
  21. -    touch "${tempheaders}"
  22. +  if [[ "${1}" = "head" ]] ; then
  23. +    while true ; do
  24. +      statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydrated/${VERSION} curl/${CURL_VERSION}" -s -w "%{http_code}" -o "${tempcont}" "${2}" -I)"
  25. +      curlret="${?}"
  26. +      touch "${tempheaders}"
  27. +      if [[ ! "${curlret}" = "0" ]]; then
  28. +        HTTP_RETRY_COUNT=$((HTTP_RETRY_COUNT-1))
  29. +   if [[ ! "${HTTP_RETRY_COUNT}" -lt "0" ]]; then
  30. +          sleep "$HTTP_RETRY_DELAY"
  31. +          continue
  32. +        fi
  33. +      fi
  34. +      break
  35. +    done
  36.    elif [[ "${1}" = "get" ]]; then
  37. -    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydrated/${VERSION} curl/${CURL_VERSION}" -L -s -w "%{http_code}" -o "${tempcont}" -D "${tempheaders}" "${2}")"
  38. -    curlret="${?}"
  39. +    while true ; do
  40. +      statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydrated/${VERSION} curl/${CURL_VERSION}" -L -s -w "%{http_code}" -o "${tempcont}" -D "${tempheaders}" "${2}")"
  41. +      curlret="${?}"
  42. +      if [[ ! "${curlret}" = "0" ]]; then
  43. +        HTTP_RETRY_COUNT=$((HTTP_RETRY_COUNT-1))
  44. +        if [[ ! "${HTTP_RETRY_COUNT}" -lt "0" ]]; then
  45. +     sleep "$HTTP_RETRY_DELAY"
  46. +          continue
  47. +        fi
  48. +      fi
  49. +      break
  50. +    done
  51.    elif [[ "${1}" = "post" ]]; then
  52. -    statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydrated/${VERSION} curl/${CURL_VERSION}" -s -w "%{http_code}" -o "${tempcont}" "${2}" -D "${tempheaders}" -H 'Content-Type: application/jose+json' -d "${3}")"
  53. -    curlret="${?}"
  54. +    while true ; do
  55. +      statuscode="$(curl ${ip_version:-} ${CURL_OPTS} -A "dehydrated/${VERSION} curl/${CURL_VERSION}" -s -w "%{http_code}" -o "${tempcont}" "${2}" -D "${tempheaders}" -H 'Content-Type: application/jose+json' -d "${3}")"
  56. +      curlret="${?}"
  57. +        if [[ ! "${curlret}" = "0" ]]; then
  58. +         HTTP_RETRY_COUNT=$((HTTP_RETRY_COUNT-1))
  59. +     if [[ ! "${HTTP_RETRY_COUNT}" -lt "0" ]]; then
  60. +            sleep "$HTTP_RETRY_DELAY"
  61. +            continue
  62. +          fi
  63. +   fi
  64. +        break
  65. +    done
  66.    else
  67.      set -e
  68.      _exiterr "Unknown request method: ${1}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement