summaryrefslogtreecommitdiffstats
path: root/packaging/installer/kickstart.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/installer/kickstart.sh')
-rwxr-xr-xpackaging/installer/kickstart.sh300
1 files changed, 237 insertions, 63 deletions
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
index f7c078274..dde738c28 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: F0516
+# Next unused error code: F051A
# ======================================================================
# Constants
@@ -21,10 +21,10 @@ KICKSTART_SOURCE="$(
)"
DEFAULT_PLUGIN_PACKAGES=""
PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
-REPOCONFIG_DEB_VERSION="2-1"
-REPOCONFIG_RPM_VERSION="2-1"
+REPOCONFIG_DEB_VERSION="2-2"
+REPOCONFIG_RPM_VERSION="2-2"
START_TIME="$(date +%s)"
-STATIC_INSTALL_ARCHES="x86_64 armv7l aarch64 ppc64le"
+STATIC_INSTALL_ARCHES="x86_64 armv7l armv6l aarch64 ppc64le"
# ======================================================================
# URLs used throughout the script
@@ -125,6 +125,7 @@ main() {
;;
esac
+ handle_existing_install
set_tmpdir
if [ -n "${INSTALL_VERSION}" ]; then
@@ -195,6 +196,7 @@ USAGE: kickstart.sh [options]
--no-cleanup Don't do any cleanup steps. This is intended to help with debugging the installer.
--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.
+ --offline-architecture Limit an offline install source being prepared with --prepare-offline-install-source to only include the specified static build architecture.
The following options are mutually exclusive and specifiy special operations other than trying to install Netdata normally or update an existing install:
@@ -310,23 +312,31 @@ telemetry_event() {
EOF
)"
+ succeeded=0
+
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
- wget -q -O - \
- -T 1 \
- --header 'Content-Type: application/json' \
- --post-data "${REQ_BODY}" \
- "${TELEMETRY_URL}" > /dev/null
- else
- wget -q -O - --no-check-certificate \
- --method POST \
- --timeout=1 \
- --header 'Content-Type: application/json' \
- --body-data "${REQ_BODY}" \
- "${TELEMETRY_URL}" > /dev/null
+ if "${CURL}" --silent -o /dev/null -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" "${TELEMETRY_URL}" > /dev/null; then
+ succeeded=1
+ fi
+ fi
+
+ if [ "${succeeded}" -eq 0 ]; then
+ if 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
+ wget -q -O - \
+ -T 1 \
+ --header 'Content-Type: application/json' \
+ --post-data "${REQ_BODY}" \
+ "${TELEMETRY_URL}" > /dev/null
+ else
+ wget -q -O - --no-check-certificate \
+ --method POST \
+ --timeout=1 \
+ --header 'Content-Type: application/json' \
+ --body-data "${REQ_BODY}" \
+ "${TELEMETRY_URL}" > /dev/null
+ fi
fi
fi
}
@@ -367,6 +377,15 @@ trap 'trap_handler 15 0' TERM
# ======================================================================
# Utility functions
+canonical_path() {
+ cd "$(dirname "${1}")" || exit 1
+ case "$(basename "${1}")" in
+ ..) dirname "$(pwd -P)" ;;
+ .) pwd -P ;;
+ *) echo "$(pwd -P)/$(basename "${1}")" ;;
+ esac
+}
+
setup_terminal() {
TPUT_RESET=""
TPUT_WHITE=""
@@ -402,6 +421,9 @@ support_list() {
}
success_banner() {
+ printf >&2 "%s\n" "To view your system's real-time performance metrics, open your web browser and enter http://NODE:19999."
+ printf >&2 "%s\n\n" "Replace NODE with the IP address or hostname of your Netdata server to access the dashboard."
+
printf >&2 "%s\n\n" "Official documentation can be found online at ${DOCS_URL}."
if [ -z "${CLAIM_TOKEN}" ]; then
@@ -530,11 +552,15 @@ run_script() {
# shellcheck disable=SC2086
run ${ROOTCMD} "${@}"
+ ret="$?"
+
if [ -r "${NETDATA_SCRIPT_STATUS_PATH}" ]; then
# shellcheck disable=SC1090
. "${NETDATA_SCRIPT_STATUS_PATH}"
rm -f "${NETDATA_SCRIPT_STATUS_PATH}"
fi
+
+ return "${ret}"
}
warning() {
@@ -588,13 +614,38 @@ set_tmpdir() {
check_for_remote_file() {
url="${1}"
+ succeeded=0
+ checked=0
if echo "${url}" | grep -Eq "^file:///"; then
[ -e "${url#file://}" ] || 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
+ return 0
+ elif [ -n "${NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT}" ]; then
+ return 0
+ fi
+
+ if [ -n "${CURL}" ]; then
+ checked=1
+
+ if "${CURL}" --output /dev/null --silent --head --fail "${url}"; then
+ succeeded=1
+ fi
+ fi
+
+ if [ "${succeeded}" -eq 0 ]; then
+ if command -v wget > /dev/null 2>&1; then
+ checked=1
+
+ if wget -S --spider "${url}" 2>&1 | grep -q 'HTTP/1.1 200 OK'; then
+ succeeded=1
+ fi
+ fi
+ fi
+
+ if [ "${succeeded}" -eq 1 ]; then
+ return 0
+ elif [ "${checked}" -eq 1 ]; then
+ return 1
else
fatal "${ERROR_F0003}" F0003
fi
@@ -603,13 +654,39 @@ check_for_remote_file() {
download() {
url="${1}"
dest="${2}"
+ succeeded=0
+ checked=0
if echo "${url}" | grep -Eq "^file:///"; then
run cp "${url#file://}" "${dest}" || 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
+ return 0
+ fi
+
+
+ if [ -n "${CURL}" ]; then
+ checked=1
+
+ if run "${CURL}" --fail -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}"; then
+ succeeded=1
+ else
+ rm -f "${dest}"
+ fi
+ fi
+
+ if [ "${succeeded}" -eq 0 ]; then
+ if command -v wget > /dev/null 2>&1; then
+ checked=1
+
+ if run wget -T 15 -O "${dest}" "${url}"; then
+ succeeded=1
+ fi
+ fi
+ fi
+
+ if [ "${succeeded}" -eq 1 ]; then
+ return 0
+ elif [ "${checked}" -eq 1 ]; then
+ return 1
else
fatal "${ERROR_F0003}" F0003
fi
@@ -633,11 +710,31 @@ get_actual_version() {
get_redirect() {
url="${1}"
+ succeeded=0
+ checked=0
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
+ checked=1
+
+ if run sh -c "${CURL} ${url} -s -L -I -o /dev/null -w '%{url_effective}' | grep -Eo '[^/]+$'"; then
+ succeeded=1
+ fi
+ fi
+
+ if [ "${succeeded}" -eq 0 ]; then
+ if command -v wget > /dev/null 2>&1; then
+ checked=1
+
+ if run sh -c "wget -S -O /dev/null ${url} 2>&1 | grep -m 1 Location | grep -Eo '[^/]+$'"; then
+ succeeded=1
+ fi
+ fi
+ fi
+
+ if [ "${succeeded}" -eq 1 ]; then
+ return 0
+ elif [ "${checked}" -eq 1 ]; then
+ return 1
else
fatal "${ERROR_F0003}" F0003
fi
@@ -796,6 +893,10 @@ update() {
opts="--interactive"
fi
+ if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
+ export NETDATA_OFFLINE_INSTALL_SOURCE="${NETDATA_OFFLINE_INSTALL_SOURCE}"
+ fi
+
if run_script "${updater}" ${opts} --not-running-from-cron; then
progress "Updated existing install at ${ndprefix}"
return 0
@@ -864,32 +965,48 @@ detect_existing_install() {
set_tmpdir
progress "Checking for existing installations of Netdata..."
+ EXISTING_INSTALL_IS_NATIVE="0"
- if pkg_installed netdata; then
- ndprefix="/"
- EXISTING_INSTALL_IS_NATIVE="1"
+ if [ -n "${INSTALL_PREFIX}" ]; then
+ searchpath="/opt/netdata/bin:${INSTALL_PREFIX}/bin:${INSTALL_PREFIX}/sbin:${INSTALL_PREFIX}/usr/bin:${INSTALL_PREFIX}/usr/sbin:${PATH}"
+ searchpath="${INSTALL_PREFIX}/netdata/bin:${INSTALL_PREFIX}/netdata/sbin:${INSTALL_PREFIX}/netdata/usr/bin:${INSTALL_PREFIX}/netdata/usr/sbin:${searchpath}"
else
- EXISTING_INSTALL_IS_NATIVE="0"
- if [ -n "${INSTALL_PREFIX}" ]; then
- searchpath="${INSTALL_PREFIX}/bin:${INSTALL_PREFIX}/sbin:${INSTALL_PREFIX}/usr/bin:${INSTALL_PREFIX}/usr/sbin:${PATH}"
- searchpath="${INSTALL_PREFIX}/netdata/bin:${INSTALL_PREFIX}/netdata/sbin:${INSTALL_PREFIX}/netdata/usr/bin:${INSTALL_PREFIX}/netdata/usr/sbin:${searchpath}"
- else
- searchpath="${PATH}"
- fi
+ searchpath="/opt/netdata/bin:${PATH}"
+ fi
- ndpath="$(PATH="${searchpath}" command -v netdata 2>/dev/null)"
+ while [ -n "${searchpath}" ]; do
+ _ndpath="$(PATH="${searchpath}" command -v netdata 2>/dev/null)"
- if [ -z "$ndpath" ] && [ -x /opt/netdata/bin/netdata ]; then
- ndpath="/opt/netdata/bin/netdata"
+ if [ -n "${_ndpath}" ]; then
+ _ndpath="$(canonical_path "${_ndpath}")"
fi
- if [ -n "${ndpath}" ]; then
- case "${ndpath}" in
- */usr/bin/netdata|*/usr/sbin/netdata) ndprefix="$(dirname "$(dirname "$(dirname "${ndpath}")")")" ;;
- *) ndprefix="$(dirname "$(dirname "${ndpath}")")" ;;
- esac
+ if [ -z "${ndpath}" ] && [ -n "${_ndpath}" ]; then
+ ndpath="${_ndpath}"
+ elif [ -n "${_ndpath}" ] && [ "${ndpath}" != "${_ndpath}" ]; then
+ fatal "Multiple installs of Netdata agent detected (located at '${ndpath}' and '${_ndpath}'). Such a setup is not generally supported. If you are certain you want to operate on one of them despite this, use the '--install-prefix' option to specifiy the install you want to operate on." F0517
fi
+ if [ -n "${INSTALL_PREFIX}" ] && [ -n "${ndpath}" ]; then
+ break
+ elif [ -z "${_ndpath}" ]; then
+ break
+ elif echo "${searchpath}" | grep -v ':'; then
+ searchpath=""
+ else
+ searchpath="$(echo "${searchpath}" | cut -f 2- -d ':')"
+ fi
+ done
+
+ if pkg_installed netdata; then
+ ndprefix="/"
+ EXISTING_INSTALL_IS_NATIVE="1"
+ elif [ -n "${ndpath}" ]; then
+ case "${ndpath}" in
+ */usr/bin/netdata|*/usr/sbin/netdata) ndprefix="$(dirname "$(dirname "$(dirname "${ndpath}")")")" ;;
+ *) ndprefix="$(dirname "$(dirname "${ndpath}")")" ;;
+ esac
+
if echo "${ndprefix}" | grep -Eq '^/usr$'; then
ndprefix="$(dirname "${ndprefix}")"
fi
@@ -1325,7 +1442,7 @@ netdata_avail_check() {
;;
centos|fedora|ol|amzn)
# shellcheck disable=SC2086
- ${pm_cmd} search --nogpgcheck -v netdata | grep -qE 'Repo *: netdata(-edge)?$'
+ LC_ALL=C ${pm_cmd} search --nogpgcheck -v netdata | grep -qE 'Repo *: netdata(-edge)?$'
return $?
;;
opensuse)
@@ -1341,7 +1458,7 @@ check_special_native_deps() {
if [ "${DISTRO_COMPAT_NAME}" = "centos" ] && [ "${SYSVERSION}" -gt 6 ]; then
progress "EPEL is required on this system, checking if it’s available."
- if ${pm_cmd} search --nogpgcheck -v epel-release | grep -q "No matches found"; then
+ if LC_ALL=C ${pm_cmd} search --nogpgcheck -v epel-release | grep -q "No matches found"; then
warning "Unable to find a suitable source for libuv, cannot install using native packages on this system."
return 1
else
@@ -1356,6 +1473,14 @@ check_special_native_deps() {
fi
}
+cleanup_apt_cache() {
+ cache_dir="/var/cache/apt/archives"
+
+ if [ -d "${cache_dir}" ]; then
+ run_as_root find "${cache_dir}" -type f -name 'netdata*.deb' -delete
+ fi
+}
+
common_rpm_opts() {
pkg_type="rpm"
pkg_suffix=".noarch"
@@ -1422,6 +1547,7 @@ try_package_install() {
install_subcmd="install"
fi
needs_early_refresh=1
+ needs_apt_cache_cleanup=1
pm_cmd="apt-get"
repo_subcmd="update"
pkg_type="deb"
@@ -1496,15 +1622,21 @@ try_package_install() {
deb)
repoconfig_file="${repoconfig_name}${pkg_vsep}${REPOCONFIG_DEB_VERSION}${pkg_suffix}.${pkg_type}"
repoconfig_url="${REPOCONFIG_DEB_URL_PREFIX}/${repo_prefix}/${repoconfig_file}"
+ ref_check_url="${REPOCONFIG_DEB_URL_PREFIX}"
;;
rpm)
repoconfig_file="${repoconfig_name}${pkg_vsep}${REPOCONFIG_RPM_VERSION}${pkg_suffix}.${pkg_type}"
repoconfig_url="${REPOCONFIG_RPM_URL_PREFIX}/${repo_prefix}/${SYSARCH}/${repoconfig_file}"
+ ref_check_url="${REPOCONFIG_RPM_URL_PREFIX}"
;;
esac
if ! pkg_installed "${repoconfig_name}"; then
progress "Checking for availability of repository configuration package."
+ if ! check_for_remote_file "${ref_check_url}"; then
+ NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1
+ fi
+
if ! check_for_remote_file "${repoconfig_url}"; then
warning "No repository configuration package available for ${DISTRO} ${SYSVERSION}. Cannot install native packages on this system."
return 2
@@ -1520,6 +1652,10 @@ try_package_install() {
warning "${failed_refresh_msg}"
return 2
fi
+
+ if [ -n "${needs_apt_cache_cleanup}" ]; then
+ cleanup_apt_cache
+ fi
fi
# shellcheck disable=SC2086
@@ -1643,6 +1779,10 @@ try_static_install() {
progress "Attempting to install using static build..."
fi
+ if ! check_for_remote_file "${NETDATA_TARBALL_BASEURL}"; then
+ NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1
+ 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
netdata_agent="${NETDATA_STATIC_ARCHIVE_NAME}"
@@ -1650,7 +1790,7 @@ try_static_install() {
netdata_agent="${NETDATA_STATIC_ARCHIVE_OLD_NAME}"
export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_STATIC_ARCHIVE_OLD_URL}"
else
- warning "There is no static build available for ${SYSARCH} CPUs. This usually means we simply do not currently provide static builds for ${SYSARCH} CPUs."
+ warning "Could not find a ${SELECTED_RELEASE_CHANNEL} static build for ${SYSARCH} CPUs. This usually means there is some networking issue preventing access to https://github.com/ from this system."
return 2
fi
@@ -1676,9 +1816,15 @@ try_static_install() {
opts="${opts} --accept"
fi
+ env_cmd="env NETDATA_CERT_TEST_URL=${NETDATA_CLAIM_URL} NETDATA_CERT_MODE=check"
+
+ if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
+ env_cmd="env NETDATA_CERT_TEST_URL=${NETDATA_CLAIM_URL} NETDATA_CERT_MODE=auto"
+ fi
+
progress "Installing netdata"
# shellcheck disable=SC2086
- if ! run_as_root sh "${tmpdir}/${netdata_agent}" ${opts} -- ${NETDATA_INSTALLER_OPTIONS}; then
+ if ! run_as_root ${env_cmd} /bin/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
@@ -1750,8 +1896,14 @@ install_local_build_dependencies() {
fi
# shellcheck disable=SC2086
- 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."
+ if [ "$(uname -s)" = "Darwin" ]; then
+ if ! run "${bash}" "${tmpdir}/install-required-packages.sh" ${opts} netdata; then
+ warning "Failed to install all required packages, but installation might still be possible."
+ fi
+ else
+ 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
fi
}
@@ -1875,13 +2027,21 @@ prepare_offline_install_source() {
static|'')
set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "x86_64"
+ if ! check_for_remote_file "${NETDATA_TARBALL_BASEURL}"; then
+ NETDATA_ASSUME_REMOTE_FILES_ARE_PRESENT=1
+ fi
+
if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
- for arch in ${STATIC_INSTALL_ARCHES}; do
+ for arch in $(echo "${NETDATA_OFFLINE_ARCHES:-${STATIC_INSTALL_ARCHES}}" | awk '{for (i=1;i<=NF;i++) if (!a[$i]++) printf("%s%s",$i,FS)}{printf("\n")}'); 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}."
+ if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
+ 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
+ else
+ progress "Skipping ${NETDATA_STATIC_ARCHIVE_URL} as it does not exist on the server."
fi
done
legacy=0
@@ -1895,6 +2055,10 @@ prepare_offline_install_source() {
fi
fi
+ if ! find . -name '*.gz.run'; then
+ fatal "Did not actually download any static installer archives, cannot continue. ${BADNET_MSG}." F0516
+ 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
@@ -2087,6 +2251,10 @@ validate_args() {
case "${NETDATA_FORCE_METHOD}" in
native|build) fatal "Offline installs are only supported for static builds currently." F0502 ;;
esac
+
+ if [ ! -d "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
+ fatal "Offline install source must be a directory." F0519
+ fi
fi
if [ -n "${LOCAL_BUILD_OPTIONS}" ]; then
@@ -2296,9 +2464,19 @@ parse_args() {
fatal "A target directory must be specified with the --prepare-offline-install-source option." F0500
fi
;;
+ "--offline-architecture")
+ if echo "${STATIC_INSTALL_ARCHES}" | grep -qw "${2}"; then
+ NETDATA_OFFLINE_ARCHES="${NETDATA_OFFLINE_ARCHES} ${2}"
+ else
+ fatal "${2} is not a recognized static build architecture (supported architectures are ${STATIC_INSTALL_ARCHES})" F0518
+ fi
+ shift 1
+ ;;
"--offline-install-source")
if [ -d "${2}" ]; then
NETDATA_OFFLINE_INSTALL_SOURCE="${2}"
+ # shellcheck disable=SC2164
+ NETDATA_TARBALL_BASEURL="file://$(cd "${2}"; pwd)"
shift 1
else
fatal "A source directory must be specified with the --offline-install-source option." F0501
@@ -2325,8 +2503,4 @@ confirm_root_support
get_system_info
confirm_install_prefix
-if [ -z "${ACTION}" ]; then
- handle_existing_install
-fi
-
main