summaryrefslogtreecommitdiffstats
path: root/packaging/installer/netdata-updater.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/installer/netdata-updater.sh')
-rw-r--r--packaging/installer/netdata-updater.sh18
1 files changed, 15 insertions, 3 deletions
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh
index 071198dd6..56c837953 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-*