Skip to content

Commit

Permalink
Avoid using which, CoreOS doesn't always have it
Browse files Browse the repository at this point in the history
We just try executing `curl --version` instead, and fall back to wget.
We can't use `wget --version` because busybox wget doesn't support
`--version`.
  • Loading branch information
justinsb committed Sep 21, 2018
1 parent d32a2c6 commit 8a483c1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions pkg/model/resources/nodeup.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ download-or-bust() {
if [[ -e "${file}" ]]; then
echo "== File exists for ${url} =="
elif [[ $(which curl) ]]; then
# CoreOS runs this script in a container without which (but has curl)
# Note also that busybox wget doesn't support wget --version, but busybox doesn't normally have curl
# So we default to wget unless we see curl
elif [[ $(curl --version) ]]; 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
else
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
Expand Down

0 comments on commit 8a483c1

Please sign in to comment.