@cryptotaxi247 / netdata-1 / commits / f666397f8

netdata/packaging/updater: fix updater (#5785)

Paul Emm. Katsoulakis committed Apr 3, 2019 at 09:59 UTC f666397f807c7f4df7b2caecaf93e69dddff7b27
1 file changed +13 -1
packaging/installer/netdata-updater.sh
+13 -1
@@ -20,6 +20,18 @@ error() {
20 echo >&3 "$(date) : ERROR: " "${@}"
21 }
22
23 +function safe_sha256sum() {
24 + # Within the contexct of the installer, we only use -c option that is common between the two commands
25 + # We will have to reconsider if we start non-common options
26 + if command -v sha256sum >/dev/null 2>&1; then
27 + sha256sum $@
28 + elif command -v shasum >/dev/null 2>&1; then
29 + shasum -a 256 $@
30 + else
31 + fatal "I could not find a suitable checksum binary to use"
32 + fi
33 +}
34 +
35 # this is what we will do if it fails (head-less only)
36 fatal() {
37 error "FAILED TO UPDATE NETDATA : ${1}"
@@ -80,7 +92,7 @@ update() {
92 else
93 download "${NETDATA_TARBALL_URL}" "${dir}/netdata-latest.tar.gz"
94 if ! grep netdata-latest.tar.gz sha256sum.txt | safe_sha256sum -c - >&3 2>&3; then
83 - failed "Tarball checksum validation failed. Stopping netdata upgrade and leaving tarball in ${dir}"
95 + fatal "Tarball checksum validation failed. Stopping netdata upgrade and leaving tarball in ${dir}"
96 fi
97 NEW_CHECKSUM="$(safe_sha256sum netdata-latest.tar.gz 2>/dev/null| cut -d' ' -f1)"
98 tar -xf netdata-latest.tar.gz >&3 2>&3