Fix kickstart and updater not working with BusyBox wget (#14392)

* Fix kickstart.sh failing when using busybox wget

* Add a BusyBox compatible wget alternative in telemetry_event()

* Fix netdata-updater.sh wget to work with BusyBox
This commit is contained in:
Dim-P 2023-02-02 14:48:04 +00:00 committed by GitHub
parent cf8881b91e
commit 161f51132d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 8 deletions

View File

@ -302,12 +302,21 @@ EOF
if command -v curl > /dev/null 2>&1; then
curl --silent -o /dev/null -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" "${TELEMETRY_URL}" > /dev/null
elif command -v wget > /dev/null 2>&1; then
wget -q -O - --no-check-certificate \
--method POST \
--timeout=1 \
--header 'Content-Type: application/json' \
--body-data "${REQ_BODY}" \
"${TELEMETRY_URL}" > /dev/null
if wget --help 2>&1 | grep BusyBox > /dev/null 2>&1; then
# BusyBox-compatible version of wget, there is no --no-check-certificate option
wget -q -O - \
-T 1 \
--header 'Content-Type: application/json' \
--post-data "${REQ_BODY}" \
"${TELEMETRY_URL}" > /dev/null
else
wget -q -O - --no-check-certificate \
--method POST \
--timeout=1 \
--header 'Content-Type: application/json' \
--body-data "${REQ_BODY}" \
"${TELEMETRY_URL}" > /dev/null
fi
fi
}
@ -592,7 +601,7 @@ get_redirect() {
if command -v curl > /dev/null 2>&1; then
run sh -c "curl ${url} -s -L -I -o /dev/null -w '%{url_effective}' | grep -o '[^/]*$'" || return 1
elif command -v wget > /dev/null 2>&1; then
run sh -c "wget --max-redirect=0 ${url} 2>&1 | grep Location | cut -d ' ' -f2 | grep -o '[^/]*$'" || return 1
run sh -c "wget -S -O /dev/null ${url} 2>&1 | grep -m 1 Location | grep -o '[^/]*$'" || return 1
else
fatal "${ERROR_F0003}" F0003
fi

View File

@ -378,7 +378,7 @@ get_netdata_latest_tag() {
if command -v curl >/dev/null 2>&1; then
tag=$(curl "${url}" -s -L -I -o /dev/null -w '%{url_effective}' | grep -m 1 -o '[^/]*$')
elif command -v wget >/dev/null 2>&1; then
tag=$(wget --max-redirect=0 "${url}" 2>&1 | grep Location | cut -d ' ' -f2 | grep -m 1 -o '[^/]*$')
tag=$(wget -S -O /dev/null "${url}" 2>&1 | grep -m 1 Location | grep -o '[^/]*$')
else
fatal "I need curl or wget to proceed, but neither of them are available on this system." U0006
fi