@cryptotaxi247 / netdata-1 / commits / aa0255b75

updater: don't use api.github.com when checking for latest stable version (#11700)

Ilya Mashchenko committed Oct 22, 2021 at 09:44 UTC aa0255b75f750b9532158af4afb49c4b4c3eabfa
1 file changed +22 -3
packaging/installer/netdata-updater.sh
+22 -3
@@ -172,6 +172,26 @@ download() {
172 fi
173 }
174
175 +get_netdata_latest_tag() {
176 + local dest="${1}"
177 + local url="https://github.com/netdata/netdata/releases/latest"
178 + local tag
179 +
180 + if command -v curl >/dev/null 2>&1; then
181 + tag=$(curl "${url}" -s -L -I -o /dev/null -w '%{url_effective}' | grep -m 1 -o '[^/]*$')
182 + elif command -v wget >/dev/null 2>&1; then
183 + tag=$(wget --max-redirect=0 "${url}" 2>&1 | grep Location | cut -d ' ' -f2 | grep -m 1 -o '[^/]*$')
184 + else
185 + fatal "I need curl or wget to proceed, but neither of them are available on this system."
186 + fi
187 +
188 + if [[ ! $tag =~ ^v[0-9]+\..+ ]]; then
189 + fatal "Cannot download latest stable tag from ${url}"
190 + fi
191 +
192 + echo "${tag}" >"${dest}"
193 +}
194 +
195 newer_commit_date() {
196 echo >&3 "Checking if a newer version of the updater script is available."
197
@@ -237,7 +257,7 @@ parse_version() {
257
258 get_latest_version() {
259 if [ "${RELEASE_CHANNEL}" == "stable" ]; then
240 - download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4
260 + get_netdata_latest_tag /dev/stdout
261 else
262 download "$NETDATA_NIGHTLIES_BASEURL/latest-version.txt" /dev/stdout
263 fi
@@ -252,8 +272,7 @@ set_tarball_urls() {
272
273 if [ "$1" = "stable" ]; then
274 local latest
255 - # Simple version
256 - latest="$(download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4)"
275 + latest="$(get_netdata_latest_tag /dev/stdout)"
276 export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/netdata-$latest.${extension}"
277 export NETDATA_TARBALL_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/$latest/sha256sums.txt"
278 else