summaryrefslogtreecommitdiffstats
path: root/packaging/installer/kickstart.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/installer/kickstart.sh')
-rwxr-xr-xpackaging/installer/kickstart.sh730
1 files changed, 332 insertions, 398 deletions
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
index 30c7b4ca..28491119 100755
--- a/packaging/installer/kickstart.sh
+++ b/packaging/installer/kickstart.sh
@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
-# Next unused error code: F050F
+# Next unused error code: F0515
# ======================================================================
# Constants
@@ -34,7 +34,7 @@ REPOCONFIG_RPM_URL_PREFIX="https://repo.netdata.cloud/repos/repoconfig"
REPOCONFIG_RPM_VERSION="2-1"
START_TIME="$(date +%s)"
STATIC_INSTALL_ARCHES="x86_64 armv7l aarch64 ppc64le"
-TELEMETRY_URL="https://posthog.netdata.cloud/capture/"
+TELEMETRY_URL="https://app.posthog.com/capture/"
# ======================================================================
# Defaults for environment variables
@@ -44,14 +44,11 @@ SELECTED_INSTALL_METHOD="none"
INSTALL_TYPE="unknown"
INSTALL_PREFIX=""
NETDATA_AUTO_UPDATES="default"
-NETDATA_CLAIM_ONLY=0
NETDATA_CLAIM_URL="https://api.netdata.cloud"
NETDATA_COMMAND="default"
NETDATA_DISABLE_CLOUD=0
NETDATA_INSTALLER_OPTIONS=""
-NETDATA_ONLY_BUILD=0
-NETDATA_ONLY_NATIVE=0
-NETDATA_ONLY_STATIC=0
+NETDATA_FORCE_METHOD=""
NETDATA_OFFLINE_INSTALL_SOURCE=""
NETDATA_REQUIRE_CLOUD=1
NETDATA_WARNINGS=""
@@ -69,7 +66,7 @@ NETDATA_TARBALL_BASEURL="${NETDATA_TARBALL_BASEURL:-https://github.com/netdata/n
TELEMETRY_API_KEY="${NETDATA_POSTHOG_API_KEY:-mqkwGT0JNFqO-zX2t0mW6Tec9yooaVu7xCBlXtHnt5Y}"
if echo "${0}" | grep -q 'kickstart-static64'; then
- NETDATA_ONLY_STATIC=1
+ NETDATA_FORCE_METHOD='static'
fi
if [ ! -t 1 ]; then
@@ -78,6 +75,8 @@ else
INTERACTIVE=1
fi
+CURL="$(PATH="${PATH}:/opt/netdata/bin" command -v curl 2>/dev/null && true)"
+
# ======================================================================
# Shared messages used in multiple places throughout the script.
@@ -103,7 +102,7 @@ main() {
uninstall
cleanup
- ACTION=
+ ACTION=''
INSTALL_PREFIX="${NEW_INSTALL_PREFIX}"
# shellcheck disable=SC2086
main
@@ -175,12 +174,9 @@ USAGE: kickstart.sh [options]
--auto-update Enable automatic updates.
--auto-update-type Specify a particular scheduling type for auto-updates (valid types: systemd, interval, crontab)
--disable-telemetry Opt-out of anonymous statistics.
- --repositories-only Only install appropriate repository configuration packages (only for native install).
--native-only Only install if native binary packages are available.
--static-only Only install if a static build is available.
--build-only Only install using a local build.
- --reinstall Explicitly reinstall instead of updating any existing install.
- --reinstall-even-if-unsafe Even try to reinstall if we don't think we can do so safely (implies --reinstall).
--disable-cloud Disable support for Netdata Cloud (default: detect)
--require-cloud Only install if Netdata Cloud can be enabled. Overrides --disable-cloud.
--install-prefix <path> Specify an installation prefix for local builds (default: autodetect based on system type).
@@ -188,13 +184,19 @@ USAGE: kickstart.sh [options]
--install-version <version> Specify the version of Netdata to install.
--claim-token Use a specified token for claiming to Netdata Cloud.
--claim-rooms When claiming, add the node to the specified rooms.
- --claim-only If there is an existing install, only try to claim it, not update it.
--claim-* Specify other options for the claiming script.
--no-cleanup Don't do any cleanup steps. This is intended to help with debugging the installer.
- --uninstall Uninstall an existing installation of Netdata.
- --reinstall-clean Clean reinstall Netdata.
--local-build-options Specify additional options to pass to the installer code when building locally. Only valid if --build-only is also specified.
--static-install-options Specify additional options to pass to the static installer code. Only valid if --static-only is also specified.
+
+The following options are mutually exclusive and specifiy special operations other than trying to install Netdata normally or update an existing install:
+
+ --reinstall If there is an existing install, reinstall it instead of trying to update it. If there is no existing install, install netdata normally.
+ --reinstall-even-if-unsafe If there is an existing install, reinstall it instead of trying to update it, even if doing so is known to potentially break things. If there is no existing install, install Netdata normally.
+ --reinstall-clean If there is an existing install, uninstall it before trying to install Netdata. Fails if there is no existing install.
+ --uninstall Uninstall an existing installation of Netdata. Fails if there is no existing install.
+ --claim-only If there is an existing install, only try to claim it without attempting to update it. If there is no existing install, install and claim Netdata normally.
+ --repositories-only Only install repository configuration packages instead of doing a full install of Netdata. Automatically sets --native-only.
--prepare-offline-install-source Instead of installing the agent, prepare a directory that can be used to install on another system without needing to download anything.
Additionally, this script may use the following environment variables:
@@ -299,8 +301,8 @@ telemetry_event() {
EOF
)"
- if command -v curl > /dev/null 2>&1; then
- curl --silent -o /dev/null -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" "${TELEMETRY_URL}" > /dev/null
+ if [ -n "${CURL}" ]; then
+ "${CURL}" --silent -o /dev/null -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" "${TELEMETRY_URL}" > /dev/null
elif command -v wget > /dev/null 2>&1; then
if wget --help 2>&1 | grep BusyBox > /dev/null 2>&1; then
# BusyBox-compatible version of wget, there is no --no-check-certificate option
@@ -329,9 +331,7 @@ trap_handler() {
printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ERROR ${TPUT_RESET} Installer exited unexpectedly (${code}-${lineno})"
case "${code}" in
- 0)
- printf >&2 "%s\n" "This is almost certainly the result of a bug. If you have time, please report it at ${AGENT_BUG_REPORT_URL}."
- ;;
+ 0) printf >&2 "%s\n" "This is almost certainly the result of a bug. If you have time, please report it at ${AGENT_BUG_REPORT_URL}." ;;
*)
printf >&2 "%s\n" "This is probably a result of a transient issue on your system. Things should work correctly if you try again."
printf >&2 "%s\n" "If you continue to experience this issue, you can reacn out to us for support on:"
@@ -406,7 +406,7 @@ success_banner() {
cleanup() {
if [ -z "${NO_CLEANUP}" ] && [ -n "${tmpdir}" ]; then
cd || true
- ${ROOTCMD} rm -rf "${tmpdir}"
+ run_as_root rm -rf "${tmpdir}"
fi
}
@@ -497,6 +497,16 @@ run() {
return ${ret}
}
+run_as_root() {
+ confirm_root_support
+
+ if [ "$(id -u)" -ne "0" ]; then
+ printf >&2 "Root privileges required to run %s\n" "${*}"
+ fi
+
+ run ${ROOTCMD} "${@}"
+}
+
run_script() {
set_tmpdir
@@ -571,8 +581,8 @@ check_for_remote_file() {
if echo "${url}" | grep -Eq "^file:///"; then
[ -e "${url#file://}" ] || return 1
- elif command -v curl > /dev/null 2>&1; then
- curl --output /dev/null --silent --head --fail "${url}" || return 1
+ elif [ -n "${CURL}" ]; then
+ "${CURL}" --output /dev/null --silent --head --fail "${url}" || return 1
elif command -v wget > /dev/null 2>&1; then
wget -S --spider "${url}" 2>&1 | grep -q 'HTTP/1.1 200 OK' || return 1
else
@@ -586,8 +596,8 @@ download() {
if echo "${url}" | grep -Eq "^file:///"; then
run cp "${url#file://}" "${dest}" || return 1
- elif command -v curl > /dev/null 2>&1; then
- run curl --fail -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}" || return 1
+ elif [ -n "${CURL}" ]; then
+ run "${CURL}" --fail -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}" || return 1
elif command -v wget > /dev/null 2>&1; then
run wget -T 15 -O "${dest}" "${url}" || return 1
else
@@ -598,8 +608,8 @@ download() {
get_redirect() {
url="${1}"
- if command -v curl > /dev/null 2>&1; then
- run sh -c "curl ${url} -s -L -I -o /dev/null -w '%{url_effective}' | grep -o '[^/]*$'" || return 1
+ if [ -n "${CURL}" ]; then
+ run sh -c "${CURL} ${url} -s -L -I -o /dev/null -w '%{url_effective}' | grep -o '[^/]*$'" || return 1
elif command -v wget > /dev/null 2>&1; then
run sh -c "wget -S -O /dev/null ${url} 2>&1 | grep -m 1 Location | grep -o '[^/]*$'" || return 1
else
@@ -620,75 +630,65 @@ safe_sha256sum() {
}
get_system_info() {
+ SYSARCH="$(uname -m)"
+
case "$(uname -s)" in
Linux)
SYSTYPE="Linux"
- os_release_file=
- if [ -s "/etc/os-release" ] && [ -r "/etc/os-release" ]; then
- os_release_file="/etc/os-release"
- elif [ -s "/usr/lib/os-release" ] && [ -r "/usr/lib/os-release" ]; then
- os_release_file="/usr/lib/os-release"
- else
- warning "Cannot find usable OS release information. Native packages will not be available for this install."
- fi
-
- if [ -n "${os_release_file}" ]; then
- # shellcheck disable=SC1090
- . "${os_release_file}"
-
- DISTRO="${ID}"
- SYSVERSION="${VERSION_ID}"
- SYSCODENAME="${VERSION_CODENAME}"
- SYSARCH="$(uname -m)"
+ if [ -z "${SKIP_DISTRO_DETECTION}" ]; then
+ os_release_file=
+ if [ -s "/etc/os-release" ] && [ -r "/etc/os-release" ]; then
+ os_release_file="/etc/os-release"
+ elif [ -s "/usr/lib/os-release" ] && [ -r "/usr/lib/os-release" ]; then
+ os_release_file="/usr/lib/os-release"
+ else
+ warning "Cannot find usable OS release information. Native packages will not be available for this install."
+ fi
- supported_compat_names="debian ubuntu centos fedora opensuse ol arch"
+ if [ -n "${os_release_file}" ]; then
+ # shellcheck disable=SC1090
+ . "${os_release_file}"
- if str_in_list "${DISTRO}" "${supported_compat_names}"; then
- DISTRO_COMPAT_NAME="${DISTRO}"
+ DISTRO="${ID}"
+ SYSVERSION="${VERSION_ID}"
+ SYSCODENAME="${VERSION_CODENAME}"
else
- case "${DISTRO}" in
- opensuse-leap)
- DISTRO_COMPAT_NAME="opensuse"
- ;;
- cloudlinux|almalinux|rocky|rhel)
- DISTRO_COMPAT_NAME="centos"
- ;;
- artix|manjaro|obarun)
- DISTRO_COMPAT_NAME="arch"
- ;;
- *)
- DISTRO_COMPAT_NAME="unknown"
- ;;
- esac
+ DISTRO="unknown"
+ DISTRO_COMPAT_NAME="unknown"
+ SYSVERSION="unknown"
+ SYSCODENAME="unknown"
fi
+ else
+ warning "Distribution auto-detection overridden by user. This is not guaranteed to work, and is not officially supported."
+ fi
- case "${DISTRO_COMPAT_NAME}" in
- centos|ol)
- SYSVERSION=$(echo "$SYSVERSION" | cut -d'.' -f1)
- ;;
- esac
+ supported_compat_names="debian ubuntu centos fedora opensuse ol amzn arch"
+
+ if str_in_list "${DISTRO}" "${supported_compat_names}"; then
+ DISTRO_COMPAT_NAME="${DISTRO}"
else
- DISTRO="unknown"
- DISTRO_COMPAT_NAME="unknown"
- SYSVERSION="unknown"
- SYSCODENAME="unknown"
- SYSARCH="$(uname -m)"
+ case "${DISTRO}" in
+ opensuse-leap) DISTRO_COMPAT_NAME="opensuse" ;;
+ cloudlinux|almalinux|rocky|rhel) DISTRO_COMPAT_NAME="centos" ;;
+ artix|manjaro|obarun) DISTRO_COMPAT_NAME="arch" ;;
+ *) DISTRO_COMPAT_NAME="unknown" ;;
+ esac
fi
+
+ case "${DISTRO_COMPAT_NAME}" in
+ centos|ol) SYSVERSION=$(echo "$SYSVERSION" | cut -d'.' -f1) ;;
+ esac
;;
Darwin)
SYSTYPE="Darwin"
SYSVERSION="$(sw_vers -buildVersion)"
- SYSARCH="$(uname -m)"
;;
FreeBSD)
SYSTYPE="FreeBSD"
SYSVERSION="$(uname -K)"
- SYSARCH="$(uname -m)"
- ;;
- *)
- fatal "Unsupported system type detected. Netdata cannot be installed on this system using this script." F0200
;;
+ *) fatal "Unsupported system type detected. Netdata cannot be installed on this system using this script." F0200 ;;
esac
}
@@ -800,6 +800,7 @@ uninstall() {
return 0
else
progress "Found existing netdata-uninstaller. Running it.."
+ # shellcheck disable=SC2086
if ! run_script "${uninstaller}" ${FLAGS}; then
warning "Uninstaller failed. Some parts of Netdata may still be present on the system."
fi
@@ -813,6 +814,7 @@ uninstall() {
progress "Downloading netdata-uninstaller ..."
download "${uninstaller_url}" "${tmpdir}/netdata-uninstaller.sh"
chmod +x "${tmpdir}/netdata-uninstaller.sh"
+ # shellcheck disable=SC2086
if ! run_script "${tmpdir}/netdata-uninstaller.sh" ${FLAGS}; then
warning "Uninstaller failed. Some parts of Netdata may still be present on the system."
fi
@@ -858,7 +860,7 @@ detect_existing_install() {
if [ -n "${ndprefix}" ]; then
typefile="${ndprefix}/etc/netdata/.install-type"
if [ -r "${typefile}" ]; then
- ${ROOTCMD} sh -c "cat \"${typefile}\" > \"${tmpdir}/install-type\""
+ run_as_root sh -c "cat \"${typefile}\" > \"${tmpdir}/install-type\""
# shellcheck disable=SC1090,SC1091
. "${tmpdir}/install-type"
else
@@ -868,7 +870,7 @@ detect_existing_install() {
envfile="${ndprefix}/etc/netdata/.environment"
if [ "${INSTALL_TYPE}" = "unknown" ] || [ "${INSTALL_TYPE}" = "custom" ]; then
if [ -r "${envfile}" ]; then
- ${ROOTCMD} sh -c "cat \"${envfile}\" > \"${tmpdir}/environment\""
+ run_as_root sh -c "cat \"${envfile}\" > \"${tmpdir}/environment\""
# shellcheck disable=SC1091
. "${tmpdir}/environment"
if [ -n "${NETDATA_IS_STATIC_INSTALL}" ]; then
@@ -903,15 +905,15 @@ handle_existing_install() {
progress "Found an existing netdata install at ${ndprefix}, with installation type '${INSTALL_TYPE}'."
fi
- if [ -n "${NETDATA_REINSTALL}" ] || [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then
+ if [ "${ACTION}" = "reinstall" ] || [ "${ACTION}" = "unsafe-reinstall" ]; then
progress "Found an existing netdata install at ${ndprefix}, but user requested reinstall, continuing."
case "${INSTALL_TYPE}" in
- binpkg-*) NETDATA_ONLY_NATIVE=1 ;;
- *-build) NETDATA_ONLY_BUILD=1 ;;
- *-static) NETDATA_ONLY_STATIC=1 ;;
+ binpkg-*) NETDATA_FORCE_METHOD='native' ;;
+ *-build) NETDATA_FORCE_METHOD='build' ;;
+ *-static) NETDATA_FORCE_METHOD='static' ;;
*)
- if [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then
+ if [ "${ACTION}" = "unsafe-reinstall" ]; then
warning "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, but the user has requested we proceed."
elif [ "${INTERACTIVE}" -eq 0 ]; then
fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting." F0104
@@ -941,9 +943,9 @@ handle_existing_install() {
failmsg="We do not support trying to update or claim installations when we cannot determine the install type. You will need to uninstall the existing install using the same method you used to install it to proceed. ${claimonly_notice}"
promptmsg="Attempting to update an existing install is not officially supported. It may work, but it also might break your system. ${claimonly_notice} Are you sure you want to continue?"
fi
- if [ "${INTERACTIVE}" -eq 0 ] && [ "${NETDATA_CLAIM_ONLY}" -eq 0 ]; then
+ if [ "${INTERACTIVE}" -eq 0 ] && [ "${ACTION}" != "claim" ]; then
fatal "${failmsg}" F0106
- elif [ "${INTERACTIVE}" -eq 1 ] && [ "${NETDATA_CLAIM_ONLY}" -eq 0 ]; then
+ elif [ "${INTERACTIVE}" -eq 1 ] && [ "${ACTION}" != "claim" ]; then
if confirm "${promptmsg}"; then
progress "OK, continuing"
else
@@ -954,7 +956,7 @@ handle_existing_install() {
ret=0
- if [ "${NETDATA_CLAIM_ONLY}" -eq 0 ]; then
+ if [ "${ACTION}" != "claim" ]; then
if ! update; then
warning "Failed to update existing Netdata install at ${ndprefix}."
else
@@ -969,7 +971,7 @@ handle_existing_install() {
INSTALL_PREFIX="${ndprefix}"
claim
ret=$?
- elif [ "${NETDATA_CLAIM_ONLY}" -eq 1 ]; then
+ elif [ "${ACTION}" = "claim" ]; then
fatal "User asked to claim, but did not proide a claiming token." F0202
else
progress "Not attempting to claim existing install at ${ndprefix} (no claiming token provided)."
@@ -985,8 +987,8 @@ handle_existing_install() {
fatal "This is an OCI container, use the regular container lifecycle management commands for your container tools instead of this script for managing it." F0203
;;
*)
- if [ -n "${NETDATA_REINSTALL}" ] || [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then
- if [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then
+ if [ "${ACTION}" = "reinstall" ] || [ "${ACTION}" = "unsafe-reinstall" ]; then
+ if [ "${ACTION}" = "unsafe-reinstall" ]; then
warning "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, but the user has requested we proceed."
elif [ "${INTERACTIVE}" -eq 0 ]; then
fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting." F0104
@@ -1007,7 +1009,7 @@ handle_existing_install() {
cleanup
trap - EXIT
exit $ret
- elif [ "${NETDATA_CLAIM_ONLY}" -eq 1 ]; then
+ elif [ "${ACTION}" = "claim" ]; then
fatal "User asked to claim, but did not proide a claiming token." F0202
else
fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported by this script, refusing to proceed." F0103
@@ -1022,30 +1024,30 @@ soft_disable_cloud() {
cloud_prefix="${INSTALL_PREFIX}/var/lib/netdata/cloud.d"
- run ${ROOTCMD} mkdir -p "${cloud_prefix}"
+ run_as_root mkdir -p "${cloud_prefix}"
cat > "${tmpdir}/cloud.conf" << EOF
[global]
enabled = no
EOF
- run ${ROOTCMD} cp "${tmpdir}/cloud.conf" "${cloud_prefix}/cloud.conf"
+ run_as_root cp "${tmpdir}/cloud.conf" "${cloud_prefix}/cloud.conf"
if [ -z "${NETDATA_NO_START}" ]; then
case "${SYSTYPE}" in
- Darwin) run ${ROOTCMD} launchctl kickstart -k com.github.netdata ;;
- FreeBSD) run ${ROOTCMD} service netdata restart ;;
+ Darwin) run_as_root launchctl kickstart -k com.github.netdata ;;
+ FreeBSD) run_as_root service netdata restart ;;
Linux)
- initpath="$(${ROOTCMD} readlink /proc/1/exe)"
+ initpath="$(run_as_root readlink /proc/1/exe)"
if command -v service > /dev/null 2>&1; then
- run ${ROOTCMD} service netdata restart
+ run_as_root service netdata restart
elif command -v rc-service > /dev/null 2>&1; then
- run ${ROOTCMD} rc-service netdata restart
+ run_as_root rc-service netdata restart
elif [ "$(basename "${initpath}" 2> /dev/null)" = "systemd" ]; then
- run ${ROOTCMD} systemctl restart netdata
+ run_as_root systemctl restart netdata
elif [ -f /etc/init.d/netdata ]; then
- run ${ROOTCMD} /etc/init.d/netdata restart
+ run_as_root /etc/init.d/netdata restart
fi
;;
esac
@@ -1053,7 +1055,7 @@ EOF
}
confirm_install_prefix() {
- if [ -n "${INSTALL_PREFIX}" ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
+ if [ -n "${INSTALL_PREFIX}" ] && [ "${NETDATA_FORCE_METHOD}" != 'build' ]; then
fatal "The --install-prefix option is only supported together with the --build-only option." F0204
fi
@@ -1135,8 +1137,14 @@ claim() {
NETDATA_CLAIM_PATH="${INSTALL_PREFIX}/netdata/usr/sbin/netdata-claim.sh"
fi
- if [ ! -x "${NETDATA_CLAIM_PATH}" ]; then
+ if [ -z "${NETDATA_CLAIM_PATH}" ]; then
fatal "Unable to find usable claiming script. Reinstalling Netdata may resolve this." F050B
+ elif [ ! -e "${NETDATA_CLAIM_PATH}" ]; then
+ fatal "${NETDATA_CLAIM_PATH} does not exist." F0512
+ elif [ ! -f "${NETDATA_CLAIM_PATH}" ]; then
+ fatal "${NETDATA_CLAIM_PATH} is not a file." F0513
+ elif [ ! -x "${NETDATA_CLAIM_PATH}" ]; then
+ fatal "Claiming script at ${NETDATA_CLAIM_PATH} is not executable. Reinstalling Netdata may resolve this." F0514
fi
if ! is_netdata_running; then
@@ -1144,58 +1152,30 @@ claim() {
fi
# shellcheck disable=SC2086
- run ${ROOTCMD} "${NETDATA_CLAIM_PATH}" -token="${NETDATA_CLAIM_TOKEN}" -rooms="${NETDATA_CLAIM_ROOMS}" -url="${NETDATA_CLAIM_URL}" ${NETDATA_CLAIM_EXTRA}
+ run_as_root "${NETDATA_CLAIM_PATH}" -token="${NETDATA_CLAIM_TOKEN}" -rooms="${NETDATA_CLAIM_ROOMS}" -url="${NETDATA_CLAIM_URL}" ${NETDATA_CLAIM_EXTRA}
case $? in
0)
progress "Successfully claimed node"
return 0
;;
- 1)
- warning "Unable to claim node due to invalid claiming options. If you are seeing this message, you’ve probably found a bug and should open a bug report at ${AGENT_BUG_REPORT_URL}"
- ;;
- 2)
- warning "Unable to claim node due to issues creating the claiming directory or preparing the local claiming key. Make sure you have a working openssl command and that ${INSTALL_PREFIX}/var/lib/netdata/cloud.d exists, then try again."
- ;;
- 3)
- warning "Unable to claim node due to missing dependencies. Usually this means that the Netdata Agent was built without support for Netdata Cloud. If you built the agent from source, please install all needed dependencies for Cloud support. If you used the regular installation script and see this error, please file a bug report at ${AGENT_BUG_REPORT_URL}."
- ;;
- 4)
- warning "Failed to claim node due to inability to connect to ${NETDATA_CLAIM_URL}. Usually this either means that the specified claiming URL is wrong, or that you are having networking problems."
- ;;
+ 1) warning "Unable to claim node due to invalid claiming options. If you are seeing this message, you’ve probably found a bug and should open a bug report at ${AGENT_BUG_REPORT_URL}" ;;
+ 2) warning "Unable to claim node due to issues creating the claiming directory or preparing the local claiming key. Make sure you have a working openssl command and that ${INSTALL_PREFIX}/var/lib/netdata/cloud.d exists, then try again." ;;
+ 3) warning "Unable to claim node due to missing dependencies. Usually this means that the Netdata Agent was built without support for Netdata Cloud. If you built the agent from source, please install all needed dependencies for Cloud support. If you used the regular installation script and see this error, please file a bug report at ${AGENT_BUG_REPORT_URL}." ;;
+ 4) warning "Failed to claim node due to inability to connect to ${NETDATA_CLAIM_URL}. Usually this either means that the specified claiming URL is wrong, or that you are having networking problems." ;;
5)
progress "Successfully claimed node, but was not able to notify the Netdata Agent. You will need to restart the Netdata service on this node before it will show up in the Cloud."
return 0
;;
- 8)
- warning "Failed to claim node due to an invalid agent ID. You can usually resolve this by removing ${INSTALL_PREFIX}/var/lib/netdata/registry/netdata.public.unique.id and restarting the agent. Then try to claim it again using the same options."
- ;;
- 9)
- warning "Failed to claim node due to an invalid node name. This probably means you tried to specify a custom name for this node (for example, using the --claim-hostname option), but the hostname itself was either empty or consisted solely of whitespace. You can resolve this by specifying a valid host name and trying again."
- ;;
- 10)
- warning "Failed to claim node due to an invalid room ID. This issue is most likely caused by a typo. Please check if the room(s) you are trying to add appear on the list of rooms provided to the --claim-rooms option ('${NETDATA_CLAIM_ROOMS}'). Then verify if the rooms are visible in Netdata Cloud and try again."
- ;;
- 11)
- warning "Failed to claim node due to an issue with the generated RSA key pair. You can usually resolve this by removing all files in ${INSTALL_PREFIX}/var/lib/netdata/cloud.d and then trying again."
- ;;
- 12)
- warning "Failed to claim node due to an invalid or expired claiming token. Please check that the token specified with the --claim-token option ('${NETDATA_CLAIM_TOKEN}') matches what you see in the Cloud and try again."
- ;;
- 13)
- warning "Failed to claim node because the Cloud thinks it is already claimed. If this node was created by cloning a VM or as a container from a template, please remove the file ${INSTALL_PREFIX}/var/lib/netdata/registry/netdata.public.unique.id and restart the agent. Then try to claim it again with the same options. Otherwise, if you are certain this node has never been claimed before, you can use the --claim-id option to specify a new node ID to use for claiming, for example by using the uuidgen command like so: --claim-id \"\$(uuidgen)\""
- ;;
- 14)
- warning "Failed to claim node because the node is already in the process of being claimed. You should not need to do anything to resolve this, the node should show up properly in the Cloud soon. If it does not, please report a bug at ${AGENT_BUG_REPORT_URL}."
- ;;
- 15|16|17)
- warning "Failed to claim node due to an internal server error in the Cloud. Please retry claiming this node later, and if you still see this message file a bug report at ${CLOUD_BUG_REPORT_URL}."
- ;;
- 18)
- warning "Unable to claim node because this Netdata installation does not have a unique ID yet. Make sure the agent is running and started up correctly, and then try again."
- ;;
- *)
- warning "Failed to claim node for an unknown reason. This usually means either networking problems or a bug. Please retry claiming later, and if you still see this message file a bug report at ${AGENT_BUG_REPORT_URL}"
- ;;
+ 8) warning "Failed to claim node due to an invalid agent ID. You can usually resolve this by removing ${INSTALL_PREFIX}/var/lib/netdata/registry/netdata.public.unique.id and restarting the agent. Then try to claim it again using the same options." ;;
+ 9) warning "Failed to claim node due to an invalid node name. This probably means you tried to specify a custom name for this node (for example, using the --claim-hostname option), but the hostname itself was either empty or consisted solely of whitespace. You can resolve this by specifying a valid host name and trying again." ;;
+ 10) warning "Failed to claim node due to an invalid room ID. This issue is most likely caused by a typo. Please check if the room(s) you are trying to add appear on the list of rooms provided to the --claim-rooms option ('${NETDATA_CLAIM_ROOMS}'). Then verify if the rooms are visible in Netdata Cloud and try again." ;;
+ 11) warning "Failed to claim node due to an issue with the generated RSA key pair. You can usually resolve this by removing all files in ${INSTALL_PREFIX}/var/lib/netdata/cloud.d and then trying again." ;;
+ 12) warning "Failed to claim node due to an invalid or expired claiming token. Please check that the token specified with the --claim-token option ('${NETDATA_CLAIM_TOKEN}') matches what you see in the Cloud and try again." ;;
+ 13) warning "Failed to claim node because the Cloud thinks it is already claimed. If this node was created by cloning a VM or as a container from a template, please remove the file ${INSTALL_PREFIX}/var/lib/netdata/registry/netdata.public.unique.id and restart the agent. Then try to claim it again with the same options. Otherwise, if you are certain this node has never been claimed before, you can use the --claim-id option to specify a new node ID to use for claiming, for example by using the uuidgen command like so: --claim-id \"\$(uuidgen)\"" ;;
+ 14) warning "Failed to claim node because the node is already in the process of being claimed. You should not need to do anything to resolve this, the node should show up properly in the Cloud soon. If it does not, please report a bug at ${AGENT_BUG_REPORT_URL}." ;;
+ 15|16|17) warning "Failed to claim node due to an internal server error in the Cloud. Please retry claiming this node later, and if you still see this message file a bug report at ${CLOUD_BUG_REPORT_URL}." ;;
+ 18) warning "Unable to claim node because this Netdata installation does not have a unique ID yet. Make sure the agent is running and started up correctly, and then try again." ;;
+ *) warning "Failed to claim node for an unknown reason. This usually means either networking problems or a bug. Please retry claiming later, and if you still see this message file a bug report at ${AGENT_BUG_REPORT_URL}" ;;
esac
if [ -z "${NETDATA_NEW_INSTALL}" ]; then
@@ -1224,16 +1204,16 @@ set_auto_updates() {
if [ "${DRY_RUN}" -eq 1 ]; then
progress "Would have attempted to enable automatic updates."
# This first case is for catching using a new kickstart script with an old build. It can be safely removed after v1.34.0 is released.
- elif ! grep -q '\-\-enable-auto-updates' ${updater}; then
+ elif ! grep -q '\-\-enable-auto-updates' "${updater}"; then
echo
- elif ! ${ROOTCMD} ${updater} --enable-auto-updates "${NETDATA_AUTO_UPDATE_TYPE}"; then
+ elif ! run_as_root "${updater}" --enable-auto-updates "${NETDATA_AUTO_UPDATE_TYPE}"; then
warning "Failed to enable auto updates. Netdata will still work, but you will need to update manually."
fi
else
if [ "${DRY_RUN}" -eq 1 ]; then
progress "Would have attempted to disable automatic updates."
else
- ${ROOTCMD} ${updater} --disable-auto-updates
+ run_as_root "${updater}" --disable-auto-updates
fi
fi
}
@@ -1251,7 +1231,7 @@ pkg_installed() {
dpkg-query --show --showformat '${Status}' "${1}" 2>&1 | cut -f 1 -d ' ' | grep -q '^install$'
return $?
;;
- centos|fedora|opensuse|ol)
+ centos|fedora|opensuse|ol|amzn)
rpm -q "${1}" > /dev/null 2>&1
return $?
;;
@@ -1263,9 +1243,7 @@ pkg_installed() {
pacman -Qi "${1}" > /dev/null 2>&1
return $?
;;
- *)
- return 1
- ;;
+ *) return 1 ;;
esac
;;
Darwin)
@@ -1295,7 +1273,7 @@ netdata_avail_check() {
env DEBIAN_FRONTEND=noninteractive apt-cache policy netdata | grep -q repo.netdata.cloud/repos/;
return $?
;;
- centos|fedora|ol)
+ centos|fedora|ol|amzn)
# shellcheck disable=SC2086
${pm_cmd} search --nogpgcheck -v netdata | grep -qE 'Repo *: netdata(-edge)?$'
return $?
@@ -1304,9 +1282,7 @@ netdata_avail_check() {
zypper packages -r "$(zypper repos | grep -E 'netdata |netdata-edge ' | cut -f 1 -d '|' | tr -d ' ')" | grep -E 'netdata '
return $?
;;
- *)
- return 1
- ;;
+ *) return 1 ;;
esac
}
@@ -1323,7 +1299,7 @@ check_special_native_deps() {
progress "EPEL is available, attempting to install so that required dependencies are available."
# shellcheck disable=SC2086
- if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} epel-release; then
+ if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} epel-release; then
warning "Failed to install EPEL, even though it is required to install native packages on this system."
return 1
fi
@@ -1334,12 +1310,39 @@ check_special_native_deps() {
fi
}
+common_rpm_opts() {
+ pkg_type="rpm"
+ pkg_suffix=".noarch"
+ pkg_vsep="-"
+ INSTALL_TYPE="binpkg-rpm"
+ NATIVE_VERSION="${INSTALL_VERSION:+"-${INSTALL_VERSION}.${SYSARCH}"}"
+}
+
+common_dnf_opts() {
+ if command -v dnf > /dev/null; then
+ pm_cmd="dnf"
+ repo_subcmd="makecache"
+ else
+ pm_cmd="yum"
+ fi
+ pkg_install_opts="${interactive_opts}"
+ repo_update_opts="${interactive_opts}"
+ uninstall_subcmd="remove"
+}
+
try_package_install() {
failed_refresh_msg="Failed to refresh repository metadata. ${BADNET_MSG} or by misconfiguration of one or more rpackage repositories in the system package manager configuration."
- if [ -z "${DISTRO}" ] || [ "${DISTRO}" = "unknown" ]; then
+ if [ -z "${DISTRO_COMPAT_NAME}" ] || [ "${DISTRO_COMPAT_NAME}" = "unknown" ]; then
warning "Unable to determine Linux distribution for native packages."
return 2
+ elif [ -z "${SYSCODENAME}" ]; then
+ case "${DISTRO_COMPAT_NAME}" in
+ debian|ubuntu)
+ warning "Release codename not set. Unable to check availability of native packages for this system."
+ return 2
+ ;;
+ esac
fi
set_tmpdir
@@ -1365,97 +1368,43 @@ try_package_install() {
fi
case "${DISTRO_COMPAT_NAME}" in
- debian)
- needs_early_refresh=1
- pm_cmd="apt-get"
- repo_subcmd="update"
- repo_prefix="debian/${SYSCODENAME}"
- pkg_type="deb"
- pkg_suffix="+debian${SYSVERSION}_all"
- pkg_vsep="_"
- pkg_install_opts="${interactive_opts}"
- repo_update_opts="${interactive_opts}"
- uninstall_subcmd="purge"
- INSTALL_TYPE="binpkg-deb"
- NATIVE_VERSION="${INSTALL_VERSION:+"=${INSTALL_VERSION}"}"
- ;;
- ubuntu)
+ debian|ubuntu)
needs_early_refresh=1
pm_cmd="apt-get"
repo_subcmd="update"
- repo_prefix="ubuntu/${SYSCODENAME}"
pkg_type="deb"
- pkg_suffix="+ubuntu${SYSVERSION}_all"
pkg_vsep="_"
pkg_install_opts="${interactive_opts}"
repo_update_opts="${interactive_opts}"
uninstall_subcmd="purge"
+ repo_prefix="${DISTRO_COMPAT_NAME}/${SYSCODENAME}"
+ pkg_suffix="+${DISTRO_COMPAT_NAME}${SYSVERSION}_all"
INSTALL_TYPE="binpkg-deb"
NATIVE_VERSION="${INSTALL_VERSION:+"=${INSTALL_VERSION}"}"
;;
centos)
- if command -v dnf > /dev/null; then
- pm_cmd="dnf"
- repo_subcmd="makecache"
- else
- pm_cmd="yum"
- fi
+ common_rpm_opts
+ common_dnf_opts
repo_prefix="el/${SYSVERSION}"
- pkg_type="rpm"
- pkg_suffix=".noarch"
- pkg_vsep="-"
- pkg_install_opts="${interactive_opts}"
- repo_update_opts="${interactive_opts}"
- uninstall_subcmd="remove"
- INSTALL_TYPE="binpkg-rpm"
- NATIVE_VERSION="${INSTALL_VERSION:+"-${INSTALL_VERSION}.${SYSARCH}"}"
;;
- fedora)
- if command -v dnf > /dev/null; then
- pm_cmd="dnf"
- repo_subcmd="makecache"
- else
- pm_cmd="yum"
- fi
- repo_prefix="fedora/${SYSVERSION}"
- pkg_type="rpm"
- pkg_suffix=".noarch"
- pkg_vsep="-"
- pkg_install_opts="${interactive_opts}"
- repo_update_opts="${interactive_opts}"
- uninstall_subcmd="remove"
- INSTALL_TYPE="binpkg-rpm"
- NATIVE_VERSION="${INSTALL_VERSION:+"-${INSTALL_VERSION}.${SYSARCH}"}"
+ fedora|ol)
+ common_rpm_opts
+ common_dnf_opts
+ repo_prefix="${DISTRO_COMPAT_NAME}/${SYSVERSION}"
;;
opensuse)
+ common_rpm_opts
pm_cmd="zypper"
repo_subcmd="--gpg-auto-import-keys refresh"
repo_prefix="opensuse/${SYSVERSION}"
- pkg_type="rpm"
- pkg_suffix=".noarch"
- pkg_vsep="-"
pkg_install_opts="${interactive_opts} --allow-unsigned-rpm"
repo_update_opts=""
uninstall_subcmd="remove"
- INSTALL_TYPE="binpkg-rpm"
- NATIVE_VERSION="${INSTALL_VERSION:+"-${INSTALL_VERSION}.${SYSARCH}"}"
;;
- ol)
- if command -v dnf > /dev/null; then
- pm_cmd="dnf"
- repo_subcmd="makecache"
- else
- pm_cmd="yum"
- fi
- repo_prefix="ol/${SYSVERSION}"
- pkg_type="rpm"
- pkg_suffix=".noarch"
- pkg_vsep="-"
- pkg_install_opts="${interactive_opts}"
- repo_update_opts="${interactive_opts}"
- uninstall_subcmd="remove"
- INSTALL_TYPE="binpkg-rpm"
- NATIVE_VERSION="${INSTALL_VERSION:+"-${INSTALL_VERSION}.${SYSARCH}"}"
+ amzn)
+ common_rpm_opts
+ common_dnf_opts
+ repo_prefix="amazonlinux/${SYSVERSION}"
;;
*)
warning "We do not provide native packages for ${DISTRO}."
@@ -1463,6 +1412,10 @@ try_package_install() {
;;
esac
+ if [ -n "${SKIP_DISTRO_DETECTION}" ]; then
+ warning "Attempting to use native packages with a distro override. This is not officially supported, but may work in some cases. If your system requires a distro override to use native packages, please open an feature request at ${AGENT_BUG_REPORT_URL} about it so that we can update the installer to auto-detect this."
+ fi
+
if [ -n "${INSTALL_VERSION}" ]; then
if echo "${INSTALL_VERSION}" | grep -q "nightly"; then
new_release="-edge"
@@ -1503,21 +1456,21 @@ try_package_install() {
if [ -n "${needs_early_refresh}" ]; then
# shellcheck disable=SC2086
- if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
+ if ! run_as_root env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
warning "${failed_refresh_msg}"
return 2
fi
fi
# shellcheck disable=SC2086
- if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
+ if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
warning "Failed to install repository configuration package."
return 2
fi
if [ -n "${repo_subcmd}" ]; then
# shellcheck disable=SC2086
- if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
+ if ! run_as_root env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
fatal "${failed_refresh_msg}" F0205
fi
fi
@@ -1525,8 +1478,8 @@ try_package_install() {
progress "Repository configuration is already present, attempting to install netdata."
fi
- if [ "${REPO_ACTION}" = "repositories-only" ]; then
- progress "Successfully installed repository configuration package."
+ if [ "${ACTION}" = "repositories-only" ]; then
+ progress "Successfully installed repository configuraion package."
deferred_warnings
cleanup
trap - EXIT
@@ -1538,7 +1491,7 @@ try_package_install() {
if [ -z "${NO_CLEANUP}" ]; then
progress "Attempting to uninstall repository configuration package."
# shellcheck disable=SC2086
- run ${ROOTCMD} env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}"
+ run_as_root env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}"
fi
return 2
fi
@@ -1548,23 +1501,23 @@ try_package_install() {
if [ -z "${NO_CLEANUP}" ]; then
progress "Attempting to uninstall repository configuration package."
# shellcheck disable=SC2086
- run ${ROOTCMD} env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}"
+ run_as_root env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}"
fi
return 2
fi
if [ "${NETDATA_DISABLE_TELEMETRY}" -eq 1 ]; then
- run ${ROOTCMD} mkdir -p "/etc/netdata"
- run ${ROOTCMD} touch "/etc/netdata/.opt-out-from-anonymous-statistics"
+ run_as_root mkdir -p "/etc/netdata"
+ run_as_root touch "/etc/netdata/.opt-out-from-anonymous-statistics"
fi
# shellcheck disable=SC2086
- if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} "netdata${NATIVE_VERSION}"; then
+ if ! run_as_root env ${env} ${pm_cmd} install ${pkg_install_opts} "netdata${NATIVE_VERSION}"; then
warning "Failed to install Netdata package."
if [ -z "${NO_CLEANUP}" ]; then
progress "Attempting to uninstall repository configuration package."
# shellcheck disable=SC2086
- run ${ROOTCMD} env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}"
+ run_as_root env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}"
fi
return 2
fi
@@ -1657,7 +1610,7 @@ try_static_install() {
progress "Installing netdata"
# shellcheck disable=SC2086
- if ! run ${ROOTCMD} sh "${tmpdir}/${netdata_agent}" ${opts} -- ${NETDATA_INSTALLER_OPTIONS}; then
+ if ! run_as_root sh "${tmpdir}/${netdata_agent}" ${opts} -- ${NETDATA_INSTALLER_OPTIONS}; then
warning "Failed to install static build of Netdata on ${SYSARCH}."
run rm -rf /opt/netdata
return 2
@@ -1666,16 +1619,16 @@ try_static_install() {
if [ "${DRY_RUN}" -ne 1 ]; then
install_type_file="/opt/netdata/etc/netdata/.install-type"
if [ -f "${install_type_file}" ]; then
- ${ROOTCMD} sh -c "cat \"${install_type_file}\" > \"${tmpdir}/install-type\""
- ${ROOTCMD} chown "$(id -u)":"$(id -g)" "${tmpdir}/install-type"
+ run_as_root sh -c "cat \"${install_type_file}\" > \"${tmpdir}/install-type\""
+ run_as_root chown "$(id -u)":"$(id -g)" "${tmpdir}/install-type"
# shellcheck disable=SC1090,SC1091
. "${tmpdir}/install-type"
cat > "${tmpdir}/install-type" <<- EOF
INSTALL_TYPE='kickstart-static'
PREBUILT_ARCH='${PREBUILT_ARCH}'
EOF
- ${ROOTCMD} chown netdata:netdata "${tmpdir}/install-type"
- ${ROOTCMD} cp "${tmpdir}/install-type" "${install_type_file}"
+ run_as_root chown netdata:netdata "${tmpdir}/install-type"
+ run_as_root cp "${tmpdir}/install-type" "${install_type_file}"
fi
fi
}
@@ -1728,14 +1681,8 @@ install_local_build_dependencies() {
opts="--dont-wait --non-interactive"
fi
- if [ "${SYSTYPE}" = "Darwin" ]; then
- sudo=""
- else
- sudo="${ROOTCMD}"
- fi
-
# shellcheck disable=SC2086
- if ! run ${sudo} "${bash}" "${tmpdir}/install-required-packages.sh" ${opts} netdata; then
+ if ! run_as_root "${bash}" "${tmpdir}/install-required-packages.sh" ${opts} netdata; then
warning "Failed to install all required packages, but installation might still be possible."
fi
}
@@ -1776,9 +1723,7 @@ build_and_install() {
fatal "netdata-installer.sh failed to run: Encountered an unhandled error in the installer code." I0000
fi
;;
- 2)
- fatal "Insufficient RAM to install netdata." F0008
- ;;
+ 2) fatal "Insufficient RAM to install netdata." F0008 ;;
esac
}
@@ -1858,34 +1803,36 @@ prepare_offline_install_source() {
run cd "${1}" || fatal "Failed to switch to target directory for offline install preparation." F0505
- if [ "${NETDATA_ONLY_NATIVE}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
- set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "x86_64"
+ case "${NETDATA_FORCE_METHOD}" in
+ static|'')
+ set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "x86_64"
- if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
- for arch in ${STATIC_INSTALL_ARCHES}; do
- set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "${arch}"
+ if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
+ for arch in ${STATIC_INSTALL_ARCHES}; do
+ set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "${arch}"
- progress "Fetching ${NETDATA_STATIC_ARCHIVE_URL}"
- if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "netdata-${arch}-latest.gz.run"; then
- warning "Failed to download static installer archive for ${arch}. ${BADNET_MSG}."
- fi
- done
- legacy=0
- else
- warning "Selected version of Netdata only provides static builds for x86_64. You will only be able to install on x86_64 systems with this offline install source."
- progress "Fetching ${NETDATA_STATIC_ARCHIVE_OLD_URL}"
- legacy=1
+ progress "Fetching ${NETDATA_STATIC_ARCHIVE_URL}"
+ if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "netdata-${arch}-latest.gz.run"; then
+ warning "Failed to download static installer archive for ${arch}. ${BADNET_MSG}."
+ fi
+ done
+ legacy=0
+ else
+ warning "Selected version of Netdata only provides static builds for x86_64. You will only be able to install on x86_64 systems with this offline install source."
+ progress "Fetching ${NETDATA_STATIC_ARCHIVE_OLD_URL}"
+ legacy=1
- if ! download "${NETDATA_STATIC_ARCHIVE_OLD_URL}" "netdata-x86_64-latest.gz.run"; then
- warning "Failed to download static installer archive for x86_64. ${BADNET_MSG}."
+ if ! download "${NETDATA_STATIC_ARCHIVE_OLD_URL}" "netdata-x86_64-latest.gz.run"; then
+ warning "Failed to download static installer archive for x86_64. ${BADNET_MSG}."
+ fi
fi
- fi
- progress "Fetching ${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}"
- if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "sha256sums.txt"; then
- fatal "Failed to download checksum file. ${BADNET_MSG}." F0506
- fi
- fi
+ progress "Fetching ${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}"
+ if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "sha256sums.txt"; then
+ fatal "Failed to download checksum file. ${BADNET_MSG}." F0506
+ fi
+ ;;
+ esac
if [ "${legacy:-0}" -eq 1 ]; then
sed -e 's/netdata-latest.gz.run/netdata-x86_64-latest.gz.run' sha256sums.txt > sha256sums.tmp
@@ -1935,7 +1882,7 @@ prepare_offline_install_source() {
# Per system-type install logic
install_on_linux() {
- if [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ] && [ -z "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
+ if [ "${NETDATA_FORCE_METHOD}" != 'static' ] && [ "${NETDATA_FORCE_METHOD}" != 'build' ] && [ -z "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
SELECTED_INSTALL_METHOD="native"
try_package_install
@@ -1944,20 +1891,17 @@ install_on_linux() {
NETDATA_INSTALL_SUCCESSFUL=1
INSTALL_PREFIX="/"
;;
- 1)
- fatal "Unable to install on this system." F0300
- ;;
+ 1) fatal "Unable to install on this system." F0300 ;;
2)
- if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then
- fatal "Could not install native binary packages." F0301
- else
- warning "Could not install native binary packages, falling back to alternative installation method."
- fi
+ case "${NETDATA_FORCE_METHOD}" in
+ native) fatal "Could not install native binary packages." F0301 ;;
+ *) warning "Could not install native binary packages, falling back to alternative installation method." ;;
+ esac
;;
esac
fi
- if [ "${NETDATA_ONLY_NATIVE}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ] && [ -z "${NETDATA_INSTALL_SUCCESSFUL}" ]; then
+ if [ "${NETDATA_FORCE_METHOD}" != 'native' ] && [ "${NETDATA_FORCE_METHOD}" != 'build' ] && [ -z "${NETDATA_INSTALL_SUCCESSFUL}" ]; then
SELECTED_INSTALL_METHOD="static"
INSTALL_TYPE="kickstart-static"
try_static_install
@@ -1967,75 +1911,60 @@ install_on_linux() {
NETDATA_INSTALL_SUCCESSFUL=1
INSTALL_PREFIX="/opt/netdata"
;;
- 1)
- fatal "Unable to install on this system." F0302
- ;;
+ 1) fatal "Unable to install on this system." F0302 ;;
2)
- if [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then
- fatal "Could not install static build." F0303
- else
- warning "Could not install static build, falling back to alternative installation method."
- fi
+ case "${NETDATA_FORCE_METHOD}" in
+ static) fatal "Could not install static build." F0303 ;;
+ *) warning "Could not install static build, falling back to alternative installation method." ;;
+ esac
;;
esac
fi
- if [ "${NETDATA_ONLY_NATIVE}" -ne 1 ] && [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ -z "${NETDATA_INSTALL_SUCCESSFUL}" ]; then
+ if [ "${NETDATA_FORCE_METHOD}" != 'native' ] && [ "${NETDATA_FORCE_METHOD}" != 'static' ] && [ -z "${NETDATA_INSTALL_SUCCESSFUL}" ]; then
SELECTED_INSTALL_METHOD="build"
INSTALL_TYPE="kickstart-build"
try_build_install
case "$?" in
- 0)
- NETDATA_INSTALL_SUCCESSFUL=1
- ;;
- *)
- fatal "Unable to install on this system." F0304
- ;;
+ 0) NETDATA_INSTALL_SUCCESSFUL=1 ;;
+ *) fatal "Unable to install on this system." F0304 ;;
esac
fi
}
install_on_macos() {
- if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then
- fatal "User requested native package, but native packages are not available for macOS. Try installing without \`--only-native\` option." F0305
- elif [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then
- fatal "User requested static build, but static builds are not available for macOS. Try installing without \`--only-static\` option." F0306
- else
- SELECTED_INSTALL_METHOD="build"
- INSTALL_TYPE="kickstart-build"
- try_build_install
+ case "${NETDATA_FORCE_METHOD}" in
+ native) fatal "User requested native package, but native packages are not available for macOS. Try installing without \`--only-native\` option." F0305 ;;
+ static) fatal "User requested static build, but static builds are not available for macOS. Try installing without \`--only-static\` option." F0306 ;;
+ *)
+ SELECTED_INSTALL_METHOD="build"
+ INSTALL_TYPE="kickstart-build"
+ try_build_install
- case "$?" in
- 0)
- NETDATA_INSTALL_SUCCESSFUL=1
- ;;
- *)
- fatal "Unable to install on this system." F0307
- ;;
- esac
- fi
+ case "$?" in
+ 0) NETDATA_INSTALL_SUCCESSFUL=1 ;;
+ *) fatal "Unable to install on this system." F0307 ;;
+ esac
+ ;;
+ esac
}
install_on_freebsd() {
- if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then
- fatal "User requested native package, but native packages are not available for FreeBSD. Try installing without \`--only-native\` option." F0308
- elif [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then
- fatal "User requested static build, but static builds are not available for FreeBSD. Try installing without \`--only-static\` option." F0309
- else
- SELECTED_INSTALL_METHOD="build"
- INSTALL_TYPE="kickstart-build"
- try_build_install
+ case "${NETDATA_FORCE_METHOD}" in
+ native) fatal "User requested native package, but native packages are not available for FreeBSD. Try installing without \`--only-native\` option." F0308 ;;
+ static) fatal "User requested static build, but static builds are not available for FreeBSD. Try installing without \`--only-static\` option." F0309 ;;
+ *)
+ SELECTED_INSTALL_METHOD="build"
+ INSTALL_TYPE="kickstart-build"
+ try_build_install
- case "$?" in
- 0)
- NETDATA_INSTALL_SUCCESSFUL=1
- ;;
- *)
- fatal "Unable to install on this system." F030A
- ;;
- esac
- fi
+ case "$?" in
+ 0) NETDATA_INSTALL_SUCCESSFUL=1 ;;
+ *) fatal "Unable to install on this system." F030A ;;
+ esac
+ ;;
+ esac
}
# ======================================================================
@@ -2044,26 +1973,32 @@ install_on_freebsd() {
validate_args() {
check_claim_opts
+ if [ -n "${NETDATA_FORCE_METHOD}" ]; then
+ SELECTED_INSTALL_METHOD="${NETDATA_FORCE_METHOD}"
+ fi
+
+ if [ "${ACTION}" = "repositories-only" ] && [ "${NETDATA_FORCE_METHOD}" != "native" ]; then
+ fatal "Repositories can only be installed for native installs." F050D
+ fi
+
if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
- if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ] || [ "${NETDATA_ONLY_BUILD}" -eq 1 ]; then
- fatal "Offline installs are only supported for static builds currently." F0502
- fi
+ case "${NETDATA_FORCE_METHOD}" in
+ native|build) fatal "Offline installs are only supported for static builds currently." F0502 ;;
+ esac
fi
if [ -n "${LOCAL_BUILD_OPTIONS}" ]; then
- if [ "${NETDATA_ONLY_BUILD}" -eq 1 ]; then
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${LOCAL_BUILD_OPTIONS}"
- else
- fatal "Specifying local build options is only supported when the --build-only option is also specified." F0401
- fi
+ case "${NETDATA_FORCE_METHOD}" in
+ build) NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${LOCAL_BUILD_OPTIONS}" ;;
+ *) fatal "Specifying local build options is only supported when the --build-only option is also specified." F0401 ;;
+ esac
fi
if [ -n "${STATIC_INSTALL_OPTIONS}" ]; then
- if [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${STATIC_INSTALL_OPTIONS}"
- else
- fatal "Specifying installer options options is only supported when the --static-only option is also specified." F0402
- fi
+ case "${NETDATA_FORCE_METHOD}" in
+ static) NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${STATIC_INSTALL_OPTIONS}" ;;
+ *) fatal "Specifying installer options options is only supported when the --static-only option is also specified." F0402 ;;
+ esac
fi
if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ -n "${INSTALL_VERSION}" ]; then
@@ -2101,6 +2036,17 @@ validate_args() {
fi
}
+set_action() {
+ new_action="${1}"
+
+ if [ -n "${ACTION}" ]; then
+ warning "Ignoring previously specified '${ACTION}' operation in favor of '${new_action}' specified later on the command line."
+ fi
+
+ ACTION="${new_action}"
+ NETDATA_COMMAND="${new_action}"
+}
+
parse_args() {
while [ -n "${1}" ]; do
case "${1}" in
@@ -2114,33 +2060,35 @@ parse_args() {
"--dont-wait"|"--non-interactive") INTERACTIVE=0 ;;
"--interactive") INTERACTIVE=1 ;;
"--dry-run") DRY_RUN=1 ;;
+ "--release-channel")
+ RELEASE_CHANNEL="$(echo "${2}" | tr '[:upper:]' '[:lower:]')"
+ case "${RELEASE_CHANNEL}" in
+ nightly|stable|default) shift 1 ;;
+ *)
+ echo "Unrecognized value for --release-channel. Valid release channels are: stable, nightly, default"
+ exit 1
+ ;;
+ esac
+ ;;
"--stable-channel") RELEASE_CHANNEL="stable" ;;
+ "--nightly-channel") RELEASE_CHANNEL="nightly" ;;
+ "--reinstall") set_action 'reinstall' ;;
+ "--reinstall-even-if-unsafe") set_action 'unsafe-reinstall' ;;
+ "--reinstall-clean") set_action 'reinstall-clean' ;;
+ "--uninstall") set_action 'uninstall' ;;
+ "--claim-only") set_action 'claim' ;;
"--no-updates") NETDATA_AUTO_UPDATES=0 ;;
"--auto-update") NETDATA_AUTO_UPDATES="1" ;;
"--auto-update-method")
NETDATA_AUTO_UPDATE_TYPE="$(echo "${2}" | tr '[:upper:]' '[:lower:]')"
case "${NETDATA_AUTO_UPDATE_TYPE}" in
- systemd|interval|crontab)
- shift 1
- ;;
+ systemd|interval|crontab) shift 1 ;;
*)
echo "Unrecognized value for --auto-update-type. Valid values are: systemd, interval, crontab"
exit 1
;;
esac
;;
- "--reinstall")
- NETDATA_REINSTALL=1
- NETDATA_COMMAND="reinstall"
- ;;
- "--reinstall-even-if-unsafe")
- NETDATA_UNSAFE_REINSTALL=1
- NETDATA_COMMAND="unsafe-reinstall"
- ;;
- "--claim-only")
- NETDATA_CLAIM_ONLY=1
- NETDATA_COMMAND="claim-only"
- ;;
"--disable-cloud")
NETDATA_DISABLE_CLOUD=1
NETDATA_REQUIRE_CLOUD=0
@@ -2170,36 +2118,29 @@ parse_args() {
AUTO_UPDATE=0
shift 1
;;
- "--uninstall")
- ACTION="uninstall"
- NETDATA_COMMAND="uninstall"
- ;;
- "--reinstall-clean")
- ACTION="reinstall-clean"
- NETDATA_COMMAND="reinstall-clean"
+ "--distro-override")
+ if [ -n "${2}" ]; then
+ SKIP_DISTRO_DETECTION=1
+ DISTRO="$(echo "${2}" | cut -f 1 -d ':' | tr '[:upper:]' '[:lower:]')"
+ SYSVERSION="$(echo "${2}" | cut -f 2 -d ':')"
+ SYSCODENAME="$(echo "${2}" | cut -f 3 -d ':' | tr '[:upper:]' '[:lower:]')"
+
+ if [ -z "${SYSVERSION}" ]; then
+ fatal "You must specify a release as well as a distribution name." F0510
+ fi
+
+ shift 1
+ else
+ fatal "A distribution name and release must be specified for the --distro-override option." F050F
+ fi
;;
"--repositories-only")
- REPO_ACTION="repositories-only"
- NETDATA_COMMAND="repositories"
- ;;
- "--native-only")
- NETDATA_ONLY_NATIVE=1
- NETDATA_ONLY_STATIC=0
- NETDATA_ONLY_BUILD=0
- SELECTED_INSTALL_METHOD="native"
- ;;
- "--static-only")
- NETDATA_ONLY_STATIC=1
- NETDATA_ONLY_NATIVE=0
- NETDATA_ONLY_BUILD=0
- SELECTED_INSTALL_METHOD="static"
- ;;
- "--build-only")
- NETDATA_ONLY_BUILD=1
- NETDATA_ONLY_NATIVE=0
- NETDATA_ONLY_STATIC=0
- SELECTED_INSTALL_METHOD="build"
+ set_action 'repositories-only'
+ NETDATA_FORCE_METHOD="native"
;;
+ "--native-only") NETDATA_FORCE_METHOD="native" ;;
+ "--static-only") NETDATA_FORCE_METHOD="static" ;;
+ "--build-only") NETDATA_FORCE_METHOD="build" ;;
"--claim-token")
NETDATA_CLAIM_TOKEN="${2}"
shift 1
@@ -2219,12 +2160,8 @@ parse_args() {
NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}=${2}"
shift 1
;;
- verbose|insecure|noproxy|noreload|daemon-not-running)
- NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}"
- ;;
- *)
- warning "Ignoring unrecognized claiming option ${optname}"
- ;;
+ verbose|insecure|noproxy|noreload|daemon-not-running) NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}" ;;
+ *) warning "Ignoring unrecognized claiming option ${optname}" ;;
esac
;;
"--local-build-options")
@@ -2237,8 +2174,7 @@ parse_args() {
;;
"--prepare-offline-install-source")
if [ -n "${2}" ]; then
- ACTION="prepare-offline"
- NETDATA_COMMAND="prepare-offline"
+ set_action 'prepare-offline'
OFFLINE_TARGET="${2}"
shift 1
else
@@ -2253,9 +2189,7 @@ parse_args() {
fatal "A source directory must be specified with the --offline-install-source option." F0501
fi
;;
- *)
- fatal "Unrecognized option '${1}'. If you intended to pass this option to the installer code, please use either --local-build-options or --static-install-options to specify it instead." F050E
- ;;
+ *) fatal "Unrecognized option '${1}'. If you intended to pass this option to the installer code, please use either --local-build-options or --static-install-options to specify it instead." F050E ;;
esac
shift 1
done