@cryptotaxi247 / netdata-1 / commits / 3c91cb006

Use temporary file for commit date check. (#18646)

Austin S. Hemmelgarn committed Oct 1, 2024 at 06:50 UTC 3c91cb00664d5ab1a2458df465734e9f9a7a57b5
1 file changed +7 -3
packaging/installer/netdata-updater.sh
+7 -3
@@ -532,6 +532,8 @@ get_netdata_latest_tag() {
532 newer_commit_date() {
533 info "Checking if a newer version of the updater script is available."
534
535 + ndtmpdir="$(create_tmp_directory)"
536 + commit_check_file="${ndtmpdir}/latest-commit.json"
537 commit_check_url="https://api.github.com/repos/netdata/netdata/commits?path=packaging%2Finstaller%2Fnetdata-updater.sh&page=1&per_page=1"
538 python_version_check="
539 from __future__ import print_function
@@ -545,12 +547,14 @@ else:
547 print(data[0]['commit']['committer']['date'] if isinstance(data, list) and data else '')
548 "
549
550 + _safe_download "${commit_check_url}" "${commit_check_file}"
551 +
552 if command -v jq > /dev/null 2>&1; then
549 - commit_date="$(_safe_download "${commit_check_url}" /dev/stdout | jq '.[0].commit.committer.date' 2>/dev/null | tr -d '"')"
553 + commit_date="$(jq '.[0].commit.committer.date' 2>/dev/null < "${commit_check_file}" | tr -d '"')"
554 elif command -v python > /dev/null 2>&1;then
551 - commit_date="$(_safe_download "${commit_check_url}" /dev/stdout | python -c "${python_version_check}")"
555 + commit_date="$(python -c "${python_version_check}" < "${commit_check_file}")"
556 elif command -v python3 > /dev/null 2>&1;then
553 - commit_date="$(_safe_download "${commit_check_url}" /dev/stdout | python3 -c "${python_version_check}")"
557 + commit_date="$(python3 -c "${python_version_check}" < "${commit_check_file}")"
558 fi
559
560 if [ -z "${commit_date}" ] ; then