@cryptotaxi247 / netdata-1 / commits / 002c9518f

Support offline installs in the updater code. (#17648)

Austin S. Hemmelgarn committed May 15, 2024 at 07:54 UTC 002c9518f116d77c3748b053ca185d1078bbc4a7
2 files changed +29 -2
packaging/installer/kickstart.sh
+9 -1
@@ -2,7 +2,7 @@
2 #
3 # SPDX-License-Identifier: GPL-3.0-or-later
4 #
5 -# Next unused error code: F0519
5 +# Next unused error code: F051A
6
7 # ======================================================================
8 # Constants
@@ -893,6 +893,10 @@ update() {
893 opts="--interactive"
894 fi
895
896 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
897 + export NETDATA_OFFLINE_INSTALL_SOURCE="${NETDATA_OFFLINE_INSTALL_SOURCE}"
898 + fi
899 +
900 if run_script "${updater}" ${opts} --not-running-from-cron; then
901 progress "Updated existing install at ${ndprefix}"
902 return 0
@@ -2241,6 +2245,10 @@ validate_args() {
2245 case "${NETDATA_FORCE_METHOD}" in
2246 native|build) fatal "Offline installs are only supported for static builds currently." F0502 ;;
2247 esac
2248 +
2249 + if [ ! -d "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
2250 + fatal "Offline install source must be a directory." F0519
2251 + fi
2252 fi
2253
2254 if [ -n "${LOCAL_BUILD_OPTIONS}" ]; then
packaging/installer/netdata-updater.sh
+20 -1
@@ -399,6 +399,11 @@ _safe_download() {
399 succeeded=0
400 checked=0
401
402 + if echo "${url}" | grep -Eq "^file:///"; then
403 + run cp "${url#file://}" "${dest}" || return 1
404 + return 0
405 + fi
406 +
407 check_for_curl
408
409 if [ -n "${curl}" ]; then
@@ -660,7 +665,11 @@ set_tarball_urls() {
665 fi
666 fi
667
663 - if [ "$1" = "stable" ]; then
668 + if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
669 + path="$(cd "${NETDATA_OFFLINE_INSTALL_SOURCE}" || exit 1; pwd)"
670 + export NETDATA_TARBALL_URL="file://${path}/${filename}"
671 + export NETDATA_TARBALL_CHECKSUM_URL="file://${path}/sha256sums.txt"
672 + elif [ "$1" = "stable" ]; then
673 latest="$(get_netdata_latest_tag "${NETDATA_STABLE_BASE_URL}")"
674 export NETDATA_TARBALL_URL="${NETDATA_STABLE_BASE_URL}/download/$latest/${filename}"
675 export NETDATA_TARBALL_CHECKSUM_URL="${NETDATA_STABLE_BASE_URL}/download/$latest/sha256sums.txt"
@@ -1044,6 +1053,10 @@ while [ -n "${1}" ]; do
1053 --force-update) NETDATA_FORCE_UPDATE=1 ;;
1054 --non-interactive) INTERACTIVE=0 ;;
1055 --interactive) INTERACTIVE=1 ;;
1056 + --offline-install-source)
1057 + NETDATA_OFFLINE_INSTALL_SOURCE="${2}"
1058 + shift 1
1059 + ;;
1060 --tmpdir-path)
1061 NETDATA_TMPDIR_PATH="${2}"
1062 shift 1
@@ -1062,6 +1075,12 @@ while [ -n "${1}" ]; do
1075 shift 1
1076 done
1077
1078 +if [ -n "${NETDATA_OFFLINE_INSTALL_SOURCE}" ]; then
1079 + NETDATA_NO_UPDATER_SELF_UPDATE=1
1080 + NETDATA_UPDATER_JITTER=0
1081 + NETDATA_FORCE_UPDATE=1
1082 +fi
1083 +
1084 # Random sleep to alleviate stampede effect of Agents upgrading
1085 # and disconnecting/reconnecting at the same time (or near to).
1086 # But only we're not a controlling terminal (tty)