summaryrefslogtreecommitdiffstats
path: root/packaging/installer/netdata-updater.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xpackaging/installer/netdata-updater.sh38
1 files changed, 22 insertions, 16 deletions
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh
index d018d67d..130507c1 100755
--- a/packaging/installer/netdata-updater.sh
+++ b/packaging/installer/netdata-updater.sh
@@ -34,6 +34,9 @@ set -e
PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh"
+NETDATA_STABLE_BASE_URL="${NETDATA_BASE_URL:-https://github.com/netdata/netdata/releases}"
+NETDATA_NIGHTLY_BASE_URL="${NETDATA_BASE_URL:-https://github.com/netdata/netdata-nightlies/releases}"
+
script_dir="$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd -P)"
if [ -x "${script_dir}/netdata-updater" ]; then
@@ -369,13 +372,13 @@ download() {
}
get_netdata_latest_tag() {
- dest="${1}"
- url="https://github.com/netdata/netdata/releases/latest"
+ url="${1}/latest"
+ dest="${2}"
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 '[^/]*$')
+ tag=$(wget -S -O /dev/null "${url}" 2>&1 | grep -m 1 Location | grep -o '[^/]*$')
else
fatal "I need curl or wget to proceed, but neither of them are available on this system." U0006
fi
@@ -439,7 +442,12 @@ self_update() {
parse_version() {
r="${1}"
- if echo "${r}" | grep -q '^v.*'; then
+ if [ "${r}" = "latest" ]; then
+ # If we get ‘latest’ as a version, return the largest possible
+ # version value.
+ printf "99999999999999"
+ return 0
+ elif echo "${r}" | grep -q '^v.*'; then
# shellcheck disable=SC2001
# XXX: Need a regex group substitution here.
r="$(echo "${r}" | sed -e 's/^v\(.*\)/\1/')"
@@ -463,9 +471,9 @@ parse_version() {
get_latest_version() {
if [ "${RELEASE_CHANNEL}" = "stable" ]; then
- get_netdata_latest_tag /dev/stdout
+ get_netdata_latest_tag "${NETDATA_STABLE_BASE_URL}" /dev/stdout
else
- download "$NETDATA_NIGHTLIES_BASEURL/latest-version.txt" /dev/stdout
+ get_netdata_latest_tag "${NETDATA_NIGHTLY_BASE_URL}" /dev/stdout
fi
}
@@ -529,12 +537,13 @@ set_tarball_urls() {
fi
if [ "$1" = "stable" ]; then
- latest="$(get_netdata_latest_tag /dev/stdout)"
- export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/${filename}"
- export NETDATA_TARBALL_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/$latest/sha256sums.txt"
+ latest="$(get_netdata_latest_tag "${NETDATA_STABLE_BASE_URL}" /dev/stdout)"
+ export NETDATA_TARBALL_URL="${NETDATA_STABLE_BASE_URL}/download/$latest/${filename}"
+ export NETDATA_TARBALL_CHECKSUM_URL="${NETDATA_STABLE_BASE_URL}/download/$latest/sha256sums.txt"
else
- export NETDATA_TARBALL_URL="$NETDATA_NIGHTLIES_BASEURL/${filename}"
- export NETDATA_TARBALL_CHECKSUM_URL="$NETDATA_NIGHTLIES_BASEURL/sha256sums.txt"
+ tag="$(get_netdata_latest_tag "${NETDATA_NIGHTLY_BASE_URL}" /dev/stdout)"
+ export NETDATA_TARBALL_URL="${NETDATA_NIGHTLY_BASE_URL}/download/${tag}/${filename}"
+ export NETDATA_TARBALL_CHECKSUM_URL="${NETDATA_NIGHTLY_BASE_URL}/download/${tag}/sha256sums.txt"
fi
}
@@ -769,8 +778,8 @@ update_binpkg() {
opensuse)
pm_cmd="zypper"
repo_subcmd="--gpg-auto-import-keys refresh"
- upgrade_cmd="upgrade"
- pkg_install_opts="${interactive_opts} --allow-unsigned-rpm"
+ upgrade_cmd="update"
+ pkg_install_opts="${interactive_opts}"
repo_update_opts=""
pkg_installed_check="rpm -q"
INSTALL_TYPE="binpkg-rpm"
@@ -907,9 +916,6 @@ export NETDATA_LIB_DIR="${NETDATA_LIB_DIR:-${NETDATA_PREFIX}/var/lib/netdata}"
# Source the tarball checksum, if not already available from environment (for existing installations with the old logic)
[ -z "${NETDATA_TARBALL_CHECKSUM}" ] && [ -f "${NETDATA_LIB_DIR}/netdata.tarball.checksum" ] && NETDATA_TARBALL_CHECKSUM="$(cat "${NETDATA_LIB_DIR}/netdata.tarball.checksum")"
-# Grab the nightlies baseurl (defaulting to our Google Storage bucket)
-export NETDATA_NIGHTLIES_BASEURL="${NETDATA_NIGHTLIES_BASEURL:-https://storage.googleapis.com/netdata-nightlies}"
-
if echo "$INSTALL_TYPE" | grep -qv ^binpkg && [ "${INSTALL_UID}" != "$(id -u)" ]; then
fatal "You are running this script as user with uid $(id -u). We recommend to run this script as root (user with uid 0)" U0011
fi