summaryrefslogtreecommitdiffstats
path: root/packaging/installer/kickstart.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-09 04:52:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-06-09 04:52:39 +0000
commit89f3604407aff8f4cb2ed958252c61e23c767e24 (patch)
tree7fbf408102cab051557d38193524d8c6e991d070 /packaging/installer/kickstart.sh
parentAdding upstream version 1.34.1. (diff)
downloadnetdata-89f3604407aff8f4cb2ed958252c61e23c767e24.tar.xz
netdata-89f3604407aff8f4cb2ed958252c61e23c767e24.zip
Adding upstream version 1.35.0.upstream/1.35.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/installer/kickstart.sh')
-rwxr-xr-xpackaging/installer/kickstart.sh792
1 files changed, 579 insertions, 213 deletions
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
index ffc95155..a1079c3f 100755
--- a/packaging/installer/kickstart.sh
+++ b/packaging/installer/kickstart.sh
@@ -1,24 +1,30 @@
#!/bin/sh
#
# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Next unused error code: F050A
# ======================================================================
# Constants
AGENT_BUG_REPORT_URL="https://github.com/netdata/netdata/issues/new/choose"
CLOUD_BUG_REPORT_URL="https://github.com/netdata/netdata-cloud/issues/new/choose"
-DISCUSSIONS_URL="https://github.com/netdata/netdata/discussions"
+DEFAULT_RELEASE_CHANNEL="nightly"
DISCORD_INVITE="https://discord.gg/5ygS846fR6"
+DISCUSSIONS_URL="https://github.com/netdata/netdata/discussions"
+DISCUSSIONS_URL="https://github.com/netdata/netdata/discussions"
DOCS_URL="https://learn.netdata.cloud/docs/"
FORUM_URL="https://community.netdata.cloud/"
KICKSTART_OPTIONS="${*}"
+KICKSTART_SOURCE="$(realpath "$0")"
PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh"
PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
PUBLIC_CLOUD_URL="https://app.netdata.cloud"
REPOCONFIG_URL_PREFIX="https://packagecloud.io/netdata/netdata-repoconfig/packages"
REPOCONFIG_VERSION="1-1"
-TELEMETRY_URL="https://posthog.netdata.cloud/capture/"
START_TIME="$(date +%s)"
+STATIC_INSTALL_ARCHES="x86_64 armv7l aarch64 ppc64le"
+TELEMETRY_URL="https://posthog.netdata.cloud/capture/"
# ======================================================================
# Defaults for environment variables
@@ -27,16 +33,17 @@ DRY_RUN=0
SELECTED_INSTALL_METHOD="none"
INSTALL_TYPE="unknown"
INSTALL_PREFIX=""
-NETDATA_AUTO_UPDATES="1"
+NETDATA_AUTO_UPDATES="default"
NETDATA_CLAIM_ONLY=0
NETDATA_CLAIM_URL="${PUBLIC_CLOUD_URL}"
NETDATA_DISABLE_CLOUD=0
NETDATA_ONLY_BUILD=0
NETDATA_ONLY_NATIVE=0
NETDATA_ONLY_STATIC=0
+NETDATA_OFFLINE_INSTALL_SOURCE=""
NETDATA_REQUIRE_CLOUD=1
-RELEASE_CHANNEL="nightly"
-WARNINGS=""
+NETDATA_WARNINGS=""
+RELEASE_CHANNEL="default"
if [ -n "$DISABLE_TELEMETRY" ]; then
NETDATA_DISABLE_TELEMETRY="${DISABLE_TELEMETRY}"
@@ -60,33 +67,54 @@ else
INTERACTIVE=1
fi
+# ======================================================================
+# Core program logic
+
main() {
- if [ "${ACTION}" = "uninstall" ]; then
- uninstall
- printf >&2 "Finished uninstalling the Netdata Agent."
- deferred_warnings
- cleanup
- trap - EXIT
- exit 0
- fi
+ case "${ACTION}" in
+ uninstall)
+ uninstall
+ printf >&2 "Finished uninstalling the Netdata Agent."
+ deferred_warnings
+ cleanup
+ trap - EXIT
+ exit 0
+ ;;
+ reinstall-clean)
+ NEW_INSTALL_PREFIX="${INSTALL_PREFIX}"
+ uninstall
+ cleanup
- if [ "${ACTION}" = "reinstall-clean" ]; then
- NEW_INSTALL_PREFIX="${INSTALL_PREFIX}"
- uninstall
- cleanup
+ ACTION=
+ INSTALL_PREFIX="${NEW_INSTALL_PREFIX}"
+ # shellcheck disable=SC2086
+ main
- ACTION=
- INSTALL_PREFIX="${NEW_INSTALL_PREFIX}"
- # shellcheck disable=SC2086
- main
+ trap - EXIT
+ exit 0
+ ;;
+ prepare-offline)
+ prepare_offline_install_source "${OFFLINE_TARGET}"
+ deferred_warnings
+ trap - EXIT
+ exit 0
+ ;;
+ esac
- trap - EXIT
- exit 0
- fi
+ set_tmpdir
+
+ if [ -n "${INSTALL_VERSION}" ]; then
+ if echo "${INSTALL_VERSION}" | grep -E -o "^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$" > /dev/null 2>&1; then
+ NEW_SELECTED_RELEASE_CHANNEL="stable"
+ else
+ NEW_SELECTED_RELEASE_CHANNEL="nightly"
+ fi
- tmpdir="$(create_tmp_directory)"
- progress "Using ${tmpdir} as a temporary directory."
- cd "${tmpdir}" || fatal "Failed to change current working directory to ${tmpdir}." F000A
+ if ! [ "${NEW_SELECTED_RELEASE_CHANNEL}" = "${SELECTED_RELEASE_CHANNEL}" ]; then
+ warning "Selected release channel does not match this version and it will be changed automatically."
+ SELECTED_RELEASE_CHANNEL="${NEW_SELECTED_RELEASE_CHANNEL}"
+ fi
+ fi
case "${SYSTYPE}" in
Linux) install_on_linux ;;
@@ -118,32 +146,39 @@ usage() {
USAGE: kickstart.sh [options]
where options include:
- --non-interactive Do not prompt for user input. (default: prompt if there is a controlling terminal)
- --interactive Prompt for user input even if there is no controlling terminal.
- --dont-start-it Do not start the agent by default (only for static installs or local builds)
- --dry-run Report what we would do with the given options on this system, but don’t actually do anything.
- --stable-channel Install a stable version instead of a nightly build (default: install a nightly build)
- --nightly-channel Install a nightly build instead of a stable version
- --no-updates Do not enable automatic updates (default: enable automatic updates using the best supported scheduling method)
- --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.
- --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 <path> Specify an installation prefix for local builds (default: autodetect based on system type).
- --old-install-prefix <path> Specify an old local builds installation prefix for uninstall/reinstall (if it's not default).
- --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.
+ --non-interactive Do not prompt for user input. (default: prompt if there is a controlling terminal)
+ --interactive Prompt for user input even if there is no controlling terminal.
+ --dont-start-it Do not start the agent by default (only for static installs or local builds)
+ --dry-run Report what we would do with the given options on this system, but don’t actually do anything.
+ --release-channel Specify the release channel to use for the install (default: ${DEFAULT_RELEASE_CHANNEL})
+ --stable-channel Equivalent to "--release-channel stable"
+ --nightly-channel Equivalent to "--release-channel nightly"
+ --no-updates Do not enable automatic updates (default: enable automatic updates using the best supported scheduling method)
+ --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 <path> This option is deprecated and will be removed in a future version, use --install-prefix instead.
+ --install-prefix <path> Specify an installation prefix for local builds (default: autodetect based on system type).
+ --old-install-prefix <path> Specify an old local builds installation prefix for uninstall/reinstall (if it's not default).
+ --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.
+ --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:
@@ -155,7 +190,6 @@ Additionally, this script may use the following environment variables:
you need special options for one of those to work, or have a different tool to do
the same thing on your system, you can specify it here.
DISABLE_TELEMETRY If set to a value other than 0, behave as if \`--disable-telemetry\` was specified.
- NETDATA_INSTALLER_OPTIONS: Specifies extra options to pass to the static installer or local build script.
HEREDOC
}
@@ -222,6 +256,7 @@ telemetry_event() {
"error_message": "${2}",
"install_options": "${KICKSTART_OPTIONS}",
"install_interactivity": "${INTERACTIVE}",
+ "install_auto_updates": "${NETDATA_AUTO_UPDATES}",
"total_runtime": "${total_duration}",
"selected_install_method": "${SELECTED_INSTALL_METHOD}",
"netdata_release_channel": "${RELEASE_CHANNEL:-null}",
@@ -302,7 +337,7 @@ setup_terminal() {
test -t 2 || return 1
if command -v tput > /dev/null 2>&1; then
- if [ $(($(tput colors 2> /dev/null))) -ge 8 ]; then
+ if num_colors=$(tput colors 2> /dev/null) && [ "${num_colors:-0}" -ge 8 ]; then
# Enable colors
TPUT_RESET="$(tput sgr 0)"
TPUT_WHITE="$(tput setaf 7)"
@@ -336,16 +371,18 @@ success_banner() {
}
cleanup() {
- if [ -z "${NO_CLEANUP}" ]; then
+ if [ -z "${NO_CLEANUP}" ] && [ -n "${tmpdir}" ]; then
+ cd || true
${ROOTCMD} rm -rf "${tmpdir}"
fi
}
deferred_warnings() {
- if [ -n "${WARNINGS}" ]; then
+ if [ -n "${NETDATA_WARNINGS}" ]; then
printf >&2 "%s\n" "The following non-fatal warnings or errors were encountered:"
- echo >&2 "${WARNINGS}"
- printf >&2 "\n"
+ # shellcheck disable=SC2059
+ printf >&2 "${NETDATA_WARNINGS}"
+ printf >&2 "\n\n"
fi
}
@@ -417,7 +454,8 @@ run() {
if [ ${ret} -ne 0 ]; then
printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET}"
printf "%s\n" "FAILED with exit code ${ret}" >> "${run_logfile}"
- WARNINGS="${WARNINGS}\n - Command \"${*}\" failed with exit code ${ret}."
+ # shellcheck disable=SC2089
+ NETDATA_WARNINGS="${NETDATA_WARNINGS}\n - Command \"${*}\" failed with exit code ${ret}."
else
printf >&2 "%s\n\n" "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET}"
printf "OK\n" >> "${run_logfile}"
@@ -428,7 +466,7 @@ run() {
warning() {
printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} WARNING ${TPUT_RESET} ${*}"
- WARNINGS="${WARNINGS}\n - ${*}"
+ NETDATA_WARNINGS="${NETDATA_WARNINGS}\n - ${*}"
}
_cannot_use_tmpdir() {
@@ -467,9 +505,20 @@ create_tmp_directory() {
mktemp -d -t netdata-kickstart-XXXXXXXXXX
}
+set_tmpdir() {
+ if [ -z "${tmpdir}" ]; then
+ tmpdir="$(create_tmp_directory)"
+ progress "Using ${tmpdir} as a temporary directory."
+ cd "${tmpdir}" || fatal "Failed to change current working directory to ${tmpdir}." F000A
+ fi
+}
+
check_for_remote_file() {
url="${1}"
- if command -v curl > /dev/null 2>&1; then
+
+ 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 command -v wget > /dev/null 2>&1; then
wget -S --spider "${url}" 2>&1 | grep -q 'HTTP/1.1 200 OK' || return 1
@@ -481,7 +530,10 @@ check_for_remote_file() {
download() {
url="${1}"
dest="${2}"
- if command -v curl > /dev/null 2>&1; then
+
+ 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 command -v wget > /dev/null 2>&1; then
run wget -T 15 -O "${dest}" "${url}" || return 1
@@ -644,11 +696,19 @@ update() {
return 0
fi
+ export NETDATA_SAVE_WARNINGS=1
+ export NETDATA_PROPAGATE_WARNINGS=1
+ # shellcheck disable=SC2090
+ export NETDATA_WARNINGS="${NETDATA_WARNINGS}"
if run ${ROOTCMD} "${updater}" --not-running-from-cron; then
progress "Updated existing install at ${ndprefix}"
return 0
else
- fatal "Failed to update existing Netdata install at ${ndprefix}" F0100
+ if [ -n "${EXIT_REASON}" ]; then
+ fatal "Failed to update existing Netdata install at ${ndprefix}: ${EXIT_REASON}" "${EXIT_CODE}"
+ else
+ fatal "Failed to update existing Netdata install at ${ndprefix}." U0000
+ fi
fi
else
warning "Could not find a usable copy of the updater script."
@@ -657,6 +717,7 @@ update() {
}
uninstall() {
+ set_tmpdir
get_system_info
detect_existing_install
@@ -681,6 +742,10 @@ uninstall() {
return 0
else
progress "Found existing netdata-uninstaller. Running it.."
+ export NETDATA_SAVE_WARNINGS=1
+ export NETDATA_PROPAGATE_WARNINGS=1
+ # shellcheck disable=SC2090
+ export NETDATA_WARNINGS="${NETDATA_WARNINGS}"
if ! run ${ROOTCMD} "${uninstaller}" $FLAGS; then
warning "Uninstaller failed. Some parts of Netdata may still be present on the system."
fi
@@ -694,6 +759,10 @@ uninstall() {
progress "Downloading netdata-uninstaller ..."
download "${uninstaller_url}" "${tmpdir}/netdata-uninstaller.sh"
chmod +x "${tmpdir}/netdata-uninstaller.sh"
+ export NETDATA_SAVE_WARNINGS=1
+ export NETDATA_PROPAGATE_WARNINGS=1
+ # shellcheck disable=SC2090
+ export NETDATA_WARNINGS="${NETDATA_WARNINGS}"
if ! run ${ROOTCMD} "${tmpdir}/netdata-uninstaller.sh" $FLAGS; then
warning "Uninstaller failed. Some parts of Netdata may still be present on the system."
fi
@@ -901,11 +970,11 @@ EOF
confirm_install_prefix() {
if [ -n "${INSTALL_PREFIX}" ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
- fatal "The \`--install\` option is only supported together with the \`--build-only\` option." F0204
+ fatal "The \`--install-prefix\` and \`--install\` options are only supported together with the \`--build-only\` option." F0204
fi
if [ -n "${INSTALL_PREFIX}" ]; then
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install ${INSTALL_PREFIX}"
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install-prefix ${INSTALL_PREFIX}"
else
case "${SYSTYPE}" in
Darwin)
@@ -1067,7 +1136,7 @@ set_auto_updates() {
return 0
fi
- if [ "${NETDATA_AUTO_UPDATES}" = "1" ]; then
+ if [ "${AUTO_UPDATE}" -eq 1 ]; then
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.
@@ -1092,6 +1161,7 @@ set_auto_updates() {
pkg_installed() {
case "${DISTRO_COMPAT_NAME}" in
debian|ubuntu)
+ # shellcheck disable=SC2016
dpkg-query --show --showformat '${Status}' "${1}" 2>&1 | cut -f 1 -d ' ' | grep -q '^install$'
return $?
;;
@@ -1163,7 +1233,7 @@ try_package_install() {
progress "Attempting to install using native packages..."
fi
- if [ "${RELEASE_CHANNEL}" = "nightly" ]; then
+ if [ "${SELECTED_RELEASE_CHANNEL}" = "nightly" ]; then
release="-edge"
else
release=""
@@ -1190,6 +1260,7 @@ try_package_install() {
repo_update_opts="${interactive_opts}"
uninstall_subcmd="purge"
INSTALL_TYPE="binpkg-deb"
+ NATIVE_VERSION="${INSTALL_VERSION:+"=${INSTALL_VERSION}"}"
;;
ubuntu)
needs_early_refresh=1
@@ -1203,6 +1274,7 @@ try_package_install() {
repo_update_opts="${interactive_opts}"
uninstall_subcmd="purge"
INSTALL_TYPE="binpkg-deb"
+ NATIVE_VERSION="${INSTALL_VERSION:+"=${INSTALL_VERSION}"}"
;;
centos)
if command -v dnf > /dev/null; then
@@ -1219,6 +1291,7 @@ try_package_install() {
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
@@ -1235,6 +1308,7 @@ try_package_install() {
repo_update_opts="${interactive_opts}"
uninstall_subcmd="remove"
INSTALL_TYPE="binpkg-rpm"
+ NATIVE_VERSION="${INSTALL_VERSION:+"-${INSTALL_VERSION}.${SYSARCH}"}"
;;
opensuse)
pm_cmd="zypper"
@@ -1247,6 +1321,7 @@ try_package_install() {
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
@@ -1263,6 +1338,7 @@ try_package_install() {
repo_update_opts="${interactive_opts}"
uninstall_subcmd="remove"
INSTALL_TYPE="binpkg-rpm"
+ NATIVE_VERSION="${INSTALL_VERSION:+"-${INSTALL_VERSION}.${SYSARCH}"}"
;;
*)
warning "We do not provide native packages for ${DISTRO}."
@@ -1270,6 +1346,20 @@ try_package_install() {
;;
esac
+ if [ -n "${INSTALL_VERSION}" ]; then
+ if echo "${INSTALL_VERSION}" | grep -q "nightly"; then
+ new_release="-edge"
+ else
+ new_release=
+ fi
+
+ if { [ -n "${new_release}" ] && [ -z "${release}" ]; } || { [ -z "${new_release}" ] && [ -n "${release}" ]; }; then
+ warning "Selected release channel does not match this version and it will be changed automatically."
+ fi
+
+ release="${new_release}"
+ fi
+
repoconfig_name="netdata-repo${release}"
repoconfig_file="${repoconfig_name}${pkg_vsep}${REPOCONFIG_VERSION}${pkg_suffix}.${pkg_type}"
repoconfig_url="${REPOCONFIG_URL_PREFIX}/${repo_prefix}/${repoconfig_file}/download.${pkg_type}"
@@ -1309,6 +1399,14 @@ try_package_install() {
progress "Repository configuration is already present, attempting to install netdata."
fi
+ if [ "${REPO_ACTION}" = "repositories-only" ]; then
+ progress "Successfully installed repository configuraion package."
+ deferred_warnings
+ cleanup
+ trap - EXIT
+ exit 1
+ fi
+
if ! check_special_native_deps; then
warning "Could not find secondary dependencies for ${DISTRO} on ${SYSARCH}."
if [ -z "${NO_CLEANUP}" ]; then
@@ -1335,7 +1433,7 @@ try_package_install() {
fi
# shellcheck disable=SC2086
- if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} netdata; then
+ if ! run ${ROOTCMD} 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."
@@ -1348,20 +1446,42 @@ try_package_install() {
# ======================================================================
# Static build install code
-
+# shellcheck disable=SC2034,SC2086,SC2126
set_static_archive_urls() {
- if [ "${RELEASE_CHANNEL}" = "stable" ]; then
- latest="$(get_redirect "https://github.com/netdata/netdata/releases/latest")"
- export NETDATA_STATIC_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/${latest}/netdata-${SYSARCH}-latest.gz.run"
- export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/${latest}/sha256sums.txt"
+ if [ -z "${2}" ]; then
+ arch="${SYSARCH}"
+ else
+ arch="${2}"
+ fi
+
+ if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
+ path="$(cd "${NETDATA_OFFLINE_INSTALL_SOURCE}" || exit 1; pwd)"
+ export NETDATA_STATIC_ARCHIVE_URL="file://${path}/netdata-${arch}-latest.gz.run"
+ export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="file://${path}/sha256sums.txt"
+ elif [ "${1}" = "stable" ]; then
+ if [ -n "${INSTALL_VERSION}" ]; then
+ export NETDATA_STATIC_ARCHIVE_OLD_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/netdata-v${INSTALL_VERSION}.gz.run"
+ export NETDATA_STATIC_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/netdata-${arch}-v${INSTALL_VERSION}.gz.run"
+ export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/sha256sums.txt"
+ else
+ latest="$(get_redirect "https://github.com/netdata/netdata/releases/latest")"
+ export NETDATA_STATIC_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/${latest}/netdata-${arch}-latest.gz.run"
+ export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/${latest}/sha256sums.txt"
+ fi
else
- export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-${SYSARCH}-latest.gz.run"
- export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt"
+ if [ -n "${INSTALL_VERSION}" ]; then
+ export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-${arch}-v${INSTALL_VERSION}.gz.run"
+ export NETDATA_STATIC_ARCHIVE_OLD_URL="${NETDATA_TARBALL_BASEURL}/netdata-v${INSTALL_VERSION}.gz.run"
+ export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt"
+ else
+ export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-${arch}-latest.gz.run"
+ export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt"
+ fi
fi
}
try_static_install() {
- set_static_archive_urls "${RELEASE_CHANNEL}"
+ set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}"
if [ "${DRY_RUN}" -eq 1 ]; then
progress "Would attempt to install using static build..."
else
@@ -1369,12 +1489,31 @@ try_static_install() {
fi
# Check status code first, so that we can provide nicer fallback for dry runs.
- if ! check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
+ if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
+ if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
+ netdata_agent="$(basename "${NETDATA_STATIC_ARCHIVE_URL#"file://"}")"
+ elif [ -n "${INSTALL_VERSION}" ]; then
+ if [ "${SELECTED_RELEASE_CHANNEL}" = "stable" ]; then
+ netdata_agent="${NETDATA_STATIC_ARCHIVE_URL#"https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/"}"
+ else
+ netdata_agent="${NETDATA_STATIC_ARCHIVE_URL#"${NETDATA_TARBALL_BASEURL}/"}"
+ fi
+ else
+ if [ "${SELECTED_RELEASE_CHANNEL}" = "stable" ]; then
+ netdata_agent="${NETDATA_STATIC_ARCHIVE_URL#"https://github.com/netdata/netdata/releases/download/${latest}/"}"
+ else
+ netdata_agent="${NETDATA_STATIC_ARCHIVE_URL#"${NETDATA_TARBALL_BASEURL}/"}"
+ fi
+ fi
+ elif [ "${SYSARCH}" = "x86_64" ] && check_for_remote_file "${NETDATA_STATIC_ARCHIVE_OLD_URL}"; then
+ netdata_agent="${NETDATA_STATIC_ARCHIVE_OLD_URL#"https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/"}"
+ export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_STATIC_ARCHIVE_OLD_URL}"
+ else
warning "No static build available for ${SYSARCH} CPUs."
return 2
fi
- if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "${tmpdir}/netdata-${SYSARCH}-latest.gz.run"; then
+ if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "${tmpdir}/${netdata_agent}"; then
fatal "Unable to download static build archive for ${SYSARCH}." F0208
fi
@@ -1385,8 +1524,10 @@ try_static_install() {
if [ "${DRY_RUN}" -eq 1 ]; then
progress "Would validate SHA256 checksum of downloaded static build archive."
else
- if ! grep "netdata-${SYSARCH}-latest.gz.run" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
- fatal "Static binary checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0207
+ if [ -z "${INSTALL_VERSION}" ]; then
+ if ! grep "${netdata_agent}" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
+ fatal "Static binary checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0207
+ fi
fi
fi
@@ -1396,7 +1537,7 @@ try_static_install() {
progress "Installing netdata"
# shellcheck disable=SC2086
- if ! run ${ROOTCMD} sh "${tmpdir}/netdata-${SYSARCH}-latest.gz.run" ${opts} -- ${NETDATA_AUTO_UPDATES:+--auto-update} ${NETDATA_INSTALLER_OPTIONS}; then
+ if ! run ${ROOTCMD} 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
@@ -1424,12 +1565,22 @@ try_static_install() {
set_source_archive_urls() {
if [ "$1" = "stable" ]; then
- latest="$(get_redirect "https://github.com/netdata/netdata/releases/latest")"
- export NETDATA_SOURCE_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/${latest}/netdata-${latest}.tar.gz"
- export NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/${latest}/sha256sums.txt"
+ if [ -n "${INSTALL_VERSION}" ]; then
+ export NETDATA_SOURCE_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/netdata-v${INSTALL_VERSION}.tar.gz"
+ export NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/sha256sums.txt"
+ else
+ latest="$(get_redirect "https://github.com/netdata/netdata/releases/latest")"
+ export NETDATA_SOURCE_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/${latest}/netdata-${latest}.tar.gz"
+ export NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/${latest}/sha256sums.txt"
+ fi
else
- export NETDATA_SOURCE_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-latest.tar.gz"
- export NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt"
+ if [ -n "${INSTALL_VERSION}" ]; then
+ export NETDATA_SOURCE_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-v${INSTALL_VERSION}.tar.gz"
+ export NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt"
+ else
+ export NETDATA_SOURCE_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-latest.tar.gz"
+ export NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt"
+ fi
fi
}
@@ -1482,11 +1633,7 @@ build_and_install() {
opts="${opts} --dont-wait"
fi
- if [ "${NETDATA_AUTO_UPDATES}" -eq 1 ]; then
- opts="${opts} --auto-update"
- fi
-
- if [ "${RELEASE_CHANNEL}" = "stable" ]; then
+ if [ "${SELECTED_RELEASE_CHANNEL}" = "stable" ]; then
opts="${opts} --stable-channel"
fi
@@ -1496,12 +1643,20 @@ build_and_install() {
opts="${opts} --disable-cloud"
fi
+ export NETDATA_SAVE_WARNINGS=1
+ export NETDATA_PROPAGATE_WARNINGS=1
+ # shellcheck disable=SC2090
+ export NETDATA_WARNINGS="${NETDATA_WARNINGS}"
# shellcheck disable=SC2086
run ${ROOTCMD} ./netdata-installer.sh ${opts}
case $? in
1)
- fatal "netdata-installer.sh failed to run correctly." F0007
+ if [ -n "${EXIT_REASON}" ]; then
+ fatal "netdata-installer.sh failed to run: ${EXIT_REASON}" "${EXIT_CODE}"
+ else
+ fatal "netdata-installer.sh failed to run correctly." I0000
+ fi
;;
2)
fatal "Insufficient RAM to install netdata." F0008
@@ -1520,9 +1675,13 @@ try_build_install() {
return 1
fi
- set_source_archive_urls "${RELEASE_CHANNEL}"
+ set_source_archive_urls "${SELECTED_RELEASE_CHANNEL}"
- if ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-latest.tar.gz"; then
+ if [ -n "${INSTALL_VERSION}" ]; then
+ if ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz"; then
+ fatal "Failed to download source tarball for local build." F000B
+ fi
+ elif ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-latest.tar.gz"; then
fatal "Failed to download source tarball for local build." F000B
fi
@@ -1533,13 +1692,22 @@ try_build_install() {
if [ "${DRY_RUN}" -eq 1 ]; then
progress "Would validate SHA256 checksum of downloaded source archive."
else
- if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
- fatal "Tarball checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0005
+ if [ -z "${INSTALL_VERSION}" ]; then
+ # shellcheck disable=SC2086
+ if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
+ fatal "Tarball checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0005
+ fi
fi
fi
- run tar -xf "${tmpdir}/netdata-latest.tar.gz" -C "${tmpdir}"
- rm -rf "${tmpdir}/netdata-latest.tar.gz" > /dev/null 2>&1
+ if [ -n "${INSTALL_VERSION}" ]; then
+ run tar -xf "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz" -C "${tmpdir}"
+ rm -rf "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz" > /dev/null 2>&1
+ else
+ run tar -xf "${tmpdir}/netdata-latest.tar.gz" -C "${tmpdir}"
+ rm -rf "${tmpdir}/netdata-latest.tar.gz" > /dev/null 2>&1
+ fi
+
if [ "${DRY_RUN}" -ne 1 ]; then
cd "$(find "${tmpdir}" -mindepth 1 -maxdepth 1 -type d -name netdata-)" || fatal "Cannot change directory to netdata source tree" F0006
fi
@@ -1557,10 +1725,97 @@ try_build_install() {
}
# ======================================================================
+# Offline install support code
+
+prepare_offline_install_source() {
+ if [ -e "${1}" ]; then
+ if [ ! -d "${1}" ]; then
+ fatal "${1} is not a directory, unable to prepare offline install source." F0503
+ fi
+ else
+ run mkdir -p "${1}" || fatal "Unable to create target directory for offline install preparation." F0504
+ fi
+
+ run cd "${1}" || fatal "Failed to swtich 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"
+
+ 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}."
+ 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."
+ 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." F0506
+ fi
+ fi
+
+ if [ "${legacy:-0}" -eq 1 ]; then
+ sed -e 's/netdata-latest.gz.run/netdata-x86_64-latest.gz.run' sha256sums.txt > sha256sums.tmp
+ mv sha256sums.tmp sha256sums.txt
+ fi
+
+ if [ "${DRY_RUN}" -ne 1 ]; then
+ progress "Verifying checksums."
+ if ! grep -e "$(find . -name '*.gz.run')" sha256sums.txt | safe_sha256sum -c -; then
+ fatal "Checksums for offline install files are incorrect. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0507
+ fi
+ else
+ progress "Would verify SHA256 checksums of downloaded installation files."
+ fi
+
+ if [ "${DRY_RUN}" -ne 1 ]; then
+ progress "Preparing install script."
+ cat > "install.sh" <<-EOF
+ #!/bin/sh
+ dir=\$(CDPATH= cd -- "\$(dirname -- "\$0")" && pwd)
+ "\${dir}/kickstart.sh" --offline-install-source "\${dir}" \${@}
+ EOF
+ chmod +x "install.sh"
+ else
+ progress "Would create install script"
+ fi
+
+ if [ "${DRY_RUN}" -ne 1 ]; then
+ progress "Copying kickstart script."
+ cp "${KICKSTART_SOURCE}" "kickstart.sh"
+ chmod +x "kickstart.sh"
+ else
+ progress "Would copy kickstart.sh to offline install source directory"
+ fi
+
+ if [ "${DRY_RUN}" -ne 1 ]; then
+ progress "Saving release channel information."
+ echo "${SELECTED_RELEASE_CHANNEL}" > "channel"
+ else
+ progress "Would save release channel information to offline install source directory"
+ fi
+
+ progress "Finished preparing offline install source directory at ${1}. You can now copy this directory to a target system and then run the script ‘install.sh’ from it to install on that system."
+}
+
+# ======================================================================
# Per system-type install logic
install_on_linux() {
- if [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
+ if [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ] && [ -z "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
SELECTED_INSTALL_METHOD="native"
try_package_install
@@ -1664,124 +1919,235 @@ install_on_freebsd() {
}
# ======================================================================
-# Main program
+# Argument parsing code
-setup_terminal || echo > /dev/null
+validate_args() {
+ check_claim_opts
-while [ -n "${1}" ]; do
- case "${1}" in
- "--help")
- usage
- cleanup
- trap - EXIT
- exit 0
- ;;
- "--no-cleanup") NO_CLEANUP=1 ;;
- "--dont-wait"|"--non-interactive") INTERACTIVE=0 ;;
- "--interactive") INTERACTIVE=1 ;;
- "--dry-run") DRY_RUN=1 ;;
- "--stable-channel") RELEASE_CHANNEL="stable" ;;
- "--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)
+ 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
+ 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
+ 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
+ fi
+
+ if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ -n "${INSTALL_VERSION}" ]; then
+ fatal "Specifying an install version alongside an offline install source is not supported." F050A
+ fi
+
+ if [ "${NETDATA_AUTO_UPDATES}" = "default" ]; then
+ if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] || [ -n "${INSTALL_VERSION}" ]; then
+ AUTO_UPDATE=0
+ else
+ AUTO_UPDATE=1
+ fi
+ elif [ "${NETDATA_AUTO_UPDATES}" = 1 ]; then
+ AUTO_UPDATE=1
+ else
+ AUTO_UPDATE=0
+ fi
+
+ if [ "${RELEASE_CHANNEL}" = "default" ]; then
+ if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
+ SELECTED_RELEASE_CHANNEL="$(cat "${NETDATA_OFFLINE_INSTALL_SOURCE}/channel")"
+
+ if [ -z "${SELECTED_RELEASE_CHANNEL}" ]; then
+ fatal "Could not find a release channel indicator in ${NETDATA_OFFLINE_INSTALL_SOURCE}." F0508
+ fi
+ else
+ SELECTED_RELEASE_CHANNEL="${DEFAULT_RELEASE_CHANNEL}"
+ fi
+ else
+ if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ "${RELEASE_CHANNEL}" != "$(cat "${NETDATA_OFFLINE_INSTALL_SOURCE}/channel")" ]; then
+ fatal "Release channal '${RELEASE_CHANNEL}' requested, but indicated offline installation source release channel is '$(cat "${NETDATA_OFFLINE_INSTALL_SOURCE}/channel")'." F0509
+ fi
+
+ SELECTED_RELEASE_CHANNEL="${RELEASE_CHANNEL}"
+ fi
+}
+
+parse_args() {
+ if [ -n "${NETDATA_INSTALLER_OPTIONS}" ]; then
+ warning "Explicitly specifying additional installer options with NETDATA_INSTALLER_OPTIONS is deprecated. Please instead pass the options to the script using either --local-build-options or --static-install-options as appropriate."
+ fi
+
+ while [ -n "${1}" ]; do
+ case "${1}" in
+ "--help")
+ usage
+ cleanup
+ trap - EXIT
+ exit 0
+ ;;
+ "--no-cleanup") NO_CLEANUP=1 ;;
+ "--dont-wait"|"--non-interactive") INTERACTIVE=0 ;;
+ "--interactive") INTERACTIVE=1 ;;
+ "--dry-run") DRY_RUN=1 ;;
+ "--stable-channel") RELEASE_CHANNEL="stable" ;;
+ "--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
+ ;;
+ *)
+ echo "Unrecognized value for --auto-update-type. Valid values are: systemd, interval, crontab"
+ exit 1
+ ;;
+ esac
+ ;;
+ "--reinstall") NETDATA_REINSTALL=1 ;;
+ "--reinstall-even-if-unsafe") NETDATA_UNSAFE_REINSTALL=1 ;;
+ "--claim-only") NETDATA_CLAIM_ONLY=1 ;;
+ "--disable-cloud")
+ NETDATA_DISABLE_CLOUD=1
+ NETDATA_REQUIRE_CLOUD=0
+ ;;
+ "--require-cloud")
+ NETDATA_DISABLE_CLOUD=0
+ NETDATA_REQUIRE_CLOUD=1
+ ;;
+ "--dont-start-it")
+ NETDATA_NO_START=1
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --dont-start-it"
+ ;;
+ "--disable-telemetry")
+ NETDATA_DISABLE_TELEMETRY="1"
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --disable-telemetry"
+ ;;
+ "--install")
+ warning "--install flag is deprecated and will be removed in a future version. Please use --install-prefix instead."
+ INSTALL_PREFIX="${2}"
+ shift 1
+ ;;
+ "--install-prefix")
+ INSTALL_PREFIX="${2}"
+ shift 1
+ ;;
+ "--old-install-prefix")
+ OLD_INSTALL_PREFIX="${2}"
+ shift 1
+ ;;
+ "--install-version")
+ INSTALL_VERSION="${2}"
+ AUTO_UPDATE=0
+ shift 1
+ ;;
+ "--uninstall")
+ ACTION="uninstall"
+ ;;
+ "--reinstall-clean")
+ ACTION="reinstall-clean"
+ ;;
+ "--repositories-only")
+ REPO_ACTION="repositories-only"
+ ;;
+ "--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"
+ ;;
+ "--claim-token")
+ NETDATA_CLAIM_TOKEN="${2}"
+ shift 1
+ ;;
+ "--claim-rooms")
+ NETDATA_CLAIM_ROOMS="${2}"
+ shift 1
+ ;;
+ "--claim-url")
+ NETDATA_CLAIM_URL="${2}"
+ shift 1
+ ;;
+ "--claim-"*)
+ optname="$(echo "${1}" | cut -d '-' -f 4-)"
+ case "${optname}" in
+ id|proxy|user|hostname)
+ 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}"
+ ;;
+ esac
+ ;;
+ "--local-build-options")
+ LOCAL_BUILD_OPTIONS="${2}"
+ shift 1
+ ;;
+ "--static-install-options")
+ STATIC_INSTALL_OPTIONS="${2}"
+ shift 1
+ ;;
+ "--prepare-offline-install-source")
+ if [ -n "${2}" ]; then
+ ACTION="prepare-offline"
+ OFFLINE_TARGET="${2}"
shift 1
- ;;
- *)
- echo "Unrecognized value for --auto-update-type. Valid values are: systemd, interval, crontab"
- exit 1
- ;;
- esac
- ;;
- "--reinstall") NETDATA_REINSTALL=1 ;;
- "--reinstall-even-if-unsafe") NETDATA_UNSAFE_REINSTALL=1 ;;
- "--claim-only") NETDATA_CLAIM_ONLY=1 ;;
- "--disable-cloud")
- NETDATA_DISABLE_CLOUD=1
- NETDATA_REQUIRE_CLOUD=0
- ;;
- "--require-cloud")
- NETDATA_DISABLE_CLOUD=0
- NETDATA_REQUIRE_CLOUD=1
- ;;
- "--dont-start-it")
- NETDATA_NO_START=1
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --dont-start-it"
- ;;
- "--disable-telemetry")
- NETDATA_DISABLE_TELEMETRY="1"
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --disable-telemetry"
- ;;
- "--install")
- INSTALL_PREFIX="${2}"
- shift 1
- ;;
- "--old-install-prefix")
- OLD_INSTALL_PREFIX="${2}"
- shift 1
- ;;
- "--uninstall")
- ACTION="uninstall"
- ;;
- "--reinstall-clean")
- ACTION="reinstall-clean"
- ;;
- "--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"
- ;;
- "--claim-token")
- NETDATA_CLAIM_TOKEN="${2}"
- shift 1
- ;;
- "--claim-rooms")
- NETDATA_CLAIM_ROOMS="${2}"
- shift 1
- ;;
- "--claim-url")
- NETDATA_CLAIM_URL="${2}"
- shift 1
- ;;
- "--claim-"*)
- optname="$(echo "${1}" | cut -d '-' -f 4-)"
- case "${optname}" in
- id|proxy|user|hostname)
- NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}=${2}"
+ else
+ fatal "A target directory must be specified with the --prepare-offline-install-source option." F0500
+ fi
+ ;;
+ "--offline-install-source")
+ if [ -d "${2}" ]; then
+ NETDATA_OFFLINE_INSTALL_SOURCE="${2}"
shift 1
- ;;
- verbose|insecure|noproxy|noreload|daemon-not-running)
- NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}"
- ;;
- *)
- warning "Ignoring unrecognized claiming option ${optname}"
- ;;
- esac
- ;;
- *)
- warning "Passing unrecognized option '${1}' to installer script. If this is intended, please add it to \$NETDATA_INSTALLER_OPTIONS instead."
- NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${1}"
- ;;
- esac
- shift 1
-done
+ else
+ fatal "A source directory must be specified with the --offline-install-source option." F0501
+ fi
+ ;;
+ *)
+ warning "Passing unrecognized option '${1}' to installer script. This behavior is deprecated and will be removed in the near future. 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."
+ NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${1}"
+ ;;
+ esac
+ shift 1
+ done
+
+ validate_args
+}
+
+# ======================================================================
+# Main program
+
+setup_terminal || echo > /dev/null
+
+# shellcheck disable=SC2068
+parse_args $@
-check_claim_opts
confirm_root_support
get_system_info
confirm_install_prefix