0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-05-02 08:20:10 +00:00

Assorted installer code cleanup. ()

* Consolidate shared options for native packages.

This makes the code significantly easier to read and greatly redueces
redundancy.

* Collapse cases with one-line bodies to single lines.

* Consolidate forced install type flags into a single variable.

* Clean up binpkg handling in updater.

* Assorted updater cleanup.

* Use bundled crontab for scheduling updates.

Instead of using one embedeed in the updater script.

* Fix botched merge.

* Fix another merge issue.

* Fix missing Amazon Linux support in updater code.
This commit is contained in:
Austin S. Hemmelgarn 2023-04-07 07:19:46 -04:00 committed by GitHub
parent a6edb782ca
commit 1c257e6969
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 168 additions and 342 deletions

View file

@ -48,9 +48,7 @@ NETDATA_CLAIM_URL="https://api.netdata.cloud"
NETDATA_COMMAND="default" NETDATA_COMMAND="default"
NETDATA_DISABLE_CLOUD=0 NETDATA_DISABLE_CLOUD=0
NETDATA_INSTALLER_OPTIONS="" NETDATA_INSTALLER_OPTIONS=""
NETDATA_ONLY_BUILD=0 NETDATA_FORCE_METHOD=""
NETDATA_ONLY_NATIVE=0
NETDATA_ONLY_STATIC=0
NETDATA_OFFLINE_INSTALL_SOURCE="" NETDATA_OFFLINE_INSTALL_SOURCE=""
NETDATA_REQUIRE_CLOUD=1 NETDATA_REQUIRE_CLOUD=1
NETDATA_WARNINGS="" NETDATA_WARNINGS=""
@ -68,7 +66,7 @@ NETDATA_TARBALL_BASEURL="${NETDATA_TARBALL_BASEURL:-https://github.com/netdata/n
TELEMETRY_API_KEY="${NETDATA_POSTHOG_API_KEY:-mqkwGT0JNFqO-zX2t0mW6Tec9yooaVu7xCBlXtHnt5Y}" TELEMETRY_API_KEY="${NETDATA_POSTHOG_API_KEY:-mqkwGT0JNFqO-zX2t0mW6Tec9yooaVu7xCBlXtHnt5Y}"
if echo "${0}" | grep -q 'kickstart-static64'; then if echo "${0}" | grep -q 'kickstart-static64'; then
NETDATA_ONLY_STATIC=1 NETDATA_FORCE_METHOD='static'
fi fi
if [ ! -t 1 ]; then if [ ! -t 1 ]; then
@ -333,9 +331,7 @@ trap_handler() {
printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ERROR ${TPUT_RESET} Installer exited unexpectedly (${code}-${lineno})" printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ERROR ${TPUT_RESET} Installer exited unexpectedly (${code}-${lineno})"
case "${code}" in case "${code}" in
0) 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 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" "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:" printf >&2 "%s\n" "If you continue to experience this issue, you can reacn out to us for support on:"
@ -673,25 +669,15 @@ get_system_info() {
DISTRO_COMPAT_NAME="${DISTRO}" DISTRO_COMPAT_NAME="${DISTRO}"
else else
case "${DISTRO}" in case "${DISTRO}" in
opensuse-leap) opensuse-leap) DISTRO_COMPAT_NAME="opensuse" ;;
DISTRO_COMPAT_NAME="opensuse" cloudlinux|almalinux|rocky|rhel) DISTRO_COMPAT_NAME="centos" ;;
;; artix|manjaro|obarun) DISTRO_COMPAT_NAME="arch" ;;
cloudlinux|almalinux|rocky|rhel) *) DISTRO_COMPAT_NAME="unknown" ;;
DISTRO_COMPAT_NAME="centos"
;;
artix|manjaro|obarun)
DISTRO_COMPAT_NAME="arch"
;;
*)
DISTRO_COMPAT_NAME="unknown"
;;
esac esac
fi fi
case "${DISTRO_COMPAT_NAME}" in case "${DISTRO_COMPAT_NAME}" in
centos|ol) centos|ol) SYSVERSION=$(echo "$SYSVERSION" | cut -d'.' -f1) ;;
SYSVERSION=$(echo "$SYSVERSION" | cut -d'.' -f1)
;;
esac esac
;; ;;
Darwin) Darwin)
@ -702,9 +688,7 @@ get_system_info() {
SYSTYPE="FreeBSD" SYSTYPE="FreeBSD"
SYSVERSION="$(uname -K)" SYSVERSION="$(uname -K)"
;; ;;
*) *) 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 esac
} }
@ -925,9 +909,9 @@ handle_existing_install() {
progress "Found an existing netdata install at ${ndprefix}, but user requested reinstall, continuing." progress "Found an existing netdata install at ${ndprefix}, but user requested reinstall, continuing."
case "${INSTALL_TYPE}" in case "${INSTALL_TYPE}" in
binpkg-*) NETDATA_ONLY_NATIVE=1 ;; binpkg-*) NETDATA_FORCE_METHOD='native' ;;
*-build) NETDATA_ONLY_BUILD=1 ;; *-build) NETDATA_FORCE_METHOD='build' ;;
*-static) NETDATA_ONLY_STATIC=1 ;; *-static) NETDATA_FORCE_METHOD='static' ;;
*) *)
if [ "${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." warning "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, but the user has requested we proceed."
@ -1071,7 +1055,7 @@ EOF
} }
confirm_install_prefix() { 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 fatal "The --install-prefix option is only supported together with the --build-only option." F0204
fi fi
@ -1168,52 +1152,24 @@ claim() {
progress "Successfully claimed node" progress "Successfully claimed node"
return 0 return 0
;; ;;
1) 1) warning "Unable to claim node due to invalid claiming options. If you are seeing this message, youve probably found a bug and should open a bug report at ${AGENT_BUG_REPORT_URL}" ;;
warning "Unable to claim node due to invalid claiming options. If you are seeing this message, youve 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}." ;;
2) 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." ;;
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) 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." 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 return 0
;; ;;
8) 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." ;;
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." ;;
9) 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." ;;
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." 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)\"" ;;
10) 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}." ;;
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." 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." ;;
11) *) 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}" ;;
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 esac
if [ -z "${NETDATA_NEW_INSTALL}" ]; then if [ -z "${NETDATA_NEW_INSTALL}" ]; then
@ -1281,9 +1237,7 @@ pkg_installed() {
pacman -Qi "${1}" > /dev/null 2>&1 pacman -Qi "${1}" > /dev/null 2>&1
return $? return $?
;; ;;
*) *) return 1 ;;
return 1
;;
esac esac
;; ;;
Darwin) Darwin)
@ -1322,9 +1276,7 @@ netdata_avail_check() {
zypper packages -r "$(zypper repos | grep -E 'netdata |netdata-edge ' | cut -f 1 -d '|' | tr -d ' ')" | grep -E 'netdata ' zypper packages -r "$(zypper repos | grep -E 'netdata |netdata-edge ' | cut -f 1 -d '|' | tr -d ' ')" | grep -E 'netdata '
return $? return $?
;; ;;
*) *) return 1 ;;
return 1
;;
esac esac
} }
@ -1352,6 +1304,26 @@ check_special_native_deps() {
fi 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() { 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." 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."
@ -1390,114 +1362,43 @@ try_package_install() {
fi fi
case "${DISTRO_COMPAT_NAME}" in case "${DISTRO_COMPAT_NAME}" in
debian) debian|ubuntu)
needs_early_refresh=1 needs_early_refresh=1
pm_cmd="apt-get" pm_cmd="apt-get"
repo_subcmd="update" repo_subcmd="update"
repo_prefix="debian/${SYSCODENAME}"
pkg_type="deb" 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)
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_vsep="_"
pkg_install_opts="${interactive_opts}" pkg_install_opts="${interactive_opts}"
repo_update_opts="${interactive_opts}" repo_update_opts="${interactive_opts}"
uninstall_subcmd="purge" uninstall_subcmd="purge"
repo_prefix="${DISTRO_COMPAT_NAME}/${SYSCODENAME}"
pkg_suffix="+${DISTRO_COMPAT_NAME}${SYSVERSION}_all"
INSTALL_TYPE="binpkg-deb" INSTALL_TYPE="binpkg-deb"
NATIVE_VERSION="${INSTALL_VERSION:+"=${INSTALL_VERSION}"}" NATIVE_VERSION="${INSTALL_VERSION:+"=${INSTALL_VERSION}"}"
;; ;;
centos) centos)
if command -v dnf > /dev/null; then common_rpm_opts
pm_cmd="dnf" common_dnf_opts
repo_subcmd="makecache"
else
pm_cmd="yum"
fi
repo_prefix="el/${SYSVERSION}" 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) fedora|ol)
if command -v dnf > /dev/null; then common_rpm_opts
pm_cmd="dnf" common_dnf_opts
repo_subcmd="makecache" repo_prefix="${DISTRO_COMPAT_NAME}/${SYSVERSION}"
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}"}"
;; ;;
opensuse) opensuse)
common_rpm_opts
pm_cmd="zypper" pm_cmd="zypper"
repo_subcmd="--gpg-auto-import-keys refresh" repo_subcmd="--gpg-auto-import-keys refresh"
repo_prefix="opensuse/${SYSVERSION}" repo_prefix="opensuse/${SYSVERSION}"
pkg_type="rpm"
pkg_suffix=".noarch"
pkg_vsep="-"
pkg_install_opts="${interactive_opts} --allow-unsigned-rpm" pkg_install_opts="${interactive_opts} --allow-unsigned-rpm"
repo_update_opts="" repo_update_opts=""
uninstall_subcmd="remove" 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) amzn)
if command -v dnf > /dev/null; then common_rpm_opts
pm_cmd="dnf" common_dnf_opts
repo_subcmd="makecache"
else
pm_cmd="yum"
fi
repo_prefix="amazonlinux/${SYSVERSION}" repo_prefix="amazonlinux/${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}"}"
;; ;;
*) *)
warning "We do not provide native packages for ${DISTRO}." warning "We do not provide native packages for ${DISTRO}."
@ -1816,9 +1717,7 @@ build_and_install() {
fatal "netdata-installer.sh failed to run: Encountered an unhandled error in the installer code." I0000 fatal "netdata-installer.sh failed to run: Encountered an unhandled error in the installer code." I0000
fi fi
;; ;;
2) 2) fatal "Insufficient RAM to install netdata." F0008 ;;
fatal "Insufficient RAM to install netdata." F0008
;;
esac esac
} }
@ -1898,34 +1797,36 @@ prepare_offline_install_source() {
run cd "${1}" || fatal "Failed to switch to target directory for offline install preparation." F0505 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 case "${NETDATA_FORCE_METHOD}" in
set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "x86_64" static|'')
set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "x86_64"
if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then if check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
for arch in ${STATIC_INSTALL_ARCHES}; do for arch in ${STATIC_INSTALL_ARCHES}; do
set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "${arch}" set_static_archive_urls "${SELECTED_RELEASE_CHANNEL}" "${arch}"
progress "Fetching ${NETDATA_STATIC_ARCHIVE_URL}" progress "Fetching ${NETDATA_STATIC_ARCHIVE_URL}"
if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "netdata-${arch}-latest.gz.run"; then if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "netdata-${arch}-latest.gz.run"; then
warning "Failed to download static installer archive for ${arch}. ${BADNET_MSG}." 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}."
fi 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}."
fi fi
fi
progress "Fetching ${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" progress "Fetching ${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}"
if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "sha256sums.txt"; then if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "sha256sums.txt"; then
fatal "Failed to download checksum file. ${BADNET_MSG}." F0506 fatal "Failed to download checksum file. ${BADNET_MSG}." F0506
fi fi
fi ;;
esac
if [ "${legacy:-0}" -eq 1 ]; then if [ "${legacy:-0}" -eq 1 ]; then
sed -e 's/netdata-latest.gz.run/netdata-x86_64-latest.gz.run' sha256sums.txt > sha256sums.tmp sed -e 's/netdata-latest.gz.run/netdata-x86_64-latest.gz.run' sha256sums.txt > sha256sums.tmp
@ -1975,7 +1876,7 @@ prepare_offline_install_source() {
# Per system-type install logic # Per system-type install logic
install_on_linux() { 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" SELECTED_INSTALL_METHOD="native"
try_package_install try_package_install
@ -1984,20 +1885,17 @@ install_on_linux() {
NETDATA_INSTALL_SUCCESSFUL=1 NETDATA_INSTALL_SUCCESSFUL=1
INSTALL_PREFIX="/" INSTALL_PREFIX="/"
;; ;;
1) 1) fatal "Unable to install on this system." F0300 ;;
fatal "Unable to install on this system." F0300
;;
2) 2)
if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then case "${NETDATA_FORCE_METHOD}" in
fatal "Could not install native binary packages." F0301 native) fatal "Could not install native binary packages." F0301 ;;
else *) warning "Could not install native binary packages, falling back to alternative installation method." ;;
warning "Could not install native binary packages, falling back to alternative installation method." esac
fi
;; ;;
esac esac
fi 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" SELECTED_INSTALL_METHOD="static"
INSTALL_TYPE="kickstart-static" INSTALL_TYPE="kickstart-static"
try_static_install try_static_install
@ -2007,75 +1905,60 @@ install_on_linux() {
NETDATA_INSTALL_SUCCESSFUL=1 NETDATA_INSTALL_SUCCESSFUL=1
INSTALL_PREFIX="/opt/netdata" INSTALL_PREFIX="/opt/netdata"
;; ;;
1) 1) fatal "Unable to install on this system." F0302 ;;
fatal "Unable to install on this system." F0302
;;
2) 2)
if [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then case "${NETDATA_FORCE_METHOD}" in
fatal "Could not install static build." F0303 static) fatal "Could not install static build." F0303 ;;
else *) warning "Could not install static build, falling back to alternative installation method." ;;
warning "Could not install static build, falling back to alternative installation method." esac
fi
;; ;;
esac esac
fi 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" SELECTED_INSTALL_METHOD="build"
INSTALL_TYPE="kickstart-build" INSTALL_TYPE="kickstart-build"
try_build_install try_build_install
case "$?" in case "$?" in
0) 0) NETDATA_INSTALL_SUCCESSFUL=1 ;;
NETDATA_INSTALL_SUCCESSFUL=1 *) fatal "Unable to install on this system." F0304 ;;
;;
*)
fatal "Unable to install on this system." F0304
;;
esac esac
fi fi
} }
install_on_macos() { install_on_macos() {
if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then case "${NETDATA_FORCE_METHOD}" in
fatal "User requested native package, but native packages are not available for macOS. Try installing without \`--only-native\` option." F0305 native) 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 static) fatal "User requested static build, but static builds are not available for macOS. Try installing without \`--only-static\` option." F0306 ;;
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"
SELECTED_INSTALL_METHOD="build" INSTALL_TYPE="kickstart-build"
INSTALL_TYPE="kickstart-build" try_build_install
try_build_install
case "$?" in case "$?" in
0) 0) NETDATA_INSTALL_SUCCESSFUL=1 ;;
NETDATA_INSTALL_SUCCESSFUL=1 *) fatal "Unable to install on this system." F0307 ;;
;; esac
*) ;;
fatal "Unable to install on this system." F0307 esac
;;
esac
fi
} }
install_on_freebsd() { install_on_freebsd() {
if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then case "${NETDATA_FORCE_METHOD}" in
fatal "User requested native package, but native packages are not available for FreeBSD. Try installing without \`--only-native\` option." F0308 native) 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 static) fatal "User requested static build, but static builds are not available for FreeBSD. Try installing without \`--only-static\` option." F0309 ;;
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"
SELECTED_INSTALL_METHOD="build" INSTALL_TYPE="kickstart-build"
INSTALL_TYPE="kickstart-build" try_build_install
try_build_install
case "$?" in case "$?" in
0) 0) NETDATA_INSTALL_SUCCESSFUL=1 ;;
NETDATA_INSTALL_SUCCESSFUL=1 *) fatal "Unable to install on this system." F030A ;;
;; esac
*) ;;
fatal "Unable to install on this system." F030A esac
;;
esac
fi
} }
# ====================================================================== # ======================================================================
@ -2084,30 +1967,32 @@ install_on_freebsd() {
validate_args() { validate_args() {
check_claim_opts check_claim_opts
if [ "${ACTION}" = "repositories-only" ] && [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then 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 fatal "Repositories can only be installed for native installs." F050D
fi fi
if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ] || [ "${NETDATA_ONLY_BUILD}" -eq 1 ]; then case "${NETDATA_FORCE_METHOD}" in
fatal "Offline installs are only supported for static builds currently." F0502 native|build) fatal "Offline installs are only supported for static builds currently." F0502 ;;
fi esac
fi fi
if [ -n "${LOCAL_BUILD_OPTIONS}" ]; then if [ -n "${LOCAL_BUILD_OPTIONS}" ]; then
if [ "${NETDATA_ONLY_BUILD}" -eq 1 ]; then case "${NETDATA_FORCE_METHOD}" in
NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${LOCAL_BUILD_OPTIONS}" build) 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 ;;
fatal "Specifying local build options is only supported when the --build-only option is also specified." F0401 esac
fi
fi fi
if [ -n "${STATIC_INSTALL_OPTIONS}" ]; then if [ -n "${STATIC_INSTALL_OPTIONS}" ]; then
if [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then case "${NETDATA_FORCE_METHOD}" in
NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${STATIC_INSTALL_OPTIONS}" static) 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 ;;
fatal "Specifying installer options options is only supported when the --static-only option is also specified." F0402 esac
fi
fi fi
if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ -n "${INSTALL_VERSION}" ]; then if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ -n "${INSTALL_VERSION}" ]; then
@ -2172,9 +2057,7 @@ parse_args() {
"--release-channel") "--release-channel")
RELEASE_CHANNEL="$(echo "${2}" | tr '[:upper:]' '[:lower:]')" RELEASE_CHANNEL="$(echo "${2}" | tr '[:upper:]' '[:lower:]')"
case "${RELEASE_CHANNEL}" in case "${RELEASE_CHANNEL}" in
nightly|stable|default) nightly|stable|default) shift 1 ;;
shift 1
;;
*) *)
echo "Unrecognized value for --release-channel. Valid release channels are: stable, nightly, default" echo "Unrecognized value for --release-channel. Valid release channels are: stable, nightly, default"
exit 1 exit 1
@ -2193,9 +2076,7 @@ parse_args() {
"--auto-update-method") "--auto-update-method")
NETDATA_AUTO_UPDATE_TYPE="$(echo "${2}" | tr '[:upper:]' '[:lower:]')" NETDATA_AUTO_UPDATE_TYPE="$(echo "${2}" | tr '[:upper:]' '[:lower:]')"
case "${NETDATA_AUTO_UPDATE_TYPE}" in case "${NETDATA_AUTO_UPDATE_TYPE}" in
systemd|interval|crontab) systemd|interval|crontab) shift 1 ;;
shift 1
;;
*) *)
echo "Unrecognized value for --auto-update-type. Valid values are: systemd, interval, crontab" echo "Unrecognized value for --auto-update-type. Valid values are: systemd, interval, crontab"
exit 1 exit 1
@ -2247,31 +2128,13 @@ parse_args() {
fatal "A distribution name and release must be specified for the --distro-override option." F050F fatal "A distribution name and release must be specified for the --distro-override option." F050F
fi fi
;; ;;
"--native-only")
NETDATA_ONLY_NATIVE=1
NETDATA_ONLY_STATIC=0
NETDATA_ONLY_BUILD=0
SELECTED_INSTALL_METHOD="native"
;;
"--repositories-only") "--repositories-only")
set_action 'repositories-only' set_action 'repositories-only'
NETDATA_ONLY_NATIVE=1 NETDATA_FORCE_METHOD="native"
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"
;; ;;
"--native-only") NETDATA_FORCE_METHOD="native" ;;
"--static-only") NETDATA_FORCE_METHOD="static" ;;
"--build-only") NETDATA_FORCE_METHOD="build" ;;
"--claim-token") "--claim-token")
NETDATA_CLAIM_TOKEN="${2}" NETDATA_CLAIM_TOKEN="${2}"
shift 1 shift 1
@ -2291,12 +2154,8 @@ parse_args() {
NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}=${2}" NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}=${2}"
shift 1 shift 1
;; ;;
verbose|insecure|noproxy|noreload|daemon-not-running) verbose|insecure|noproxy|noreload|daemon-not-running) NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}" ;;
NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}" *) warning "Ignoring unrecognized claiming option ${optname}" ;;
;;
*)
warning "Ignoring unrecognized claiming option ${optname}"
;;
esac esac
;; ;;
"--local-build-options") "--local-build-options")
@ -2324,9 +2183,7 @@ parse_args() {
fatal "A source directory must be specified with the --offline-install-source option." F0501 fatal "A source directory must be specified with the --offline-install-source option." F0501
fi 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 esac
shift 1 shift 1
done done

View file

@ -21,7 +21,7 @@
# - TMPDIR (set to a usable temporary directory) # - TMPDIR (set to a usable temporary directory)
# - NETDATA_NIGHTLIES_BASEURL (set the base url for downloading the dist tarball) # - NETDATA_NIGHTLIES_BASEURL (set the base url for downloading the dist tarball)
# #
# Copyright: 2018-2020 Netdata Inc. # Copyright: 2018-2023 Netdata Inc.
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
# #
# Author: Paweł Krupa <paulfantom@gmail.com> # Author: Paweł Krupa <paulfantom@gmail.com>
@ -225,9 +225,8 @@ enable_netdata_updater() {
;; ;;
"crontab") "crontab")
if [ -d "/etc/cron.d" ]; then if [ -d "/etc/cron.d" ]; then
cat > "/etc/cron.d/netdata-updater" <<-EOF [ -f "/etc/cron.d/netdata-updater" ] && rm -f "/etc/cron.d/netdata-updater"
2 57 * * * root ${NETDATA_PREFIX}/netdata-updater.sh install -p -m 0644 -o 0 -g 0 "${NETDATA_PREFIX}/usr/lib/system/cron/netdata-updater-daily" "/etc/cron.d/netdata-updater-daily"
EOF
info "Auto-updating has been ENABLED through cron, using a crontab at /etc/cron.d/netdata-updater\n" info "Auto-updating has been ENABLED through cron, using a crontab at /etc/cron.d/netdata-updater\n"
info "If the update process fails and you have email notifications set up correctly for cron on this system, you should receive an email notification of the failure." info "If the update process fails and you have email notifications set up correctly for cron on this system, you should receive an email notification of the failure."
@ -262,6 +261,7 @@ disable_netdata_updater() {
if [ -d /etc/cron.d ]; then if [ -d /etc/cron.d ]; then
rm -f /etc/cron.d/netdata-updater rm -f /etc/cron.d/netdata-updater
rm -f /etc/cron.d/netdata-updater-daily
fi fi
info "Auto-updates have been DISABLED." info "Auto-updates have been DISABLED."
@ -715,7 +715,7 @@ update_binpkg() {
DISTRO="${ID}" DISTRO="${ID}"
supported_compat_names="debian ubuntu centos fedora opensuse" supported_compat_names="debian ubuntu centos fedora opensuse ol amzn"
if str_in_list "${DISTRO}" "${supported_compat_names}"; then if str_in_list "${DISTRO}" "${supported_compat_names}"; then
DISTRO_COMPAT_NAME="${DISTRO}" DISTRO_COMPAT_NAME="${DISTRO}"
@ -742,7 +742,7 @@ update_binpkg() {
fi fi
case "${DISTRO_COMPAT_NAME}" in case "${DISTRO_COMPAT_NAME}" in
debian) debian|ubuntu)
pm_cmd="apt-get" pm_cmd="apt-get"
repo_subcmd="update" repo_subcmd="update"
upgrade_cmd="--only-upgrade install" upgrade_cmd="--only-upgrade install"
@ -751,29 +751,7 @@ update_binpkg() {
pkg_installed_check="dpkg -s" pkg_installed_check="dpkg -s"
INSTALL_TYPE="binpkg-deb" INSTALL_TYPE="binpkg-deb"
;; ;;
ubuntu) centos|fedora|ol|amzn)
pm_cmd="apt-get"
repo_subcmd="update"
upgrade_cmd="--only-upgrade install"
pkg_install_opts="${interactive_opts}"
repo_update_opts="${interactive_opts}"
pkg_installed_check="dpkg -s"
INSTALL_TYPE="binpkg-deb"
;;
centos)
if command -v dnf > /dev/null; then
pm_cmd="dnf"
repo_subcmd="makecache"
else
pm_cmd="yum"
fi
upgrade_cmd="upgrade"
pkg_install_opts="${interactive_opts}"
repo_update_opts="${interactive_opts}"
pkg_installed_check="rpm -q"
INSTALL_TYPE="binpkg-rpm"
;;
fedora)
if command -v dnf > /dev/null; then if command -v dnf > /dev/null; then
pm_cmd="dnf" pm_cmd="dnf"
repo_subcmd="makecache" repo_subcmd="makecache"
@ -826,11 +804,10 @@ update_binpkg() {
# Simple function to encapsulate original updater behavior. # Simple function to encapsulate original updater behavior.
update_legacy() { update_legacy() {
set_tarball_urls "${RELEASE_CHANNEL}" "${IS_NETDATA_STATIC_BINARY}" set_tarball_urls "${RELEASE_CHANNEL}" "${IS_NETDATA_STATIC_BINARY}"
if [ "${IS_NETDATA_STATIC_BINARY}" = "yes" ]; then case "${IS_NETDATA_STATIC_BINARY}" in
update_static && exit 0 yes) update_static && exit 0 ;;
else *) update_build && exit 0 ;;
update_build && exit 0 esac
fi
} }
logfile= logfile=
@ -901,9 +878,7 @@ while [ -n "${1}" ]; do
disable_netdata_updater disable_netdata_updater
exit $? exit $?
;; ;;
*) *) fatal "Unrecognized option ${1}" U001A ;;
fatal "Unrecognized option ${1}" U001A
;;
esac esac
shift 1 shift 1
@ -945,9 +920,7 @@ case "${INSTALL_TYPE}" in
set_tarball_urls "${RELEASE_CHANNEL}" "${IS_NETDATA_STATIC_BINARY}" set_tarball_urls "${RELEASE_CHANNEL}" "${IS_NETDATA_STATIC_BINARY}"
update_static && exit 0 update_static && exit 0
;; ;;
*binpkg*) *binpkg*) update_binpkg && exit 0 ;;
update_binpkg && exit 0
;;
"") # Fallback case for no `.install-type` file. This just works like the old install type detection. "") # Fallback case for no `.install-type` file. This just works like the old install type detection.
validate_environment_file validate_environment_file
update_legacy update_legacy
@ -961,10 +934,6 @@ case "${INSTALL_TYPE}" in
fatal "This script does not support updating custom installations without valid environment files." U0012 fatal "This script does not support updating custom installations without valid environment files." U0012
fi fi
;; ;;
oci) oci) fatal "This script does not support updating Netdata inside our official Docker containers, please instead update the container itself." U0013 ;;
fatal "This script does not support updating Netdata inside our official Docker containers, please instead update the container itself." U0013 *) fatal "Unrecognized installation type (${INSTALL_TYPE}), unable to update." U0014 ;;
;;
*)
fatal "Unrecognized installation type (${INSTALL_TYPE}), unable to update." U0014
;;
esac esac