@cryptotaxi247 / netdata-1 / commits / 4cf76cfb3

Add support for installing static builds on systems without usable internet connections. (#12809)

* Add code to prepare an offline installation source directory. * Add support to `download` function for `file://` URLs. This will be used to reference local files instead of having to set up a web server or complicate the code for fetching files. * Modify static archive URL handling to use offline install source if present. * Make check for offline install source support more robust. * Fix fetching of files for offline installs. * Fixed installer stub script. * Mark release channel in offline install source directory. To ensure that users are getting what they expect. * Fix handling of option ordering. * Assorted fixes. * Don’t enable auto-updates by defualt for offline installs. * Update documentation. * Add dry run mode support. * Fix checking of SHA256 checksums. * Fix handling of custom install version selection. * Fix CPU architecture selection. * Fix typo. * Fix typos in user-facing messages * Fix broken merge. * Fix incorrect variable name.

Austin S. Hemmelgarn committed May 17, 2022 at 11:55 UTC 4cf76cfb357bee19f1e9b760df6ce3eedf3dd9c2
3 files changed +261 -120
packaging/installer/kickstart.sh
+229 -67
@@ -1,6 +1,8 @@
1 #!/bin/sh
2 #
3 # SPDX-License-Identifier: GPL-3.0-or-later
4 +#
5 +# Next unused error code: F050A
6
7 # ======================================================================
8 # Constants
@@ -8,18 +10,21 @@
10 AGENT_BUG_REPORT_URL="https://github.com/netdata/netdata/issues/new/choose"
11 CLOUD_BUG_REPORT_URL="https://github.com/netdata/netdata-cloud/issues/new/choose"
12 DEFAULT_RELEASE_CHANNEL="nightly"
11 -DISCUSSIONS_URL="https://github.com/netdata/netdata/discussions"
13 DISCORD_INVITE="https://discord.gg/5ygS846fR6"
14 +DISCUSSIONS_URL="https://github.com/netdata/netdata/discussions"
15 +DISCUSSIONS_URL="https://github.com/netdata/netdata/discussions"
16 DOCS_URL="https://learn.netdata.cloud/docs/"
17 FORUM_URL="https://community.netdata.cloud/"
18 KICKSTART_OPTIONS="${*}"
19 +KICKSTART_SOURCE="$(realpath "$0")"
20 PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh"
21 PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
22 PUBLIC_CLOUD_URL="https://app.netdata.cloud"
23 REPOCONFIG_URL_PREFIX="https://packagecloud.io/netdata/netdata-repoconfig/packages"
24 REPOCONFIG_VERSION="1-1"
21 -TELEMETRY_URL="https://posthog.netdata.cloud/capture/"
25 START_TIME="$(date +%s)"
26 +STATIC_INSTALL_ARCHES="x86_64 armv7l aarch64 ppc64le"
27 +TELEMETRY_URL="https://posthog.netdata.cloud/capture/"
28
29 # ======================================================================
30 # Defaults for environment variables
@@ -35,6 +40,7 @@ NETDATA_DISABLE_CLOUD=0
40 NETDATA_ONLY_BUILD=0
41 NETDATA_ONLY_NATIVE=0
42 NETDATA_ONLY_STATIC=0
43 +NETDATA_OFFLINE_INSTALL_SOURCE=""
44 NETDATA_REQUIRE_CLOUD=1
45 NETDATA_WARNINGS=""
46 RELEASE_CHANNEL="default"
@@ -62,28 +68,35 @@ else
68 fi
69
70 main() {
65 - if [ "${ACTION}" = "uninstall" ]; then
66 - uninstall
67 - printf >&2 "Finished uninstalling the Netdata Agent."
68 - deferred_warnings
69 - cleanup
70 - trap - EXIT
71 - exit 0
72 - fi
73 -
74 - if [ "${ACTION}" = "reinstall-clean" ]; then
75 - NEW_INSTALL_PREFIX="${INSTALL_PREFIX}"
76 - uninstall
77 - cleanup
71 + case "${ACTION}" in
72 + uninstall)
73 + uninstall
74 + printf >&2 "Finished uninstalling the Netdata Agent."
75 + deferred_warnings
76 + cleanup
77 + trap - EXIT
78 + exit 0
79 + ;;
80 + reinstall-clean)
81 + NEW_INSTALL_PREFIX="${INSTALL_PREFIX}"
82 + uninstall
83 + cleanup
84
79 - ACTION=
80 - INSTALL_PREFIX="${NEW_INSTALL_PREFIX}"
81 - # shellcheck disable=SC2086
82 - main
85 + ACTION=
86 + INSTALL_PREFIX="${NEW_INSTALL_PREFIX}"
87 + # shellcheck disable=SC2086
88 + main
89
84 - trap - EXIT
85 - exit 0
86 - fi
90 + trap - EXIT
91 + exit 0
92 + ;;
93 + prepare-offline)
94 + prepare_offline_install_source "${OFFLINE_TARGET}"
95 + deferred_warnings
96 + trap - EXIT
97 + exit 0
98 + ;;
99 + esac
100
101 tmpdir="$(create_tmp_directory)"
102 progress "Using ${tmpdir} as a temporary directory."
@@ -119,38 +132,39 @@ usage() {
132 USAGE: kickstart.sh [options]
133 where options include:
134
122 - --non-interactive Do not prompt for user input. (default: prompt if there is a controlling terminal)
123 - --interactive Prompt for user input even if there is no controlling terminal.
124 - --dont-start-it Do not start the agent by default (only for static installs or local builds)
125 - --dry-run Report what we would do with the given options on this system, but don’t actually do anything.
126 - --release-channel Specify the release channel to use for the install (default: ${DEFAULT_RELEASE_CHANNEL})
127 - --stable-channel Equivalent to "--release-channel stable"
128 - --nightly-channel Equivalent to "--release-channel nightly"
129 - --no-updates Do not enable automatic updates (default: enable automatic updates using the best supported scheduling method)
130 - --auto-update Enable automatic updates.
131 - --auto-update-type Specify a particular scheduling type for auto-updates (valid types: systemd, interval, crontab)
132 - --disable-telemetry Opt-out of anonymous statistics.
133 - --repositories-only Only install appropriate repository configuration packages (only for native install).
134 - --native-only Only install if native binary packages are available.
135 - --static-only Only install if a static build is available.
136 - --build-only Only install using a local build.
137 - --reinstall Explicitly reinstall instead of updating any existing install.
138 - --reinstall-even-if-unsafe Even try to reinstall if we don't think we can do so safely (implies --reinstall).
139 - --disable-cloud Disable support for Netdata Cloud (default: detect)
140 - --require-cloud Only install if Netdata Cloud can be enabled. Overrides --disable-cloud.
141 - --install <path> This option is deprecated and will be removed in a future version, use --install-prefix instead.
142 - --install-prefix <path> Specify an installation prefix for local builds (default: autodetect based on system type).
143 - --old-install-prefix <path> Specify an old local builds installation prefix for uninstall/reinstall (if it's not default).
144 - --install-version <version> Specify the version of Netdata to install.
145 - --claim-token Use a specified token for claiming to Netdata Cloud.
146 - --claim-rooms When claiming, add the node to the specified rooms.
147 - --claim-only If there is an existing install, only try to claim it, not update it.
148 - --claim-* Specify other options for the claiming script.
149 - --no-cleanup Don't do any cleanup steps. This is intended to help with debugging the installer.
150 - --uninstall Uninstall an existing installation of Netdata.
151 - --reinstall-clean Clean reinstall Netdata.
152 - --local-build-options Specify additional options to pass to the installer code when building locally. Only valid if --build-only is also specified.
153 - --static-install-options Specify additional options to pass to the static installer code. Only valid if --static-only is also specified.
135 + --non-interactive Do not prompt for user input. (default: prompt if there is a controlling terminal)
136 + --interactive Prompt for user input even if there is no controlling terminal.
137 + --dont-start-it Do not start the agent by default (only for static installs or local builds)
138 + --dry-run Report what we would do with the given options on this system, but don’t actually do anything.
139 + --release-channel Specify the release channel to use for the install (default: ${DEFAULT_RELEASE_CHANNEL})
140 + --stable-channel Equivalent to "--release-channel stable"
141 + --nightly-channel Equivalent to "--release-channel nightly"
142 + --no-updates Do not enable automatic updates (default: enable automatic updates using the best supported scheduling method)
143 + --auto-update Enable automatic updates.
144 + --auto-update-type Specify a particular scheduling type for auto-updates (valid types: systemd, interval, crontab)
145 + --disable-telemetry Opt-out of anonymous statistics.
146 + --repositories-only Only install appropriate repository configuration packages (only for native install).
147 + --native-only Only install if native binary packages are available.
148 + --static-only Only install if a static build is available.
149 + --build-only Only install using a local build.
150 + --reinstall Explicitly reinstall instead of updating any existing install.
151 + --reinstall-even-if-unsafe Even try to reinstall if we don't think we can do so safely (implies --reinstall).
152 + --disable-cloud Disable support for Netdata Cloud (default: detect)
153 + --require-cloud Only install if Netdata Cloud can be enabled. Overrides --disable-cloud.
154 + --install <path> This option is deprecated and will be removed in a future version, use --install-prefix instead.
155 + --install-prefix <path> Specify an installation prefix for local builds (default: autodetect based on system type).
156 + --old-install-prefix <path> Specify an old local builds installation prefix for uninstall/reinstall (if it's not default).
157 + --install-version <version> Specify the version of Netdata to install.
158 + --claim-token Use a specified token for claiming to Netdata Cloud.
159 + --claim-rooms When claiming, add the node to the specified rooms.
160 + --claim-only If there is an existing install, only try to claim it, not update it.
161 + --claim-* Specify other options for the claiming script.
162 + --no-cleanup Don't do any cleanup steps. This is intended to help with debugging the installer.
163 + --uninstall Uninstall an existing installation of Netdata.
164 + --reinstall-clean Clean reinstall Netdata.
165 + --local-build-options Specify additional options to pass to the installer code when building locally. Only valid if --build-only is also specified.
166 + --static-install-options Specify additional options to pass to the static installer code. Only valid if --static-only is also specified.
167 + --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.
168
169 Additionally, this script may use the following environment variables:
170
@@ -477,7 +491,10 @@ create_tmp_directory() {
491
492 check_for_remote_file() {
493 url="${1}"
480 - if command -v curl > /dev/null 2>&1; then
494 +
495 + if echo "${url}" | grep -Eq "^file:///"; then
496 + [ -e "${url#file://}" ] || return 1
497 + elif command -v curl > /dev/null 2>&1; then
498 curl --output /dev/null --silent --head --fail "${url}" || return 1
499 elif command -v wget > /dev/null 2>&1; then
500 wget -S --spider "${url}" 2>&1 | grep -q 'HTTP/1.1 200 OK' || return 1
@@ -489,7 +506,10 @@ check_for_remote_file() {
506 download() {
507 url="${1}"
508 dest="${2}"
492 - if command -v curl > /dev/null 2>&1; then
509 +
510 + if echo "${url}" | grep -Eq "^file:///"; then
511 + run cp "${url#file://}" "${dest}" || return 1
512 + elif command -v curl > /dev/null 2>&1; then
513 run curl --fail -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}" || return 1
514 elif command -v wget > /dev/null 2>&1; then
515 run wget -T 15 -O "${dest}" "${url}" || return 1
@@ -1389,23 +1409,33 @@ try_package_install() {
1409 # Static build install code
1410 # shellcheck disable=SC2034,SC2086,SC2126
1411 set_static_archive_urls() {
1392 - if [ "$1" = "stable" ]; then
1412 + if [ -z "${2}" ]; then
1413 + arch="${SYSARCH}"
1414 + else
1415 + arch="${2}"
1416 + fi
1417 +
1418 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
1419 + path="$(cd "${NETDATA_OFFLINE_INSTALL_SOURCE}" || exit 1; pwd)"
1420 + export NETDATA_STATIC_ARCHIVE_URL="file://${path}/netdata-${arch}-latest.gz.run"
1421 + export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="file://${path}/sha256sums.txt"
1422 + elif [ "${1}" = "stable" ]; then
1423 if [ -n "${INSTALL_VERSION}" ]; then
1424 export NETDATA_STATIC_ARCHIVE_OLD_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/netdata-v${INSTALL_VERSION}.gz.run"
1395 - export NETDATA_STATIC_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/netdata-${SYSARCH}-v${INSTALL_VERSION}.gz.run"
1425 + export NETDATA_STATIC_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/netdata-${arch}-v${INSTALL_VERSION}.gz.run"
1426 export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/sha256sums.txt"
1427 else
1428 latest="$(get_redirect "https://github.com/netdata/netdata/releases/latest")"
1399 - export NETDATA_STATIC_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/${latest}/netdata-${SYSARCH}-latest.gz.run"
1429 + export NETDATA_STATIC_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/${latest}/netdata-${arch}-latest.gz.run"
1430 export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/${latest}/sha256sums.txt"
1431 fi
1432 else
1433 if [ -n "${INSTALL_VERSION}" ]; then
1404 - export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-${SYSARCH}-v${INSTALL_VERSION}.gz.run"
1434 + export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-${arch}-v${INSTALL_VERSION}.gz.run"
1435 export NETDATA_STATIC_ARCHIVE_OLD_URL="${NETDATA_TARBALL_BASEURL}/netdata-v${INSTALL_VERSION}.gz.run"
1436 export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt"
1437 else
1408 - export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-${SYSARCH}-latest.gz.run"
1438 + export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-${arch}-latest.gz.run"
1439 export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt"
1440 fi
1441 fi
@@ -1421,7 +1451,9 @@ try_static_install() {
1451
1452 # Check status code first, so that we can provide nicer fallback for dry runs.
1453 if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
1424 - if [ -n "${INSTALL_VERSION}" ]; then
1454 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
1455 + netdata_agent="$(basename "${NETDATA_STATIC_ARCHIVE_URL#"file://"}")"
1456 + elif [ -n "${INSTALL_VERSION}" ]; then
1457 if [ "${SELECTED_RELEASE_CHANNEL}" = "stable" ]; then
1458 netdata_agent="${NETDATA_STATIC_ARCHIVE_URL#"https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/"}"
1459 else
@@ -1653,11 +1685,98 @@ try_build_install() {
1685 fi
1686 }
1687
1688 +# ======================================================================
1689 +# Offline install support code
1690 +
1691 +prepare_offline_install_source() {
1692 + if [ -e "${1}" ]; then
1693 + if [ ! -d "${1}" ]; then
1694 + fatal "${1} is not a directory, unable to prepare offline install source." F0503
1695 + fi
1696 + else
1697 + run mkdir -p "${1}" || fatal "Unable to create target directory for offline install preparation." F0504
1698 + fi
1699 +
1700 + run cd "${1}" || fatal "Failed to swtich to target directory for offline install preparation." F0505
1701 +
1702 + if [ "${NETDATA_ONLY_NATIVE}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
1703 + set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "x86_64"
1704 +
1705 + if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
1706 + for arch in ${STATIC_INSTALL_ARCHES}; do
1707 + set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "${arch}"
1708 +
1709 + progress "Fetching ${NETDATA_STATIC_ARCHIVE_URL}"
1710 + if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "netdata-${arch}-latest.gz.run"; then
1711 + warning "Failed to download static installer archive for ${arch}."
1712 + fi
1713 + done
1714 + legacy=0
1715 + else
1716 + 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."
1717 + progress "Fetching ${NETDATA_STATIC_ARCHIVE_OLD_URL}"
1718 + legacy=1
1719 +
1720 + if ! download "${NETDATA_STATIC_ARCHIVE_OLD_URL}" "netdata-x86_64-latest.gz.run"; then
1721 + warning "Failed to download static installer archive for x86_64."
1722 + fi
1723 + fi
1724 +
1725 + progress "Fetching ${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}"
1726 + if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "sha256sums.txt"; then
1727 + fatal "Failed to download checksum file." F0506
1728 + fi
1729 + fi
1730 +
1731 + if [ "${legacy:-0}" -eq 1 ]; then
1732 + sed -e 's/netdata-latest.gz.run/netdata-x86_64-latest.gz.run' sha256sums.txt > sha256sums.tmp
1733 + mv sha256sums.tmp sha256sums.txt
1734 + fi
1735 +
1736 + if [ "${DRY_RUN}" -ne 1 ]; then
1737 + progress "Verifying checksums."
1738 + if ! grep -e "$(find . -name '*.gz.run')" sha256sums.txt | safe_sha256sum -c -; then
1739 + 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
1740 + fi
1741 + else
1742 + progress "Would verify SHA256 checksums of downloaded installation files."
1743 + fi
1744 +
1745 + if [ "${DRY_RUN}" -ne 1 ]; then
1746 + progress "Preparing install script."
1747 + cat > "install.sh" <<-EOF
1748 + #!/bin/sh
1749 + dir=\$(CDPATH= cd -- "\$(dirname -- "\$0")" && pwd)
1750 + "\${dir}/kickstart.sh" --offline-install-source "\${dir}" \${@}
1751 + EOF
1752 + chmod +x "install.sh"
1753 + else
1754 + progress "Would create install script"
1755 + fi
1756 +
1757 + if [ "${DRY_RUN}" -ne 1 ]; then
1758 + progress "Copying kickstart script."
1759 + cp "${KICKSTART_SOURCE}" "kickstart.sh"
1760 + chmod +x "kickstart.sh"
1761 + else
1762 + progress "Would copy kickstart.sh to offline install source directory"
1763 + fi
1764 +
1765 + if [ "${DRY_RUN}" -ne 1 ]; then
1766 + progress "Saving release channel information."
1767 + echo "${SELECTED_RELEASE_CHANNEL}" > "channel"
1768 + else
1769 + progress "Would save release channel information to offline install source directory"
1770 + fi
1771 +
1772 + 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."
1773 +}
1774 +
1775 # ======================================================================
1776 # Per system-type install logic
1777
1778 install_on_linux() {
1660 - if [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
1779 + if [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ] && [ -z "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
1780 SELECTED_INSTALL_METHOD="native"
1781 try_package_install
1782
@@ -1839,8 +1958,6 @@ while [ -n "${1}" ]; do
1958 ;;
1959 "--install-version")
1960 INSTALL_VERSION="${2}"
1842 - # shellcheck disable=SC2034
1843 - AUTO_UPDATES=0
1961 shift 1
1962 ;;
1963 "--old-install-prefix")
@@ -1909,6 +2026,23 @@ while [ -n "${1}" ]; do
2026 STATIC_INSTALL_OPTIONS="${2}"
2027 shift 1
2028 ;;
2029 + "--prepare-offline-install-source")
2030 + if [ -n "${2}" ]; then
2031 + ACTION="prepare-offline"
2032 + OFFLINE_TARGET="${2}"
2033 + shift 1
2034 + else
2035 + fatal "A target directory must be specified with the --prepare-offline-install-source option." F0500
2036 + fi
2037 + ;;
2038 + "--offline-install-source")
2039 + if [ -d "${2}" ]; then
2040 + NETDATA_OFFLINE_INSTALL_SOURCE="${2}"
2041 + shift 1
2042 + else
2043 + fatal "A source directory must be specified with the --offline-install-source option." F0501
2044 + fi
2045 + ;;
2046 *)
2047 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."
2048 NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${1}"
@@ -1917,6 +2051,12 @@ while [ -n "${1}" ]; do
2051 shift 1
2052 done
2053
2054 +if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
2055 + if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ] || [ "${NETDATA_ONLY_BUILD}" -eq 1 ]; then
2056 + fatal "Offline installs are only supported for static builds currently." F0502
2057 + fi
2058 +fi
2059 +
2060 if [ -n "${LOCAL_BUILD_OPTIONS}" ]; then
2061 if [ "${NETDATA_ONLY_BUILD}" -eq 1 ]; then
2062 NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${LOCAL_BUILD_OPTIONS}"
@@ -1933,15 +2073,37 @@ if [ -n "${STATIC_INSTALL_OPTIONS}" ]; then
2073 fi
2074 fi
2075
1936 -if [ "${NETDATA_AUTO_UPDATES}" = "default" ] || [ "${NETDATA_AUTO_UPDATES}" = "1" ]; then
2076 +if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ -n "${INSTALL_VERSION}" ]; then
2077 + fatal "Specifying an install version alongside an offline install source is not supported." F050A
2078 +fi
2079 +
2080 +if [ "${NETDATA_AUTO_UPDATES}" = "default" ]; then
2081 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] || [ -n "${INSTALL_VERSION}" ]; then
2082 + AUTO_UPDATE=0
2083 + else
2084 + AUTO_UPDATE=1
2085 + fi
2086 +elif [ "${NETDATA_AUTO_UPDATES}" = 1 ]; then
2087 AUTO_UPDATE=1
2088 else
2089 AUTO_UPDATE=0
2090 fi
2091
2092 if [ "${RELEASE_CHANNEL}" = "default" ]; then
1943 - SELECTED_RELEASE_CHANNEL="${DEFAULT_RELEASE_CHANNEL}"
2093 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
2094 + SELECTED_RELEASE_CHANNEL="$(cat "${NETDATA_OFFLINE_INSTALL_SOURCE}/channel")"
2095 +
2096 + if [ -z "${SELECTED_RELEASE_CHANNEL}" ]; then
2097 + fatal "Could not find a release channel indicator in ${NETDATA_OFFLINE_INSTALL_SOURCE}." F0508
2098 + fi
2099 + else
2100 + SELECTED_RELEASE_CHANNEL="${DEFAULT_RELEASE_CHANNEL}"
2101 + fi
2102 else
2103 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ "${RELEASE_CHANNEL}" != "$(cat "${NETDATA_OFFLINE_INSTALL_SOURCE}/channel")" ]; then
2104 + fatal "Release channal '${RELEASE_CHANNEL}' requested, but indicated offline installation source release channel is '$(cat "${NETDATA_OFFLINE_INSTALL_SOURCE}/channel")'." F0509
2105 + fi
2106 +
2107 SELECTED_RELEASE_CHANNEL="${RELEASE_CHANNEL}"
2108 fi
2109
packaging/installer/methods/kickstart.md
+1
@@ -76,6 +76,7 @@ The `kickstart.sh` script accepts a number of optional parameters to control how
76 - `--reinstall-clean`: Performs an uninstall of Netdata and clean installation.
77 - `--local-build-options`: Specify additional options to pass to the installer code when building locally. Only valid if `--build-only` is also specified.
78 - `--static-install-options`: Specify additional options to pass to the static installer code. Only valid if --static-only is also specified.
79 +- `--prepare-offline-install-source`: Instead of insallling the agent, prepare a directory that can be used to install on another system without needing to download anything. See our [offline installation documentation](/packaging/installer/methods/offline.md) for more info.
80
81 Additionally, the following environment variables may be used to further customize how the script runs (most users
82 should not need to use special values for any of these):
packaging/installer/methods/offline.md
+31 -53
@@ -6,75 +6,53 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/packaging/instal
6
7 # Install Netdata on offline systems
8
9 -The Netdata Agent installs on offline or air gapped systems with a few additional steps.
9 +Our kickstart install script provides support for installing the Netdata Agent on systems which do not have a
10 +usable internet connection by prefetching all of the required files so that they can be copied to the target system.
11 +Currently, we only support using static installs with this method. There are tentative plans to support building
12 +locally on offline systems as well, but there is currently no estimate of when this functionality may be implemented.
13
11 -By default, the `kickstart.sh` and `kickstart-static64.sh` download Netdata assets, like the precompiled binary and a
12 -few dependencies, using the system's internet connection, but the Agent installer can also use equivalent files already
13 -present on the local filesystem.
14 +Users who wish to use native packages on offline systems may be able to do so using whatever tooling their
15 +distribution already provides for offline package management (such as `apt-offline` on Debian or Ubuntu systems),
16 +but this is not officially supported.
17
15 -First, download the required files. If you're using `kickstart.sh`, you need the Netdata tarball, the checksums, the
16 -go.d plugin binary, and the go.d plugin configuration. If you're using `kickstart-static64.sh`, you need only the
17 -Netdata tarball and checksums.
18 +## Preparing the offline installation source
19
19 -Download the files you need to a system of yours that's connected to the internet. Use the commands below, or visit the
20 -[latest Netdata release page](https://github.com/netdata/netdata/releases/latest) and [latest go.d plugin release
21 -page](https://github.com/netdata/go.d.plugin/releases) to download the required files manually.
20 +The first step to installing Netdata on an offline system is to prepare the offline installation source. This can
21 +be as a regular user from any internet connected system that has the following tools available:
22
23 -**If you're using `kickstart.sh`**, use the following commands:
23 +- cURL or wget
24 +- sha256sum or shasum
25 +- A standard POSIX compliant shell
26
25 -```bash
26 -cd /tmp
27 -
28 -curl -s https://my-netdata.io/kickstart.sh > kickstart.sh
29 -
30 -# Netdata tarball
31 -curl -s https://api.github.com/repos/netdata/netdata/releases/latest | grep "browser_download_url.*tar.gz" | cut -d '"' -f 4 | wget -qi -
32 -
33 -# Netdata checksums
34 -curl -s https://api.github.com/repos/netdata/netdata/releases/latest | grep "browser_download_url.*txt" | cut -d '"' -f 4 | wget -qi -
27 +To prepare the offline installation source, simply run:
28
36 -# Netdata dependency handling script
37 -wget -q - https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh
38 -
39 -# go.d plugin
40 -# For binaries for OS types and architectures not listed on [go.d releases](https://github.com/netdata/go.d.plugin/releases/latest), kindly open a github issue and we will do our best to serve your request
41 -export OS=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m | sed -e 's/i386/386/g' -e 's/i686/386/g' -e 's/x86_64/amd64/g' -e 's/aarch64/arm64/g' -e 's/armv64/arm64/g' -e 's/armv6l/arm/g' -e 's/armv7l/arm/g' -e 's/armv5tel/arm/g') && curl -s https://api.github.com/repos/netdata/go.d.plugin/releases/latest | grep "browser_download_url.*${OS}-${ARCH}.tar.gz" | cut -d '"' -f 4 | wget -qi -
42 -
43 -# go.d configuration
44 -curl -s https://api.github.com/repos/netdata/go.d.plugin/releases/latest | grep "browser_download_url.*config.tar.gz" | cut -d '"' -f 4 | wget -qi -
29 +```bash
30 +wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --prepare-offline-install-source ./netdata-offline
31 ```
32
47 -**If you're using `kickstart-static64.sh`**, use the following commands:
33 +or
34
35 ```bash
50 -cd /tmp
51 -
52 -curl -s https://my-netdata.io/kickstart-static64.sh > kickstart-static64.sh
53 -
54 -# Netdata static64 tarball
55 -curl -s https://api.github.com/repos/netdata/netdata/releases/latest | grep "browser_download_url.*gz.run" | cut -d '"' -f 4 | wget -qi -
56 -
57 -# Netdata checksums
58 -curl -s https://api.github.com/repos/netdata/netdata/releases/latest | grep "browser_download_url.*txt" | cut -d '"' -f 4 | wget -qi -
36 +curl https://my-netdata.io/kickstart.sh > /tmp/netdata-kickstart.sh && sh /tmp/netdata-kickstart.sh --prepare-offline-install-source ./netdata-offline
37 ```
38
61 -Move downloaded files to the `/tmp` directory on the offline system in whichever way your defined policy allows (if
62 -any).
39 +> The exact name used for the directory does not matter, you can specify any other name you want in place of `./netdata-offline`.
40
64 -Now you can run either the `kickstart.sh` or `kickstart-static64.sh` scripts using the `--local-files` option. This
65 -option requires you to specify the location and names of the files you just downloaded.
41 +This will create a directory called `netdata-offline` in the current directory and place all the files required for an offline install in it.
42
67 -> When using `--local-files`, the `kickstart.sh` or `kickstart-static64.sh` scripts won't download any Netdata assets
68 -> from the internet. But, you may still need a connection to install dependencies using your system's package manager.
69 -> The scripts will warn you if your system doesn't have all the dependencies.
43 +If you want to use a specific release channel (nightly or stable), it _must_ be specified on this step using the
44 +apporpriate option for the kickstart script.
45
71 -```bash
72 -# kickstart.sh
73 -bash kickstart.sh --local-files /tmp/netdata-(version-number-here).tar.gz /tmp/sha256sums.txt /tmp/go.d.plugin-(version-number-here).(OS)-(architecture).tar.gz /tmp/config.tar.gz /tmp/install-required-packages.sh
46 +## Installing on the target system
47
75 -# kickstart-static64.sh
76 -bash kickstart-static64.sh --local-files /tmp/netdata-(version-number-here).gz.run /tmp/sha256sums.txt
77 -```
48 +Once you have prepared the offline install source, you need to copy the offline install source directory to the
49 +target system. This can be done in any manner you like, as long as filenames are not changed.
50 +
51 +After copying the files, simply run the `install.sh` script located in the
52 +offline install source directory. It accepts all the [same options as the kickstart
53 +script](/packaging/installer/methods/kickstart.md#optional-parameters-to-alter-your-installation) for further
54 +customization of the installation, though it will default to not enabling automatic updates (as they are not
55 +supported on offline installs).
56
57 ## What's next?
58