diff options
Diffstat (limited to '')
-rw-r--r-- | packaging/installer/README.md | 32 | ||||
-rw-r--r-- | packaging/installer/UPDATE.md | 2 | ||||
-rw-r--r-- | packaging/installer/functions.sh | 14 | ||||
-rwxr-xr-x | packaging/installer/kickstart-static64.sh | 45 | ||||
-rwxr-xr-x | packaging/installer/kickstart.sh | 47 | ||||
-rwxr-xr-x | packaging/installer/netdata-uninstaller.sh | 208 | ||||
-rwxr-xr-x[-rw-r--r--] | packaging/installer/netdata-updater.sh | 48 |
7 files changed, 330 insertions, 66 deletions
diff --git a/packaging/installer/README.md b/packaging/installer/README.md index 1fa8f14d5..6dc084e83 100644 --- a/packaging/installer/README.md +++ b/packaging/installer/README.md @@ -42,7 +42,7 @@ bash <(curl -Ss https://my-netdata.io/kickstart.sh) Verify the integrity of the script with this: ```bash -[ "15c688e7228ebee83ace1811273cd089" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" +[ "fe451cd039c8f99b2ba4ca0feab88033" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" ``` *It should print `OK, VALID` if the script is the one we ship.* @@ -99,7 +99,7 @@ To install Netdata with a binary package on any Linux distro, any kernel version Verify the integrity of the script with this: ```bash -[ "97427a0fc5a52593b603c2ae887d4466" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" +[ "9ff4f5f37d23dff431f80d5349e0a25c" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" ``` *It should print `OK, VALID` if the script is the one we ship.* @@ -191,13 +191,13 @@ This is how to do it by hand: ```sh # Debian / Ubuntu -apt-get install zlib1g-dev uuid-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl +apt-get install zlib1g-dev uuid-dev libuv1-dev liblz4-dev libjudy-dev libssl-dev libmnl-dev gcc make git autoconf autoconf-archive autogen automake pkg-config curl # Fedora -dnf install zlib-devel libuuid-devel libmnl-devel gcc make git autoconf autoconf-archive autogen automake pkgconfig curl findutils +dnf install zlib-devel libuuid-devel libuv-devel lz4-devel Judy-devel openssl-devel libmnl-devel gcc make git autoconf autoconf-archive autogen automake pkgconfig curl findutils # CentOS / Red Hat Enterprise Linux -yum install autoconf automake curl gcc git libmnl-devel libuuid-devel lm_sensors make MySQL-python nc pkgconfig python python-psycopg2 PyYAML zlib-devel +yum install autoconf automake curl gcc git libmnl-devel libuuid-devel openssl-devel libuv-devel lz4-devel Judy-devel lm_sensors make MySQL-python nc pkgconfig python python-psycopg2 PyYAML zlib-devel ``` @@ -234,6 +234,17 @@ package|description *Netdata will greatly benefit if you have the above packages installed, but it will still work without them.* +Netdata DB engine can be enabled when these are installed (they are optional): + +|package|description| +|:-----:|-----------| +|`libuv`|multi-platform support library with a focus on asynchronous I/O| +|`liblz4`|Extremely Fast Compression algorithm| +|`Judy`|General purpose dynamic array| +|`openssl`|Cryptography and SSL/TLS Toolkit| + +*Netdata will greatly benefit if you have the above packages installed, but it will still work without them.* + --- ### Install Netdata @@ -299,16 +310,19 @@ Note first three packages are downloaded from the pfSense repository for maintai pkg install pkgconf pkg install bash pkg install e2fsprogs-libuuid -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/netdata-1.11.0.txz +pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/python36-3.6.8_2.txz +pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/netdata-1.13.0.txz ``` To start Netdata manually run `service netdata onestart` -To start Netdata automatically at each boot add `service netdata start` as a Shellcmd within the pfSense web interface (under **Services/Shellcmd**, which you need to install beforehand under **System/Package Manager/Available Packages**). +To start Netdata automatically at each boot add `service netdata onestart` as a Shellcmd within the pfSense web interface (under **Services/Shellcmd**, which you need to install beforehand under **System/Package Manager/Available Packages**). Shellcmd Type should be set to `Shellcmd`. -![](https://user-images.githubusercontent.com/36808164/36930790-4db3aa84-1f0d-11e8-8752-cdc08bb7207c.png) +![](https://i.imgur.com/wcKiPe1.png) Alternatively more information can be found in https://doc.pfsense.org/index.php/Installing_FreeBSD_Packages, for achieving the same via the command line and scripts. -If you experience an issue with `/usr/bin/install` absense on pfSense 2.3 or earlier, update pfSense or use workaround from [https://redmine.pfsense.org/issues/6643](https://redmine.pfsense.org/issues/6643) +If you experience an issue with `/usr/bin/install` absense on pfSense 2.3 or earlier, update pfSense or use workaround from [https://redmine.pfsense.org/issues/6643](https://redmine.pfsense.org/issues/6643) + +**Note:** In pfSense, the Netdata configuration files are located under `/usr/local/etc/netdata` ##### FreeNAS On FreeNAS-Corral-RELEASE (>=10.0.3), Netdata is pre-installed. diff --git a/packaging/installer/UPDATE.md b/packaging/installer/UPDATE.md index c93ebf9b4..0903ddb57 100644 --- a/packaging/installer/UPDATE.md +++ b/packaging/installer/UPDATE.md @@ -11,7 +11,7 @@ The update procedure depends on how you installed it: ### Manual update to get the latest git commit -netdata versions older than `v1.12.0-rc2-52` had a `netdata-updater.sh` script in the root directory of the source code, which has now been deprecated. The manual process that works for all versions to get the latest commit in git is to use the `netdata-installer.sh`. The installer preserves your custom configuration and updates the the information of the installation in the `.environment` file under the user configuration directory. +netdata versions older than `v1.12.0-rc2-52` had a `netdata-updater.sh` script in the root directory of the source code, which has now been deprecated. The manual process that works for all versions to get the latest commit in git is to use the `netdata-installer.sh`. The installer preserves your custom configuration and updates the information of the installation in the `.environment` file under the user configuration directory. ```sh # go to the git downloaded directory diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh index 4270c4ee0..d1e944878 100644 --- a/packaging/installer/functions.sh +++ b/packaging/installer/functions.sh @@ -606,6 +606,11 @@ portable_add_user() { run adduser -h "${homedir}" -s "${nologin}" -D -G "${username}" "${username}" && return 0 fi + # mac OS + if command -v sysadminctl 1> /dev/null 2>&1; then + run sysadminctl -addUser ${username} && return 0 + fi + echo >&2 "Failed to add ${username} user account !" return 1 @@ -637,6 +642,11 @@ portable_add_group() { run addgroup "${groupname}" && return 0 fi + # mac OS + if command -v dseditgroup 1> /dev/null 2>&1; then + dseditgroup -o create "${groupname}" && return 0 + fi + echo >&2 "Failed to add ${groupname} user group !" return 1 } @@ -674,6 +684,10 @@ portable_add_user_to_group() { run addgroup "${username}" "${groupname}" && return 0 fi + # mac OS + if command -v dseditgroup 1> /dev/null 2>&1; then + dseditgroup -u "${username}" "${groupname}" && return 0 + fi echo >&2 "Failed to add user ${username} to group ${groupname} !" return 1 fi diff --git a/packaging/installer/kickstart-static64.sh b/packaging/installer/kickstart-static64.sh index 6ef3a1232..505179051 100755 --- a/packaging/installer/kickstart-static64.sh +++ b/packaging/installer/kickstart-static64.sh @@ -32,13 +32,27 @@ setup_terminal() { return 0 } +setup_terminal || echo >/dev/null -progress() { - echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- " +# ----------------------------------------------------------------------------- +fatal() { + printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n" + exit 1 +} + +run_ok() { + printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n" } +run_failed() { + printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n" +} + +ESCAPED_PRINT_METHOD= +printf "%q " test >/dev/null 2>&1 +[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq" escaped_print() { - if printf "%q " test >/dev/null 2>&1; then + if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then printf "%q " "${@}" else printf "%s" "${*}" @@ -46,24 +60,39 @@ escaped_print() { return 0 } +progress() { + echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- " +} + +run_logfile="/dev/null" run() { - local dir="${PWD}" info_console + local user="${USER--}" dir="${PWD}" info info_console if [ "${UID}" = "0" ]; then + info="[root ${dir}]# " info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# " else + info="[${user} ${dir}]$ " info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ " fi - escaped_print "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" "${@}" "${TPUT_RESET}\n" >&2 + printf >>"${run_logfile}" "${info}" + escaped_print >>"${run_logfile}" "${@}" + printf >>"${run_logfile}" " ... " + + printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" + escaped_print >&2 "${@}" + printf >&2 "${TPUT_RESET}\n" "${@}" local ret=$? if [ ${ret} -ne 0 ]; then - printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n" + run_failed + printf >>"${run_logfile}" "FAILED with exit code ${ret}\n" else - printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n" + run_ok + printf >>"${run_logfile}" "OK\n" fi return ${ret} @@ -130,8 +159,6 @@ sudo="" [ -z "${UID}" ] && UID="$(id -u)" [ "${UID}" -ne "0" ] && sudo="sudo" -setup_terminal || echo >/dev/null - # --------------------------------------------------------------------------------------------------------------------- if [ "$(uname -m)" != "x86_64" ]; then fatal "Static binary versions of netdata are available only for 64bit Intel/AMD CPUs (x86_64), but yours is: $(uname -m)." diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh index a8057c19c..2db95f21d 100755 --- a/packaging/installer/kickstart.sh +++ b/packaging/installer/kickstart.sh @@ -58,13 +58,27 @@ setup_terminal() { return 0 } +setup_terminal || echo >/dev/null -progress() { - echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- " +# ----------------------------------------------------------------------------- +fatal() { + printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n" + exit 1 +} + +run_ok() { + printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n" } +run_failed() { + printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n" +} + +ESCAPED_PRINT_METHOD= +printf "%q " test >/dev/null 2>&1 +[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq" escaped_print() { - if printf "%q " test >/dev/null 2>&1; then + if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then printf "%q " "${@}" else printf "%s" "${*}" @@ -72,24 +86,39 @@ escaped_print() { return 0 } +progress() { + echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- " +} + +run_logfile="/dev/null" run() { - local dir="${PWD}" info_console + local user="${USER--}" dir="${PWD}" info info_console if [ "${UID}" = "0" ]; then + info="[root ${dir}]# " info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# " else + info="[${user} ${dir}]$ " info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ " fi - escaped_print "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" "${@}" "${TPUT_RESET}\n" >&2 + printf >>"${run_logfile}" "${info}" + escaped_print >>"${run_logfile}" "${@}" + printf >>"${run_logfile}" " ... " + + printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" + escaped_print >&2 "${@}" + printf >&2 "${TPUT_RESET}\n" - ${@} + "${@}" local ret=$? if [ ${ret} -ne 0 ]; then - printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n" + run_failed + printf >>"${run_logfile}" "FAILED with exit code ${ret}\n" else - printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n" + run_ok + printf >>"${run_logfile}" "OK\n" fi return ${ret} @@ -224,8 +253,6 @@ sudo="" [ "${UID}" -ne "0" ] && sudo="sudo" export PATH="${PATH}:/usr/local/bin:/usr/local/sbin" -setup_terminal || echo >/dev/null - # --------------------------------------------------------------------------------------------------------------------- # try to update using autoupdater in the first place diff --git a/packaging/installer/netdata-uninstaller.sh b/packaging/installer/netdata-uninstaller.sh index 96dd62906..cfd858c02 100755 --- a/packaging/installer/netdata-uninstaller.sh +++ b/packaging/installer/netdata-uninstaller.sh @@ -1,11 +1,15 @@ #!/usr/bin/env bash #shellcheck disable=SC2181 - -# this script will uninstall netdata - +# +# This is the netdata uninstaller script # Variables needed by script and taken from '.environment' file: # - NETDATA_PREFIX # - NETDATA_ADDED_TO_GROUPS +# +# Copyright: SPDX-License-Identifier: GPL-3.0-or-later +# +# Author: Paul Emm. Katsoulakis <paul@netdata.cloud> +# usage="$(basename "$0") [-h] [-f ] -- program to calculate the answer to life, the universe and everything @@ -46,13 +50,13 @@ while :; do done if [ "$YES" != "1" ]; then - echo "This script will REMOVE netdata from your system." - echo "Run it again with --yes to do it." + echo >&2 "This script will REMOVE netdata from your system." + echo >&2 "Run it again with --yes to do it." exit 1 fi if [[ $EUID -ne 0 ]]; then - echo "This script SHOULD be run as root or otherwise it won't delete all installed components." + echo >&2 "This script SHOULD be run as root or otherwise it won't delete all installed components." key="n" read -r -s -n 1 -p "Do you want to continue as non-root user [y/n] ? " key if [ "$key" != "y" ] && [ "$key" != "Y" ]; then @@ -60,34 +64,191 @@ if [[ $EUID -ne 0 ]]; then fi fi -function quit_msg() { +# ----------------------------------------------------------------------------- + +setup_terminal() { + TPUT_RESET="" + TPUT_YELLOW="" + TPUT_WHITE="" + TPUT_BGRED="" + TPUT_BGGREEN="" + TPUT_BOLD="" + TPUT_DIM="" + + # Is stderr on the terminal? If not, then fail + test -t 2 || return 1 + + if command -v tput 1>/dev/null 2>&1; then + if [ $(($(tput colors 2>/dev/null))) -ge 8 ]; then + # Enable colors + TPUT_RESET="$(tput sgr 0)" + TPUT_YELLOW="$(tput setaf 3)" + TPUT_WHITE="$(tput setaf 7)" + TPUT_BGRED="$(tput setab 1)" + TPUT_BGGREEN="$(tput setab 2)" + TPUT_BOLD="$(tput bold)" + TPUT_DIM="$(tput dim)" + fi + fi + + return 0 +} +setup_terminal || echo >/dev/null + +run_ok() { + printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n" +} + +run_failed() { + printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n" +} + +ESCAPED_PRINT_METHOD= +printf "%q " test >/dev/null 2>&1 +[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq" +escaped_print() { + if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then + printf "%q " "${@}" + else + printf "%s" "${*}" + fi + return 0 +} + +run_logfile="/dev/null" +run() { + local user="${USER--}" dir="${PWD}" info info_console + + if [ "${UID}" = "0" ]; then + info="[root ${dir}]# " + info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# " + else + info="[${user} ${dir}]$ " + info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ " + fi + + printf >>"${run_logfile}" "${info}" + escaped_print >>"${run_logfile}" "${@}" + printf >>"${run_logfile}" " ... " + + printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" + escaped_print >&2 "${@}" + printf >&2 "${TPUT_RESET}\n" + + "${@}" + + local ret=$? + if [ ${ret} -ne 0 ]; then + run_failed + printf >>"${run_logfile}" "FAILED with exit code ${ret}\n" + else + run_ok + printf >>"${run_logfile}" "OK\n" + fi + + return ${ret} +} + +portable_del_group() { + local groupname="${1}" + + # Check if group exist + echo >&2 "Removing ${groupname} user group ..." + + # Linux + if command -v groupdel 1>/dev/null 2>&1; then + run groupdel -f "${groupname}" && return 0 + fi + + # mac OS + if command -v dseditgroup 1> /dev/null 2>&1; then + if dseditgroup -o read netdata 1> /dev/null 2>&1; then + run dseditgroup -o delete "${groupname}" && return 0 + else + echo >&2 "Could not find group ${groupname}, nothing to do" + fi + fi + + echo >&2 "Group ${groupname} was not automatically removed, you might have to remove it manually" + return 1 +} + +portable_del_user() { + local username="${1}" + echo >&2 "Deleting ${username} user account ..." + + # Linux + if command -v userdel 1>/dev/null 2>&1; then + run userdel -f "${username}" && return 0 + fi + + # mac OS + if command -v sysadminctl 1>/dev/null 2>&1; then + run sysadminctl -deleteUser "${username}" && return 0 + fi + + echo >&2 "User ${username} could not be deleted from system, you might have to remove it manually" + return 1 +} + +portable_del_user_from_group() { + local groupname="${1}" username="${2}" + + # username is not in group + echo >&2 "Deleting ${username} user from ${groupname} group ..." + + # Linux + if command -v gpasswd 1>/dev/null 2>&1; then + run gpasswd -d "netdata" "${group}" && return 0 + fi + + # FreeBSD + if command -v pw 1>/dev/null 2>&1; then + run pw groupmod "${groupname}" -d "${username}" && return 0 + fi + + # BusyBox + if command -v delgroup 1>/dev/null 2>&1; then + run delgroup "${username}" "${groupname}" && return 0 + fi + + # mac OS + if command -v dseditgroup 1> /dev/null 2>&1; then + run dseditgroup -o delete -u "${username}" "${groupname}" && return 0 + fi + + echo >&2 "Failed to delete user ${username} from group ${groupname} !" + return 1 +} + +quit_msg() { echo if [ "$FILE_REMOVAL_STATUS" -eq 0 ]; then - echo "Something went wrong :(" + echo >&2 "Something went wrong :(" else - echo "Netdata files were successfully removed from your system" + echo >&2 "Netdata files were successfully removed from your system" fi } -function user_input() { +user_input() { TEXT="$1" if [ "${INTERACTIVITY}" == "-i" ]; then read -r -p "$TEXT" >&2 fi } -function rm_file() { +rm_file() { FILE="$1" if [ -f "${FILE}" ]; then - rm -v ${INTERACTIVITY} "${FILE}" + run rm -v ${INTERACTIVITY} "${FILE}" fi } -function rm_dir() { +rm_dir() { DIR="$1" if [ -n "$DIR" ] && [ -d "$DIR" ]; then user_input "Press ENTER to recursively delete directory '$DIR' > " - rm -v -f -R "${DIR}" + run rm -v -f -R "${DIR}" fi } @@ -116,14 +277,14 @@ trap quit_msg EXIT source "${ENVIRONMENT_FILE}" || exit 1 #### STOP NETDATA -echo "Stopping a possibly running netdata..." +echo >&2 "Stopping a possibly running netdata..." for p in $(netdata_pids); do i=0 while kill "${p}" 2>/dev/null; do if [ "$i" -gt 30 ]; then - echo "Forcefully stopping netdata with pid ${p}" - kill -9 "${p}" - sleep 2 + echo >&2 "Forcefully stopping netdata with pid ${p}" + run kill -9 "${p}" + run sleep 2 break fi sleep 1 @@ -155,15 +316,18 @@ fi FILE_REMOVAL_STATUS=1 -#### REMOVE NETDATA USER & GROUP +#### REMOVE NETDATA USER FROM ADDED GROUPS if [ -n "$NETDATA_ADDED_TO_GROUPS" ]; then user_input "Press ENTER to delete 'netdata' from following groups: '$NETDATA_ADDED_TO_GROUPS' > " for group in $NETDATA_ADDED_TO_GROUPS; do - gpasswd -d netdata "${group}" + portable_del_user_from_group "${group}" "netdata" done fi +#### REMOVE USER user_input "Press ENTER to delete 'netdata' system user > " -userdel -f netdata || : +portable_del_user "netdata" || : + +### REMOVE GROUP user_input "Press ENTER to delete 'netdata' system group > " -groupdel -f netdata || : +portable_del_group "netdata" || : diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index 56c837953..21a769ba5 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 |