@cryptotaxi247 / netdata-1 / commits / 81a3feae6

fix(updater): don't produce output when static update succeeded (#11879)

Ilya Mashchenko committed Dec 9, 2021 at 16:51 UTC 81a3feae6f838e4ff415fa6e411c569e5db7b932
1 file changed +11 -11
packaging/installer/netdata-updater.sh
+11 -11
@@ -123,9 +123,7 @@ create_tmp_directory() {
123 if [ -z "${TMPDIR}" ] || _cannot_use_tmpdir "${TMPDIR}" ; then
124 if _cannot_use_tmpdir /tmp ; then
125 if _cannot_use_tmpdir "${PWD}" ; then
126 - echo >&2
127 - echo >&2 "Unable to find a usable temporary directory. Please set \$TMPDIR to a path that is both writable and allows execution of files and try again."
128 - exit 1
126 + fatal "Unable to find a usable temporary directory. Please set \$TMPDIR to a path that is both writable and allows execution of files and try again."
127 else
128 TMPDIR="${PWD}"
129 fi
@@ -191,7 +189,7 @@ get_netdata_latest_tag() {
189 }
190
191 newer_commit_date() {
194 - echo >&3 "Checking if a newer version of the updater script is available."
192 + info "Checking if a newer version of the updater script is available."
193
194 if command -v jq > /dev/null 2>&1; then
195 commit_date="$(_safe_download "https://api.github.com/repos/netdata/netdata/commits?path=packaging%2Finstaller%2Fnetdata-updater.sh&page=1&per_page=1" /dev/stdout | jq '.[0].commit.committer.date' | tr -d '"')"
@@ -216,7 +214,7 @@ newer_commit_date() {
214
215 self_update() {
216 if [ -z "${NETDATA_NO_UPDATER_SELF_UPDATE}" ] && newer_commit_date; then
219 - echo >&3 "Downloading newest version of updater script."
217 + info "Downloading newest version of updater script."
218
219 ndtmpdir=$(create_tmp_directory)
220 cd "$ndtmpdir" || exit 1
@@ -226,7 +224,7 @@ self_update() {
224 export ENVIRONMENT_FILE="${ENVIRONMENT_FILE}"
225 exec ./netdata-updater.sh --not-running-from-cron --no-updater-self-update --tmpdir-path "$(pwd)"
226 else
229 - echo >&3 "Failed to download newest version of updater script, continuing with current version."
227 + error "Failed to download newest version of updater script, continuing with current version."
228 fi
229 fi
230 }
@@ -437,7 +435,7 @@ if [ "${IS_NETDATA_STATIC_BINARY}" = "yes" ]; then
435 ndtmpdir="$(create_tmp_directory)"
436 PREVDIR="$(pwd)"
437
440 - echo >&2 "Entering ${ndtmpdir}"
438 + info "Entering ${ndtmpdir}"
439 cd "${ndtmpdir}" || exit 1
440
441 download "${NETDATA_TARBALL_CHECKSUM_URL}" "${ndtmpdir}/sha256sum.txt"
@@ -454,18 +452,20 @@ if [ "${IS_NETDATA_STATIC_BINARY}" = "yes" ]; then
452
453 # Do not pass any options other than the accept, for now
454 # shellcheck disable=SC2086
457 - if sh "${ndtmpdir}/netdata-latest.gz.run" --accept -- ${REINSTALL_OPTIONS}; then
458 - rm -r "${ndtmpdir}"
455 + if sh "${ndtmpdir}/netdata-latest.gz.run" --accept -- ${REINSTALL_OPTIONS} >&3 2>&3; then
456 + rm -rf "${ndtmpdir}" >&3 2>&3
457 else
460 - echo >&2 "NOTE: did not remove: ${ndtmpdir}"
458 + info "NOTE: did not remove: ${ndtmpdir}"
459 fi
460
461 echo "${install_type}" > /opt/netdata/etc/netdata/.install-type
462
463 if [ -e "${PREVDIR}" ]; then
466 - echo >&2 "Switching back to ${PREVDIR}"
464 + info "Switching back to ${PREVDIR}"
465 cd "${PREVDIR}"
466 fi
467 + [ -n "${logfile}" ] && rm "${logfile}" && logfile=
468 + exit 0
469 else
470 # the installer updates this script - so we run and exit in a single line
471 update && exit 0