@cryptotaxi247 / netdata-1 / commits / 59f919946

Handle cases when go.d plugin can't be downloaded (no connection to internet) (#5457)

Add timeouts and retries to wget and curl. Handle errors without showing duplicate FAILED messages. Remove calls to `fatal` which wasn't defined anyway. This means we can proceed without the go.d plugin

Chris Akritidis committed Feb 21, 2019 at 12:44 UTC 59f919946a6332de902909d649dfb74f04c9a23f
1 file changed +14 -4
netdata-installer.sh
+14 -4
@@ -45,14 +45,14 @@ download() {
45 dest="${2}"
46 if command -v wget >/dev/null 2>&1; then
47 if [ -t 1 ]; then
48 - run wget -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
48 + run wget --timeout=5 --tries=3 -O - "${url}" >"${dest}"
49 else
50 - run wget --progress=dot:mega -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
50 + run wget --timeout=5 --tries=3 --progress=dot:mega -O - "${url}" >"${dest}"
51 fi
52 elif command -v curl >/dev/null 2>&1; then
53 - run curl -L "${url}" >"${dest}" || fatal "Cannot download ${url}"
53 + run curl -L --connect-timeout 10 --retry 3 "${url}" >"${dest}"
54 else
55 - fatal "I need curl or wget to proceed, but neither is available on this system."
55 + echo >&2 "I need curl or wget to proceed, but neither is available on this system."
56 fi
57 }
58
@@ -814,8 +814,18 @@ install_go() {
814 done
815 tmp=$(mktemp -d /tmp/netdata-go-XXXXXX)
816 GO_PACKAGE_BASENAME="go.d.plugin-$GO_PACKAGE_VERSION.$OS-$ARCH"
817 +
818 download "https://github.com/netdata/go.d.plugin/releases/download/$GO_PACKAGE_VERSION/$GO_PACKAGE_BASENAME" "${tmp}/$GO_PACKAGE_BASENAME"
819 + if [ $? ] ; then
820 + echo >&2 "go.d.plugin package could not be downloaded"
821 + return 1
822 + fi
823 +
824 download "https://github.com/netdata/go.d.plugin/releases/download/$GO_PACKAGE_VERSION/config.tar.gz" "${tmp}/config.tar.gz"
825 + if [ $? ] ; then
826 + echo >&2 "go.d.plugin config could not be downloaded"
827 + return 1
828 + fi
829 grep "${GO_PACKAGE_BASENAME}" "${installer_dir}/packaging/go.d.checksums" > "${tmp}/sha256sums.txt" 2>/dev/null
830 grep "config.tar.gz" "${installer_dir}/packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2>/dev/null
831