diff options
author | Austin S. Hemmelgarn <austin@netdata.cloud> | 2023-02-15 07:20:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-15 07:20:01 -0500 |
commit | b333c6ffdee2ff9f9ee835e36dbe99e83605e8da (patch) | |
tree | 2d00419853e8d4e4ee230944e9c25b8e6dd6229d /packaging/installer/functions.sh | |
parent | 568cda1978cabe8a338c118682a85c56720d5698 (diff) |
Use curl from static builds if no system-wide copy exists. (#14403)
Instead of immediately falling back to wget, try using curl from a
static build if it is installed. This provides better behavior in a
number of cases and also makes the static builds more self-contained
(and makes the static builds a bit more self-contained).
Diffstat (limited to 'packaging/installer/functions.sh')
-rw-r--r-- | packaging/installer/functions.sh | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh index ebb4aab75a..3efaca528d 100644 --- a/packaging/installer/functions.sh +++ b/packaging/installer/functions.sh @@ -95,10 +95,19 @@ progress() { echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- " } +check_for_curl() { + if [ -z "${curl}" ]; then + curl="$(PATH="${PATH}:/opt/netdata/bin" command -v curl 2>/dev/null && true)" + fi +} + get() { url="${1}" - if command -v curl > /dev/null 2>&1; then - curl -q -o - -sSL --connect-timeout 10 --retry 3 "${url}" + + check_for_curl + + if [ -n "${curl}" ]; then + "${curl}" -q -o - -sSL --connect-timeout 10 --retry 3 "${url}" elif command -v wget > /dev/null 2>&1; then wget -T 15 -O - "${url}" else @@ -112,8 +121,10 @@ download_file() { name="${3}" opt="${4}" - if command -v curl > /dev/null 2>&1; then - run curl -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}" + check_for_curl + + if [ -n "${curl}" ]; then + run "${curl}" -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}" elif command -v wget > /dev/null 2>&1; then run wget -T 15 -O "${dest}" "${url}" else @@ -873,8 +884,10 @@ create_netdata_conf() { export http_proxy= export https_proxy= - if command -v curl 1> /dev/null 2>&1; then - run curl -sSL --connect-timeout 10 --retry 3 "${url}" > "${path}.new" + check_for_curl + + if [ -n "${curl}" ]; then + run "${curl}" -sSL --connect-timeout 10 --retry 3 "${url}" > "${path}.new" elif command -v wget 1> /dev/null 2>&1; then run wget -T 15 -O - "${url}" > "${path}.new" fi |