diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-04-26 16:22:17 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-04-26 16:22:17 +0000 |
commit | 58b482856cf37b0519e516ab8dc1105ba958f8b2 (patch) | |
tree | 0c46396e98741dfae4ce907bc8ef8c54418b3753 /packaging/installer/netdata-updater.sh | |
parent | Adding upstream version 1.14.0~rc0. (diff) | |
download | netdata-58b482856cf37b0519e516ab8dc1105ba958f8b2.tar.xz netdata-58b482856cf37b0519e516ab8dc1105ba958f8b2.zip |
Adding upstream version 1.14.0.upstream/1.14.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/installer/netdata-updater.sh')
-rw-r--r-- | packaging/installer/netdata-updater.sh | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index 071198dd..56c83795 100644 --- a/packaging/installer/netdata-updater.sh +++ b/packaging/installer/netdata-updater.sh @@ -20,6 +20,18 @@ error() { echo >&3 "$(date) : ERROR: " "${@}" } +safe_sha256sum() { + # Within the contexct of the installer, we only use -c option that is common between the two commands + # We will have to reconsider if we start non-common options + if command -v sha256sum >/dev/null 2>&1; then + sha256sum $@ + elif command -v shasum >/dev/null 2>&1; then + shasum -a 256 $@ + else + fatal "I could not find a suitable checksum binary to use" + fi +} + # this is what we will do if it fails (head-less only) fatal() { error "FAILED TO UPDATE NETDATA : ${1}" @@ -79,10 +91,10 @@ update() { info "Newest version is already installed" else download "${NETDATA_TARBALL_URL}" "${dir}/netdata-latest.tar.gz" - if ! grep netdata-latest.tar.gz sha256sum.txt | sha256sum --check - >&3 2>&3; then - failed "Tarball checksum validation failed. Stopping netdata upgrade and leaving tarball in ${dir}" + if ! grep netdata-latest.tar.gz sha256sum.txt | safe_sha256sum -c - >&3 2>&3; then + fatal "Tarball checksum validation failed. Stopping netdata upgrade and leaving tarball in ${dir}" fi - NEW_CHECKSUM="$(sha256sum netdata-latest.tar.gz 2>/dev/null| cut -d' ' -f1)" + NEW_CHECKSUM="$(safe_sha256sum netdata-latest.tar.gz 2>/dev/null| cut -d' ' -f1)" tar -xf netdata-latest.tar.gz >&3 2>&3 rm netdata-latest.tar.gz >&3 2>&3 cd netdata-* |