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
Dim-P committed
Feb 2, 2023 at 14:48 UTC
161f51132dd83909d4a5652e3e2591d7282d47ed
2 files changed
+17
-8
packaging/installer/kickstart.sh
+16
-7
@@ -302,12 +302,21 @@ EOF
302
if command -v curl > /dev/null 2>&1; then
303
curl --silent -o /dev/null -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" "${TELEMETRY_URL}" > /dev/null
304
elif command -v wget > /dev/null 2>&1; then
305
- wget -q -O - --no-check-certificate \
306
- --method POST \
307
- --timeout=1 \
308
- --header 'Content-Type: application/json' \
309
- --body-data "${REQ_BODY}" \
310
- "${TELEMETRY_URL}" > /dev/null
305
+ if wget --help 2>&1 | grep BusyBox > /dev/null 2>&1; then
306
+ # BusyBox-compatible version of wget, there is no --no-check-certificate option
307
+ wget -q -O - \
308
+ -T 1 \
309
+ --header 'Content-Type: application/json' \
310
+ --post-data "${REQ_BODY}" \
311
+ "${TELEMETRY_URL}" > /dev/null
312
+ else
313
+ wget -q -O - --no-check-certificate \
314
+ --method POST \
315
+ --timeout=1 \
316
+ --header 'Content-Type: application/json' \
317
+ --body-data "${REQ_BODY}" \
318
+ "${TELEMETRY_URL}" > /dev/null
319
+ fi
320
fi
321
}
322
@@ -592,7 +601,7 @@ get_redirect() {
601
if command -v curl > /dev/null 2>&1; then
602
run sh -c "curl ${url} -s -L -I -o /dev/null -w '%{url_effective}' | grep -o '[^/]*$'" || return 1
603
elif command -v wget > /dev/null 2>&1; then
595
- run sh -c "wget --max-redirect=0 ${url} 2>&1 | grep Location | cut -d ' ' -f2 | grep -o '[^/]*$'" || return 1
604
+ run sh -c "wget -S -O /dev/null ${url} 2>&1 | grep -m 1 Location | grep -o '[^/]*$'" || return 1
605
else
606
fatal "${ERROR_F0003}" F0003
607
fi
packaging/installer/netdata-updater.sh
+1
-1
@@ -378,7 +378,7 @@ get_netdata_latest_tag() {
378
if command -v curl >/dev/null 2>&1; then
379
tag=$(curl "${url}" -s -L -I -o /dev/null -w '%{url_effective}' | grep -m 1 -o '[^/]*$')
380
elif command -v wget >/dev/null 2>&1; then
381
- tag=$(wget --max-redirect=0 "${url}" 2>&1 | grep Location | cut -d ' ' -f2 | grep -m 1 -o '[^/]*$')
381
+ tag=$(wget -S -O /dev/null "${url}" 2>&1 | grep -m 1 Location | grep -o '[^/]*$')
382
else
383
fatal "I need curl or wget to proceed, but neither of them are available on this system." U0006
384
fi