diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-12-01 06:15:04 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-12-01 06:15:04 +0000 |
commit | e970e0b37b8bd7f246feb3f70c4136418225e434 (patch) | |
tree | 0b67c0ca45f56f2f9d9c5c2e725279ecdf52d2eb /packaging/installer/netdata-updater.sh | |
parent | Adding upstream version 1.31.0. (diff) | |
download | netdata-e970e0b37b8bd7f246feb3f70c4136418225e434.tar.xz netdata-e970e0b37b8bd7f246feb3f70c4136418225e434.zip |
Adding upstream version 1.32.0.upstream/1.32.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/installer/netdata-updater.sh')
-rwxr-xr-x | packaging/installer/netdata-updater.sh | 50 |
1 files changed, 44 insertions, 6 deletions
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index ad741225..59c5fab1 100755 --- a/packaging/installer/netdata-updater.sh +++ b/packaging/installer/netdata-updater.sh @@ -6,13 +6,15 @@ # - PATH # - CFLAGS # - LDFLAGS +# - MAKEOPTS # - IS_NETDATA_STATIC_BINARY # - NETDATA_CONFIGURE_OPTIONS # - REINSTALL_OPTIONS # - NETDATA_TARBALL_URL # - NETDATA_TARBALL_CHECKSUM_URL # - NETDATA_TARBALL_CHECKSUM -# - NETDATA_PREFIX / NETDATA_LIB_DIR (After 1.16.1 we will only depend on lib dir) +# - NETDATA_PREFIX +# - NETDATA_LIB_DIR # # Optional environment options: # @@ -170,6 +172,26 @@ download() { fi } +get_netdata_latest_tag() { + local dest="${1}" + local url="https://github.com/netdata/netdata/releases/latest" + local tag + + if command -v curl >/dev/null 2>&1; then + tag=$(curl "${url}" -s -L -I -o /dev/null -w '%{url_effective}' | grep -m 1 -o '[^/]*$') + elif command -v wget >/dev/null 2>&1; then + tag=$(wget --max-redirect=0 "${url}" 2>&1 | grep Location | cut -d ' ' -f2 | grep -m 1 -o '[^/]*$') + else + fatal "I need curl or wget to proceed, but neither of them are available on this system." + fi + + if [[ ! $tag =~ ^v[0-9]+\..+ ]]; then + fatal "Cannot download latest stable tag from ${url}" + fi + + echo "${tag}" >"${dest}" +} + newer_commit_date() { echo >&3 "Checking if a newer version of the updater script is available." @@ -235,7 +257,7 @@ parse_version() { get_latest_version() { if [ "${RELEASE_CHANNEL}" == "stable" ]; then - download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4 + get_netdata_latest_tag /dev/stdout else download "$NETDATA_NIGHTLIES_BASEURL/latest-version.txt" /dev/stdout fi @@ -250,8 +272,7 @@ set_tarball_urls() { if [ "$1" = "stable" ]; then local latest - # Simple version - latest="$(download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4)" + latest="$(get_netdata_latest_tag /dev/stdout)" export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/netdata-$latest.${extension}" export NETDATA_TARBALL_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/$latest/sha256sums.txt" else @@ -326,6 +347,12 @@ update() { fi fi + if [ -e "${NETDATA_PREFIX}/etc/netdata/.install-type" ] ; then + install_type="$(cat "${NETDATA_PREFIX}"/etc/netdata/.install-type)" + else + install_type="INSTALL_TYPE='legacy-build'" + fi + info "Re-installing netdata..." eval "${env} ./netdata-installer.sh ${REINSTALL_OPTIONS} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA" @@ -334,6 +361,8 @@ update() { info "Updating tarball checksum info" echo "${NEW_CHECKSUM}" > "${NETDATA_LIB_DIR}/netdata.tarball.checksum" + + echo "${install_type}" > "${NETDATA_PREFIX}/etc/netdata/.install-type" fi rm -rf "${ndtmpdir}" >&3 2>&3 @@ -393,7 +422,7 @@ if [ -t 2 ]; then else # we are headless # create a temporary file for the log - logfile="$(mktemp "${logfile}"/netdata-updater.log.XXXXXX)" + logfile="$(mktemp -t netdata-updater.log.XXXXXX)" # open fd 3 and send it to logfile exec 3> "${logfile}" fi @@ -415,6 +444,12 @@ if [ "${IS_NETDATA_STATIC_BINARY}" == "yes" ]; then fatal "Static binary checksum validation failed. Stopping netdata installation and leaving binary in ${ndtmpdir}\nUsually this is a result of an older copy of the file being cached somewhere and can be resolved by simply retrying in an hour." fi + if [ -e /opt/netdata/etc/netdata/.install-type ] ; then + install_type="$(cat /opt/netdata/etc/netdata/.install-type)" + else + install_type="INSTALL_TYPE='legacy-static'" + fi + # Do not pass any options other than the accept, for now # shellcheck disable=SC2086 if sh "${ndtmpdir}/netdata-latest.gz.run" --accept -- ${REINSTALL_OPTIONS}; then @@ -422,8 +457,11 @@ if [ "${IS_NETDATA_STATIC_BINARY}" == "yes" ]; then else echo >&2 "NOTE: did not remove: ${ndtmpdir}" fi + + echo "${install_type}" > /opt/netdata/etc/netdata/.install-type + echo >&2 "Switching back to ${PREVDIR}" - cd "${PREVDIR}" || exit 1 + cd "${PREVDIR}" else # the installer updates this script - so we run and exit in a single line update && exit 0 |