diff --git a/pkg/model/resources/nodeup.go b/pkg/model/resources/nodeup.go index a875d1cdb1..692eb5db20 100644 --- a/pkg/model/resources/nodeup.go +++ b/pkg/model/resources/nodeup.go @@ -66,9 +66,23 @@ download-or-bust() { for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then diff --git a/pkg/model/tests/data/bootstrapscript_0.txt b/pkg/model/tests/data/bootstrapscript_0.txt index 1f9a121a57..fba5c22233 100644 --- a/pkg/model/tests/data/bootstrapscript_0.txt +++ b/pkg/model/tests/data/bootstrapscript_0.txt @@ -69,9 +69,23 @@ download-or-bust() { for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then diff --git a/pkg/model/tests/data/bootstrapscript_1.txt b/pkg/model/tests/data/bootstrapscript_1.txt index 9c1ac5ec0c..6a94e73a31 100644 --- a/pkg/model/tests/data/bootstrapscript_1.txt +++ b/pkg/model/tests/data/bootstrapscript_1.txt @@ -69,9 +69,23 @@ download-or-bust() { for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then diff --git a/pkg/model/tests/data/bootstrapscript_2.txt b/pkg/model/tests/data/bootstrapscript_2.txt index 9c1ac5ec0c..6a94e73a31 100644 --- a/pkg/model/tests/data/bootstrapscript_2.txt +++ b/pkg/model/tests/data/bootstrapscript_2.txt @@ -69,9 +69,23 @@ download-or-bust() { for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then diff --git a/pkg/model/tests/data/bootstrapscript_3.txt b/pkg/model/tests/data/bootstrapscript_3.txt index 211dac1428..4d7de05b73 100644 --- a/pkg/model/tests/data/bootstrapscript_3.txt +++ b/pkg/model/tests/data/bootstrapscript_3.txt @@ -69,9 +69,23 @@ download-or-bust() { for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then diff --git a/pkg/model/tests/data/bootstrapscript_4.txt b/pkg/model/tests/data/bootstrapscript_4.txt index 005303f1d0..e66e28d423 100644 --- a/pkg/model/tests/data/bootstrapscript_4.txt +++ b/pkg/model/tests/data/bootstrapscript_4.txt @@ -69,9 +69,23 @@ download-or-bust() { for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then diff --git a/pkg/model/tests/data/bootstrapscript_5.txt b/pkg/model/tests/data/bootstrapscript_5.txt index 005303f1d0..e66e28d423 100644 --- a/pkg/model/tests/data/bootstrapscript_5.txt +++ b/pkg/model/tests/data/bootstrapscript_5.txt @@ -69,9 +69,23 @@ download-or-bust() { for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then diff --git a/tests/integration/minimal/cloudformation.json.extracted.yaml b/tests/integration/minimal/cloudformation.json.extracted.yaml index 2149589c20..9b23589014 100644 --- a/tests/integration/minimal/cloudformation.json.extracted.yaml +++ b/tests/integration/minimal/cloudformation.json.extracted.yaml @@ -49,9 +49,23 @@ Resources.AWSAutoScalingLaunchConfigurationmasterustest1amastersminimalexampleco for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then @@ -303,9 +317,23 @@ Resources.AWSAutoScalingLaunchConfigurationnodesminimalexamplecom.Properties.Use for url in "${urls[@]}"; do local file="${url##*/}" rm -f "${file}" - if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then - echo "== Failed to download ${url}. Retrying. ==" - elif [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then + + if [[ $(which curl) ]]; then + if ! curl -f --ipv4 -Lo "${file}" --connect-timeout 20 --retry 6 --retry-delay 10 "${url}"; then + echo "== Failed to curl ${url}. Retrying. ==" + break + fi + elif [[ $(which wget ) ]]; then + if ! wget --inet4-only -O "${file}" --connect-timeout=20 --tries=6 --wait=10 "${url}"; then + echo "== Failed to wget ${url}. Retrying. ==" + break + fi + else + echo "== Could not find curl or wget. Retrying. ==" + break + fi + + if [[ -n "${hash}" ]] && ! validate-hash "${file}" "${hash}"; then echo "== Hash validation of ${url} failed. Retrying. ==" else if [[ -n "${hash}" ]]; then