diff options
author | Paul Emm. Katsoulakis <34388743+paulkatsoulakis@users.noreply.github.com> | 2019-04-29 18:39:22 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-29 18:39:22 +0300 |
commit | d01b2620eab77d8f2ab1c70456744565eff356f0 (patch) | |
tree | 9b0713a373f0d63282ecd728322bb5d873b351b3 /packaging | |
parent | e33c45d333b0704363eb31105293c9b067158cdb (diff) |
Fix lifecycle script (#5918)
* netdata/packaging/ci: stronger validations during install, add some comments, change validation of CWD
* netdata/packaging/ci: Add a lifecycle test to validate update from stable to latest works smooth
-> Add updater BATS script that does the trick for installing stable then migrating to latest using current code and not nightly
-> Integrate with travis
-> Rename /code to /netdata in travis, scripts will eventually expect the TLD of repo to be actually named netdata, so test will start failing later
-> Introduce a flag on the updater, so that it doesn't download the tarball, but it rather works with a local pre-defined directory. If a user wants
to override the update process, so that it runs with a different repository he just needs to export NETDATA_LOCAL_TARBAL_OVERRIDE with the desired repo directory
* netdata/packaging/ci: Add required packages for it to run
Diffstat (limited to 'packaging')
-rwxr-xr-x[-rw-r--r--] | packaging/installer/netdata-updater.sh | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index 56c8379530..21a769ba57 100644..100755 --- a/packaging/installer/netdata-updater.sh +++ b/packaging/installer/netdata-updater.sh @@ -67,6 +67,12 @@ download() { } set_tarball_urls() { + + if [ ! -z "${NETDATA_LOCAL_TARBAL_OVERRIDE}" ]; then + info "Not fetching remote tarballs, local override was given" + return + fi + if [ "$1" == "stable" ]; then local latest # Simple version @@ -83,22 +89,34 @@ set_tarball_urls() { update() { [ -z "${logfile}" ] && info "Running on a terminal - (this script also supports running headless from crontab)" - dir=$(create_tmp_directory) - cd "$dir" + RUN_INSTALLER=0 + tmpdir=$(create_tmp_directory) + cd "$tmpdir" - download "${NETDATA_TARBALL_CHECKSUM_URL}" "${dir}/sha256sum.txt" >&3 2>&3 - if grep "${NETDATA_TARBALL_CHECKSUM}" sha256sum.txt >&3 2>&3; then - info "Newest version is already installed" - else - download "${NETDATA_TARBALL_URL}" "${dir}/netdata-latest.tar.gz" - if ! grep netdata-latest.tar.gz sha256sum.txt | safe_sha256sum -c - >&3 2>&3; then - fatal "Tarball checksum validation failed. Stopping netdata upgrade and leaving tarball in ${dir}" + if [ -z "${NETDATA_LOCAL_TARBAL_OVERRIDE}" ]; then + download "${NETDATA_TARBALL_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt" >&3 2>&3 + if grep "${NETDATA_TARBALL_CHECKSUM}" sha256sum.txt >&3 2>&3; then + info "Newest version is already installed" + else + download "${NETDATA_TARBALL_URL}" "${tmpdir}/netdata-latest.tar.gz" + if ! grep netdata-latest.tar.gz sha256sum.txt | safe_sha256sum -c - >&3 2>&3; then + fatal "Tarball checksum validation failed. Stopping netdata upgrade and leaving tarball in ${tmpdir}" + fi + NEW_CHECKSUM="$(safe_sha256sum netdata-latest.tar.gz 2>/dev/null| cut -d' ' -f1)" + tar -xf netdata-latest.tar.gz >&3 2>&3 + rm netdata-latest.tar.gz >&3 2>&3 + cd netdata-* + RUN_INSTALLER=1 fi - NEW_CHECKSUM="$(safe_sha256sum netdata-latest.tar.gz 2>/dev/null| cut -d' ' -f1)" - tar -xf netdata-latest.tar.gz >&3 2>&3 - rm netdata-latest.tar.gz >&3 2>&3 - cd netdata-* + else + info "!!Local tarball override detected!! - Entering directory ${NETDATA_LOCAL_TARBAL_OVERRIDE} for installation, not downloading anything" + RUN_INSTALLER=1 + cd ${NETDATA_LOCAL_TARBAL_OVERRIDE} + fi + + # We got the sources, run the update now + if [ ${RUN_INSTALLER} -eq 1 ]; then # signal netdata to start saving its database # this is handy if your database is big pids=$(pidof netdata) @@ -119,9 +137,9 @@ NETDATA_TARBALL_CHECKSUM="$NEW_CHECKSUM" EOF fi - rm -rf "${dir}" >&3 2>&3 + rm -rf "${tmpdir}" >&3 2>&3 [ -n "${logfile}" ] && rm "${logfile}" && logfile= - return 0 + return } # Usually stored in /etc/netdata/.environment |