diff options
author | Paweł Krupa <pawel@krupa.net.pl> | 2019-02-28 16:19:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-28 16:19:48 +0100 |
commit | 7a98b56ad9c5d708894189d1c95756f031991c60 (patch) | |
tree | 3466143c61ca1bf8d9b46513479e52228a21dd1d /packaging/installer/netdata-updater.sh | |
parent | 4fd9c251c4d30bf21c1f85a779ef00106bfc810b (diff) |
introduce stable installation channel (#5487)
[patch]
Diffstat (limited to 'packaging/installer/netdata-updater.sh')
-rw-r--r-- | packaging/installer/netdata-updater.sh | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index 13759abd26..2dce5efc1e 100644 --- a/packaging/installer/netdata-updater.sh +++ b/packaging/installer/netdata-updater.sh @@ -31,6 +31,17 @@ fatal() { exit 1 } +create_tmp_directory() { + # Check if tmp is mounted as noexec + if grep -Eq '^[^ ]+ /tmp [^ ]+ ([^ ]*,)?noexec[, ]' /proc/mounts; then + pattern="$(pwd)/netdata-updater-XXXXXX" + else + pattern="/tmp/netdata-updater-XXXXXX" + fi + + mktemp -d "$pattern" +} + download() { url="${1}" dest="${2}" @@ -43,18 +54,24 @@ download() { fi } -update() { - [ -z "${logfile}" ] && info "Running on a terminal - (this script also supports running headless from crontab)" - - # Check if tmp is mounted as noexec - if grep -Eq '^[^ ]+ /tmp [^ ]+ ([^ ]*,)?noexec[, ]' /proc/mounts; then - pattern="$(pwd)/netdata-updater-XXXXXX" +set_tarball_urls() { + if [ "$1" == "stable" ]; then + local latest + # Simple version + # latest="$(curl -sSL https://api.github.com/repos/netdata/netdata/releases/latest | grep tag_name | cut -d'"' -f4)" + latest="$(download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4)" + export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/netdata-$latest.tar.gz" + export NETDATA_TARBALL_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/$latest/sha256sums.txt" else - pattern="/tmp/netdata-updater-XXXXXX" + export NETDATA_TARBALL_URL="https://storage.googleapis.com/netdata-nightlies/netdata-latest.tar.gz" + export NETDATA_TARBALL_CHECKSUM_URL="https://storage.googleapis.com/netdata-nightlies/sha256sums.txt" fi +} - dir=$(mktemp -d "$pattern") +update() { + [ -z "${logfile}" ] && info "Running on a terminal - (this script also supports running headless from crontab)" + dir=$(create_tmp_directory) cd "$dir" download "${NETDATA_TARBALL_CHECKSUM_URL}" "${dir}/sha256sum.txt" >&3 2>&3 @@ -85,11 +102,9 @@ update() { fi info "Re-installing netdata..." - eval "${REINSTALL_COMMAND} --dont-wait ${do_not_start}" >&3 2>&3 || failed "FAILED TO COMPILE/INSTALL NETDATA" + eval "${REINSTALL_COMMAND} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA" sed -i '/NETDATA_TARBALL/d' "${ENVIRONMENT_FILE}" cat <<EOF >>"${ENVIRONMENT_FILE}" -NETDATA_TARBALL_URL="$NETDATA_TARBALL_URL" -NETDATA_TARBALL_CHECKSUM_URL="$NETDATA_TARBALL_CHECKSUM_URL" NETDATA_TARBALL_CHECKSUM="$NEW_CHECKSUM" EOF @@ -121,5 +136,7 @@ else exec 3>"${logfile}" fi +set_tarball_urls "${RELEASE_CHANNEL}" + # the installer updates this script - so we run and exit in a single line update && exit 0 |