@cryptotaxi247 / netdata-1 / commits / 2637740ff

netdata/packaging/installer: fix sha256sum failure on freeBSD (#5760)

* netdata/packaging/installer: Introduce safe_sha256sum - a more flexible checsum function Due to #5747 we discovered that our installer wasnt working properly on FreeBSD. We created within our functions lib a safe_sha256sum that picks between sha256sum and shasum, with priority to the first method * netdata/packaging/installer: Update checksums in README

Paul Emm. Katsoulakis committed Apr 1, 2019 at 18:25 UTC 2637740ff30669ec78d175d7d0d18294e07003f7
6 files changed +20 -7
netdata-installer.sh
+1 -1
@@ -775,7 +775,7 @@ install_go() {
775 grep "config.tar.gz" "${INSTALLER_DIR}/packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2>/dev/null
776
777 # Checksum validation
778 - if ! (cd "${tmp}" && sha256sum -c "sha256sums.txt"); then
778 + if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
779 run_failed "go.d.plugin package files checksum validation failed."
780 return 1
781 fi
packaging/installer/README.md
+2 -2
@@ -42,7 +42,7 @@ bash <(curl -Ss https://my-netdata.io/kickstart.sh)
42 Verify the integrity of the script with this:
43
44 ```bash
45 -[ "e051d1baed4c69653b5d3e4588696466" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
45 +[ "dec269c623667e132b4b179b9b77fcaf" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
46 ```
47 *It should print `OK, VALID` if the script is the one we ship.*
48
@@ -96,7 +96,7 @@ To install Netdata with a binary package on any Linux distro, any kernel version
96 Verify the integrity of the script with this:
97
98 ```bash
99 -[ "8e6df9b6f6cc7de0d73f6e5e51a3c8c2" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
99 +[ "9f5e63e50ec4322f65064b446cff8dc5" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
100 ```
101
102 *It should print `OK, VALID` if the script is the one we ship.*
packaging/installer/functions.sh
+13
@@ -678,3 +678,16 @@ portable_add_user_to_group() {
678 return 1
679 fi
680 }
681 +
682 +
683 +function safe_sha256sum() {
684 + # Within the contexct of the installer, we only use -c option that is common between the two commands
685 + # We will have to reconsider if we start non-common options
686 + if command -v sha256sum >/dev/null 2>&1; then
687 + sha256sum $@
688 + elif command -v shasum >/dev/null 2>&1; then
689 + shasum -a 256 $@
690 + else
691 + fatal "I could not find a suitable checksum binary to use"
692 + fi
693 +}
packaging/installer/kickstart-static64.sh
+1 -1
@@ -157,7 +157,7 @@ progress "Downloading static netdata binary: ${NETDATA_TARBALL_URL}"
157
158 download "${NETDATA_TARBALL_CHECKSUM_URL}" "${TMPDIR}/sha256sum.txt"
159 download "${NETDATA_TARBALL_URL}" "${TMPDIR}/netdata-latest.gz.run"
160 -if ! grep netdata-latest.gz.run "${TMPDIR}/sha256sum.txt" | sha256sum --check - >/dev/null 2>&1; then
160 +if ! grep netdata-latest.gz.run "${TMPDIR}/sha256sum.txt" | safe_sha256sum -c - >/dev/null 2>&1; then
161 fatal "Static binary checksum validation failed. Stopping netdata installation and leaving binary in ${TMPDIR}"
162 fi
163
packaging/installer/kickstart.sh
+1 -1
@@ -275,7 +275,7 @@ set_tarball_urls "${RELEASE_CHANNEL}"
275
276 download "${NETDATA_TARBALL_CHECKSUM_URL}" "${TMPDIR}/sha256sum.txt"
277 download "${NETDATA_TARBALL_URL}" "${TMPDIR}/netdata-latest.tar.gz"
278 -if ! grep netdata-latest.tar.gz "${TMPDIR}/sha256sum.txt" | sha256sum --check - >/dev/null 2>&1; then
278 +if ! grep netdata-latest.tar.gz "${TMPDIR}/sha256sum.txt" | safe_sha256sum -c - >/dev/null 2>&1; then
279 fatal "Tarball checksum validation failed. Stopping netdata installation and leaving tarball in ${TMPDIR}"
280 fi
281 run tar -xf netdata-latest.tar.gz
packaging/installer/netdata-updater.sh
+2 -2
@@ -79,10 +79,10 @@ update() {
79 info "Newest version is already installed"
80 else
81 download "${NETDATA_TARBALL_URL}" "${dir}/netdata-latest.tar.gz"
82 - if ! grep netdata-latest.tar.gz sha256sum.txt | sha256sum --check - >&3 2>&3; then
82 + 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}"
84 fi
85 - NEW_CHECKSUM="$(sha256sum netdata-latest.tar.gz 2>/dev/null| cut -d' ' -f1)"
85 + NEW_CHECKSUM="$(safe_sha256sum netdata-latest.tar.gz 2>/dev/null| cut -d' ' -f1)"
86 tar -xf netdata-latest.tar.gz >&3 2>&3
87 rm netdata-latest.tar.gz >&3 2>&3
88 cd netdata-*