@cryptotaxi247 / netdata-1 / commits / 15fc26437

Add support for installing a specific major version of the agent on install. (#16413)

* Add support for installing a specific major version of the agent on install. * Minor fixup to improve reusability.

Austin S. Hemmelgarn committed Nov 16, 2023 at 10:49 UTC 15fc264375d322ebdc1b7765d2ab2f2c4e711391
1 file changed +81 -17
packaging/installer/kickstart.sh
+81 -17
@@ -2,7 +2,7 @@
2 #
3 # SPDX-License-Identifier: GPL-3.0-or-later
4 #
5 -# Next unused error code: F0515
5 +# Next unused error code: F0516
6
7 # ======================================================================
8 # Constants
@@ -38,6 +38,7 @@ FORUM_URL="https://community.netdata.cloud/"
38 INSTALL_DOC_URL="https://learn.netdata.cloud/docs/install-the-netdata-agent/one-line-installer-for-all-linux-systems"
39 PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh"
40 PUBLIC_CLOUD_URL="https://app.netdata.cloud"
41 +RELEASE_INFO_URL="https://repo.netdata.cloud/releases"
42 REPOCONFIG_DEB_URL_PREFIX="https://repo.netdata.cloud/repos/repoconfig"
43 REPOCONFIG_RPM_URL_PREFIX="https://repo.netdata.cloud/repos/repoconfig"
44 TELEMETRY_URL="https://us-east1-netdata-analytics-bi.cloudfunctions.net/ingest_agent_events"
@@ -614,6 +615,22 @@ download() {
615 fi
616 }
617
618 +get_actual_version() {
619 + major="${1}"
620 + channel="${2}"
621 + url="${RELEASE_INFO_URL}/${channel}/${major}"
622 +
623 + if check_for_remote_file "${RELEASE_INFO_URL}"; then
624 + if check_for_remote_file "${url}"; then
625 + download "${url}" -
626 + else
627 + echo "NONE"
628 + fi
629 + else
630 + echo ""
631 + fi
632 +}
633 +
634 get_redirect() {
635 url="${1}"
636
@@ -2021,6 +2038,40 @@ install_on_freebsd() {
2038 # ======================================================================
2039 # Argument parsing code
2040
2041 +handle_major_version() {
2042 + CONTINUE_INSTALL_PROMPT="Attempting to install will use the latest version available overall. Do you wish to continue the install?"
2043 +
2044 + if [ -z "${INSTALL_MAJOR_VERSION}" ]; then
2045 + return
2046 + fi
2047 +
2048 + actual_version="$(get_actual_version "v${INSTALL_MAJOR_VERSION}" "${RELEASE_CHANNEL}")"
2049 +
2050 + if [ -z "${actual_version}" ]; then
2051 + if [ "${INTERACTIVE}" -eq 0 ]; then
2052 + fatal "Could not determine the lastest releaase in channel '${RELEASE_CHANNEL}' with major version '${INSTALL_MAJOR_VERSION}'" F0517
2053 + else
2054 + if confirm "Unable to determine the correct version to install for major version '${INSTALL_MAJOR_VERSION}'. ${CONTINUE_INSTALL_PROMPT}"; then
2055 + progress "User requested continuing the install with the latest version."
2056 + else
2057 + fatal "Cancelling installation at user request." F0518
2058 + fi
2059 + fi
2060 + elif [ "${actual_version}" = 'NONE' ]; then
2061 + if [ "${INTERACTIVE}" -eq 0 ]; then
2062 + warning "No releases with major version '${INSTALL_MAJOR_VERSION}' have been published. Continuing the install with the latest version instead."
2063 + else
2064 + if confirm "No releases with major version '${INSTALL_MAJOR_VERSION}' have been published. ${CONTINUE_INSTALL_PROMPT}"; then
2065 + progress "User requested continuing the install with the latest version."
2066 + else
2067 + fatal "Cancelling installation at user request." F0519
2068 + fi
2069 + fi
2070 + else
2071 + INSTALL_VERSION="${actual_version}"
2072 + fi
2073 +}
2074 +
2075 validate_args() {
2076 check_claim_opts
2077
@@ -2052,22 +2103,6 @@ validate_args() {
2103 esac
2104 fi
2105
2055 - if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ -n "${INSTALL_VERSION}" ]; then
2056 - fatal "Specifying an install version alongside an offline install source is not supported." F050A
2057 - fi
2058 -
2059 - if [ "${NETDATA_AUTO_UPDATES}" = "default" ]; then
2060 - if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] || [ -n "${INSTALL_VERSION}" ]; then
2061 - AUTO_UPDATE=0
2062 - else
2063 - AUTO_UPDATE=1
2064 - fi
2065 - elif [ "${NETDATA_AUTO_UPDATES}" = 1 ]; then
2066 - AUTO_UPDATE=1
2067 - else
2068 - AUTO_UPDATE=0
2069 - fi
2070 -
2106 if [ "${RELEASE_CHANNEL}" = "default" ]; then
2107 if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
2108 SELECTED_RELEASE_CHANNEL="$(cat "${NETDATA_OFFLINE_INSTALL_SOURCE}/channel")"
@@ -2085,6 +2120,31 @@ validate_args() {
2120
2121 SELECTED_RELEASE_CHANNEL="${RELEASE_CHANNEL}"
2122 fi
2123 +
2124 + if [ -n "${INSTALL_MAJOR_VERSION}" ] && [ -n "${INSTALL_VERSION}" ]; then
2125 + fatal "Only one of --install-version or --install-major-version may be specified." F0515
2126 + fi
2127 +
2128 + handle_major_version # Appropriately updates INSTALL_VERSION if INSTALL_MAJOR_VERSION is set.
2129 +
2130 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] && [ -n "${INSTALL_VERSION}" ]; then
2131 + fatal "Specifying an install version alongside an offline install source is not supported." F050A
2132 + fi
2133 +
2134 + if [ "${NETDATA_AUTO_UPDATES}" = "default" ]; then
2135 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ] || [ -n "${INSTALL_VERSION}" ]; then
2136 + AUTO_UPDATE=0
2137 + else
2138 + AUTO_UPDATE=1
2139 + fi
2140 + elif [ "${NETDATA_INSTALL_MAJOR_VERSION}" ]; then
2141 + warning "Forcibly disabling auto updates as a specific major version was requested."
2142 + AUTO_UPDATE=0
2143 + elif [ "${NETDATA_AUTO_UPDATES}" = 1 ]; then
2144 + AUTO_UPDATE=1
2145 + else
2146 + AUTO_UPDATE=0
2147 + fi
2148 }
2149
2150 set_action() {
@@ -2164,6 +2224,10 @@ parse_args() {
2224 OLD_INSTALL_PREFIX="${2}"
2225 shift 1
2226 ;;
2227 + "--install-major-version")
2228 + INSTALL_MAJOR_VERSION="${2}"
2229 + shift 1
2230 + ;;
2231 "--install-version")
2232 INSTALL_VERSION="${2}"
2233 AUTO_UPDATE=0