@cryptotaxi247 / netdata-1 / commits / c8e8dc42c

Add a dry run mode to the kickstart script. (#12322)

* Ad a dry run mode to the kickstart script. This will report what the script would try to do on the system on which it’s run without actually doing any of it. Also includes a handful of mnior changes to improve the overall UX of the script. * Create UPDATE.md I commited my change directly because it was easier to express which changes I wanted. * Fix typo in documentation file. Co-authored-by: Tina Luedtke <kickoke@users.noreply.github.com>

Austin S. Hemmelgarn committed Mar 16, 2022 at 07:35 UTC c8e8dc42c5ec295006ddd07dcb17666fb246d75d
3 files changed +171 -71
packaging/installer/UPDATE.md
+24 -20
@@ -17,7 +17,17 @@ or stable version. You can also [enable or disable automatic updates on an exist
17 Before you update the Netdata Agent, check to see if your Netdata Agent is already up-to-date by clicking on the update
18 icon in the local Agent dashboard's top navigation. This modal informs you whether your Agent needs an update or not.
19
20 -![Opening the Agent's Update modal](https://user-images.githubusercontent.com/1153921/99738428-add06780-2a87-11eb-8268-0e17b689eb3f.gif)
20 +The exact update method to use depends on the install type:
21 +
22 +- Installs with an install type of 'custom' usually indicate installing a third-party package through the system
23 + package manager. To update these installs, you should update the package just like you would any other package
24 + on your system.
25 +- Installs with an install type starting with `binpkg` or ending with `build` or `static` can be updated using
26 + our [regular update method](#updates-for-most-systems).
27 +- Installs with an install type of 'oci' were created from our official Docker images, and should be updated
28 + using our [Docker](#docker) update procedure.
29 +- macOS users should check [our update instructions for macOS](#macos).
30 +- Manually built installs should check [our update instructions for manual builds](#manual-installation-from-git).
31
32 ## Determine which installation method you used
33
@@ -27,29 +37,23 @@ Starting with netdata v1.33.0, you can use Netdata itself to determine the insta
37 netdata -W buildinfo | grep 'Install type:'
38 ```
39
30 -If this produces no output, you have an older install and will have to manually look in the Netdata config directory.
31 -If you are not sure where your Netdata config directory is, see the [configuration doc](/docs/configure/nodes.md). In
32 -most installations, this is `/etc/netdata`.
40 +If you are using an older version of Netdata, or the above command produces no output, you can run our one-line
41 +installation script in dry-run mode to attempt to determine what method to use to update by running the following
42 +command:
43
34 -Use `cd` to navigate to the Netdata config directory, then use `ls -a` to look for a file called `.install-type`.
44 +```bash
45 +wget -O /tmp/netdata-kickstart.sh https://my-netdata.io/kickstart.sh && sh /tmp/netdata-kickstart.sh --dry-run
46 +```
47
36 -- If the `.install-type` file doex not exist, look for a file in the same directory called `.environment`.
37 - - If the `.environment` file does not exist, then you have a ‘custom’ install.
38 - - If the `.environment` file does exist, then you have either a ‘static’ or ‘build’ install.
39 -- If the `.install-type` file does exist, check it’s contents with `cat .install-type`.
40 - - The value of the `INSTALL_TYPE` key indicates what type of install you have.
48 +Note that if you installed Netdata using an installation prefix, you will need to add an `--install` option
49 +specifying that prefix to make sure it finds the existing install.
50
42 -The exact update method to use depends on the install type:
51 +If you see a line starting with `--- Would attempt to update existing installation by running the updater script
52 +located at:`, then our [regular update method](#updates-for-most-systems) will work for you.
53
44 -- Installs with an install type of 'custom' usually indicate installing a third-party package through the system
45 - package manager. To update these installs, you should update the package just like you would any other package
46 - on your system.
47 -- Installs with an install type starting with `binpkg` or ending with `build` or `static` can be updated using
48 - our [regular update method](#updates-for-most-systems).
49 -- Installs with an install type of 'oci' were created from our official Docker images, and should be updated
50 - using our [Docker](#docker) update procedure.
51 -- macOS users should check [our update instructions for macOS](#macos).
52 -- Manually built installs should check [our update instructions for manual builds](#manual-installation-from-git).
54 +Otherwise, it should either indicate that the installation type is not supported (which probably means you either
55 +have a `custom` instal or built Netdata manually) or indicate that it would create a new install (which means that
56 +you either used a non-standard install path, or that you don’t actually have Netdata installed).
57
58 ## Updates for most systems
59
packaging/installer/kickstart.sh
+146 -51
@@ -16,6 +16,7 @@ START_TIME="$(date +%s)"
16 # ======================================================================
17 # Defaults for environment variables
18
19 +DRY_RUN=0
20 SELECTED_INSTALL_METHOD="none"
21 INSTALL_TYPE="unknown"
22 INSTALL_PREFIX=""
@@ -62,6 +63,7 @@ USAGE: kickstart.sh [options]
63 --non-interactive Do not prompt for user input. (default: prompt if there is a controlling terminal)
64 --interactive Prompt for user input even if there is no controlling terminal.
65 --dont-start-it Do not start the agent by default (only for static installs or local builds)
66 + --dry-run Report what we would do with the given options on this system, but don’t actually do anything.
67 --stable-channel Install a stable version instead of a nightly build (default: install a nightly build)
68 --nightly-channel Install a nightly build instead of a stable version
69 --no-updates Do not enable automatic updates (default: enable automatic updates)
@@ -80,7 +82,7 @@ USAGE: kickstart.sh [options]
82 --claim-only If there is an existing install, only try to claim it, not update it.
83 --claim-* Specify other options for the claiming script.
84 --no-cleanup Don't do any cleanup steps. This is intended to help with debugging the installer.
83 - --uninstall Uninstall netdata.
85 + --uninstall Uninstall an existing installation of Netdata.
86
87 Additionally, this script may use the following environment variables:
88
@@ -101,7 +103,7 @@ HEREDOC
103 # Telemetry functions
104
105 telemetry_event() {
104 - if [ "${NETDATA_DISABLE_TELEMETRY}" -eq 1 ]; then
106 + if [ "${NETDATA_DISABLE_TELEMETRY}" -eq 1 ] || [ "${DRY_RUN}" -eq 1 ]; then
107 return 0
108 fi
109
@@ -297,6 +299,10 @@ run() {
299 info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ "
300 fi
301
302 + if [ "${DRY_RUN}" -eq 1 ]; then
303 + printf >&2 "%s" "Would run command:\n"
304 + fi
305 +
306 {
307 printf "%s" "${info}"
308 escaped_print "${@}"
@@ -307,9 +313,13 @@ run() {
313 escaped_print >&2 "${@}"
314 printf >&2 "%s\n" "${TPUT_RESET}"
315
310 - "${@}"
316 + if [ "${DRY_RUN}" -ne 1 ]; then
317 + "${@}"
318 + ret=$?
319 + else
320 + ret=0
321 + fi
322
312 - ret=$?
323 if [ ${ret} -ne 0 ]; then
324 run_failed
325 printf "%s\n" "FAILED with exit code ${ret}" >> "${run_logfile}"
@@ -361,6 +371,17 @@ create_tmp_directory() {
371 mktemp -d -t netdata-kickstart-XXXXXXXXXX
372 }
373
374 +check_for_remote_file() {
375 + url="${1}"
376 + if command -v curl > /dev/null 2>&1; then
377 + curl --output /dev/null --silent --head --fail "${url}" || return 1
378 + elif command -v wget > /dev/null 2>&1; then
379 + wget -S --spider "${url}" 2>&1 | grep -q 'HTTP/1.1 200 OK' || return 1
380 + else
381 + fatal "I need curl or wget to proceed, but neither of them are available on this system." F0003
382 + fi
383 +}
384 +
385 download() {
386 url="${1}"
387 dest="${2}"
@@ -522,6 +543,11 @@ update() {
543 updater="${ndprefix}/usr/libexec/netdata/netdata-updater.sh"
544
545 if [ -x "${updater}" ]; then
546 + if [ "${DRY_RUN}" -eq 1 ]; then
547 + progress "Would attempt to update existing installation by running the updater script located at: ${updater}"
548 + return 0
549 + fi
550 +
551 if run ${ROOTCMD} "${updater}" --not-running-from-cron; then
552 progress "Updated existing install at ${ndprefix}"
553 return 0
@@ -529,6 +555,7 @@ update() {
555 fatal "Failed to update existing Netdata install at ${ndprefix}" F0100
556 fi
557 else
558 + warning "Could not find a usable copy of the updater script."
559 return 1
560 fi
561 }
@@ -539,24 +566,40 @@ uninstall() {
566
567 export INSTALL_PREFIX="${ndprefix}"
568
569 + uninstaller="${INSTALL_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh"
570 + uninstaller_url="https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/netdata-uninstaller.sh"
571 +
572 if [ $INTERACTIVE = 0 ]; then
573 FLAGS="--yes --force"
574 else
575 FLAGS="--yes"
576 fi
577
548 - if [ -f "${INSTALL_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh" ]; then
549 - echo "Found existing netdata-uninstaller. Running it.."
550 - ${ROOTCMD} "${INSTALL_PREFIX}/usr/libexec/netdata/netdata-uninstaller.sh" $FLAGS
578 + if [ -x "${uninstaller}" ]; then
579 + if [ "${DRY_RUN}" -eq 1 ]; then
580 + progress "Would attempt to uninstall existing install with uninstaller script found at: ${uninstaller}"
581 + return 0
582 + else
583 + progress "Found existing netdata-uninstaller. Running it.."
584 + run ${ROOTCMD} "${uninstaller}" $FLAGS
585 + fi
586 else
552 - echo "Downloading netdata-uninstaller ..."
553 - wget https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/netdata-uninstaller.sh -O "${tmpdir}/netdata-uninstaller.sh"
554 - chmod +x "${tmpdir}/netdata-uninstaller.sh"
555 - ${ROOTCMD} "${tmpdir}/netdata-uninstaller.sh" $FLAGS
587 + if [ "${DRY_RUN}" -eq 1 ]; then
588 + progress "Would download installer script from: ${uninstaller_url}"
589 + progress "Would attempt to uninstall existing install with downloaded uninstaller script."
590 + return 0
591 + else
592 + progress "Downloading netdata-uninstaller ..."
593 + download "${uninstaller_url}" "${tmpdir}/netdata-uninstaller.sh"
594 + chmod +x "${tmpdir}/netdata-uninstaller.sh"
595 + run ${ROOTCMD} "${tmpdir}/netdata-uninstaller.sh" $FLAGS
596 + fi
597 fi
598 }
599
600 detect_existing_install() {
601 + progress "Checking for existing installations of Netdata..."
602 +
603 if pkg_installed netdata; then
604 ndprefix="/"
605 else
@@ -584,7 +627,6 @@ detect_existing_install() {
627
628 if [ -n "${ndprefix}" ]; then
629 typefile="${ndprefix}/etc/netdata/.install-type"
587 - envfile="${ndprefix}/etc/netdata/.environment"
630 if [ -r "${typefile}" ]; then
631 ${ROOTCMD} sh -c "cat \"${typefile}\" > \"${tmpdir}/install-type\""
632 # shellcheck disable=SC1090,SC1091
@@ -593,6 +635,7 @@ detect_existing_install() {
635 INSTALL_TYPE="unknown"
636 fi
637
638 + envfile="${ndprefix}/etc/netdata/.environment"
639 if [ "${INSTALL_TYPE}" = "unknown" ] || [ "${INSTALL_TYPE}" = "custom" ]; then
640 if [ -r "${envfile}" ]; then
641 ${ROOTCMD} sh -c "cat \"${envfile}\" > \"${tmpdir}/environment\""
@@ -621,7 +664,6 @@ handle_existing_install() {
664 case "${INSTALL_TYPE}" in
665 kickstart-*|legacy-*|binpkg-*|manual-static|unknown)
666 if [ "${INSTALL_TYPE}" = "unknown" ]; then
624 -
667 warning "Found an existing netdata install at ${ndprefix}, but could not determine the install type."
668 warning "Usually this means you installed Netdata through your distribution’s regular package repositories or some other unsupported method."
669 else
@@ -763,7 +805,7 @@ confirm_install_prefix() {
805 check_claim_opts() {
806 # shellcheck disable=SC2235,SC2030
807 if [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_ROOMS}" ]; then
766 - fatal "Invalid claiming options, claim rooms may only be specified when a token and URL are specified." F0204
808 + fatal "Invalid claiming options, claim rooms may only be specified when a token is specified." F0204
809 elif [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_EXTRA}" ]; then
810 fatal "Invalid claiming options, a claiming token must be specified." F0204
811 elif [ "${NETDATA_DISABLE_CLOUD}" -eq 1 ] && [ -n "${NETDATA_CLAIM_TOKEN}" ]; then
@@ -796,7 +838,12 @@ is_netdata_running() {
838 }
839
840 claim() {
799 - progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
841 + if [ "${DRY_RUN}" -eq 1 ]; then
842 + progress "Would attempt to claim agent to ${NETDATA_CLAIM_URL}"
843 + else
844 + progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}"
845 + fi
846 +
847 if [ -z "${INSTALL_PREFIX}" ] || [ "${INSTALL_PREFIX}" = "/" ]; then
848 NETDATA_CLAIM_PATH=/usr/sbin/netdata-claim.sh
849 elif [ "${INSTALL_PREFIX}" = "/opt/netdata" ]; then
@@ -805,12 +852,22 @@ claim() {
852 NETDATA_CLAIM_PATH="${INSTALL_PREFIX}/netdata/usr/sbin/netdata-claim.sh"
853 fi
854
855 + claim_opts="-token=${NETDATA_CLAIM_TOKEN} -url=${NETDATA_CLAIM_URL}"
856 +
857 + if [ -n "${NETDATA_CLAIM_ROOMS}" ]; then
858 + claim_opts="${claim_opts} -rooms=${NETDATA_CLAIM_ROOMS}"
859 + fi
860 +
861 if ! is_netdata_running; then
809 - NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -daemon-not-running"
862 + claim_opts="${claim_opts} -daemon-not-running"
863 + fi
864 +
865 + if [ -n "${NETDATA_CLAIM_EXTRA}" ]; then
866 + claim_opts="${claim_opts} ${NETDATA_CLAIM_EXTRA}"
867 fi
868
869 # shellcheck disable=SC2086
813 - if ${ROOTCMD} "${NETDATA_CLAIM_PATH}" -token="${NETDATA_CLAIM_TOKEN}" -rooms="${NETDATA_CLAIM_ROOMS}" -url="${NETDATA_CLAIM_URL}" ${NETDATA_CLAIM_EXTRA}; then
870 + if run ${ROOTCMD} "${NETDATA_CLAIM_PATH}" ${claim_opts}; then
871 progress "Successfully claimed node"
872 else
873 warning "Unable to claim node, you must do so manually."
@@ -870,10 +927,10 @@ check_special_native_deps() {
927 progress "Checking for libuv availability."
928 # shellcheck disable=SC2086
929 if ${pm_cmd} search ${interactive_opts} -v libuv | grep -q "No matches found"; then
873 - progress "libv not found, checking for EPEL availability."
930 + progress "libuv not found, checking for EPEL availability."
931 # shellcheck disable=SC2086
932 if ${pm_cmd} search ${interactive_opts} -v epel-release | grep -q "No matches found"; then
876 - warning "Unable to find a suitable source for libuv, cannot install on this system."
933 + warning "Unable to find a suitable source for libuv, cannot install using native packages on this system."
934 return 1
935 else
936 progress "EPEL is available, attempting to install so that required dependencies are available."
@@ -896,7 +953,11 @@ try_package_install() {
953 return 1
954 fi
955
899 - progress "Attempting to install using native packages..."
956 + if [ "${DRY_RUN}" -eq 1 ]; then
957 + progress "Would attempt to install using native packages..."
958 + else
959 + progress "Attempting to install using native packages..."
960 + fi
961
962 if [ "${RELEASE_CHANNEL}" = "nightly" ]; then
963 release="-edge"
@@ -1010,14 +1071,17 @@ try_package_install() {
1071 repoconfig_url="${REPOCONFIG_URL_PREFIX}/${repo_prefix}/${repoconfig_file}/download.${pkg_type}"
1072
1073 if ! pkg_installed "${repoconfig_name}"; then
1013 - progress "Downloading repository configuration package."
1014 - if ! download "${repoconfig_url}" "${tmpdir}/${repoconfig_file}"; then
1015 - warning "Failed to download repository configuration package."
1074 + progress "Checking for availability of repository configuration package."
1075 + if ! check_for_remote_file "${repoconfig_url}"; then
1076 + warning "No repository configuration package available for ${DISTRO} ${SYSVERSION}."
1077 return 2
1078 fi
1079
1080 + if ! download "${repoconfig_url}" "${tmpdir}/${repoconfig_file}"; then
1081 + fatal "Failed to download repository configuration package." F0209
1082 + fi
1083 +
1084 if [ -n "${needs_early_refresh}" ]; then
1020 - progress "Updating repository metadata."
1085 # shellcheck disable=SC2086
1086 if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
1087 warning "Failed to refresh repository metadata."
@@ -1025,7 +1089,6 @@ try_package_install() {
1089 fi
1090 fi
1091
1028 - progress "Installing repository configuration package."
1092 # shellcheck disable=SC2086
1093 if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then
1094 warning "Failed to install repository configuration package."
@@ -1033,7 +1096,6 @@ try_package_install() {
1096 fi
1097
1098 if [ -n "${repo_subcmd}" ]; then
1036 - progress "Updating repository metadata."
1099 # shellcheck disable=SC2086
1100 if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
1101 fatal "Failed to update repository metadata." F0205
@@ -1044,7 +1106,7 @@ try_package_install() {
1106 fi
1107
1108 if ! check_special_native_deps; then
1047 - warning "Could not find secondary dependencies ${DISTRO} on ${SYSARCH}."
1109 + warning "Could not find secondary dependencies for ${DISTRO} on ${SYSARCH}."
1110 if [ -z "${NO_CLEANUP}" ]; then
1111 progress "Attempting to uninstall repository configuration package."
1112 # shellcheck disable=SC2086
@@ -1053,7 +1115,6 @@ try_package_install() {
1115 return 2
1116 fi
1117
1056 - progress "Checking for usable Netdata package."
1118 if ! netdata_avail_check "${DISTRO_COMPAT_NAME}"; then
1119 warning "Could not find a usable native package for ${DISTRO} on ${SYSARCH}."
1120 if [ -z "${NO_CLEANUP}" ]; then
@@ -1069,7 +1130,6 @@ try_package_install() {
1130 run ${ROOTCMD} touch "/etc/netdata/.opt-out-from-anonymous-statistics"
1131 fi
1132
1072 - progress "Installing Netdata package."
1133 # shellcheck disable=SC2086
1134 if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} netdata; then
1135 warning "Failed to install Netdata package."
@@ -1098,19 +1158,32 @@ set_static_archive_urls() {
1158
1159 try_static_install() {
1160 set_static_archive_urls "${RELEASE_CHANNEL}"
1101 - progress "Downloading static netdata binary: ${NETDATA_STATIC_ARCHIVE_URL}"
1161 + if [ "${DRY_RUN}" -eq 1 ]; then
1162 + progress "Would attempt to install using static build..."
1163 + else
1164 + progress "Attempting to install using static build..."
1165 + fi
1166
1103 - if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "${tmpdir}/netdata-${SYSARCH}-latest.gz.run"; then
1104 - warning "Unable to download static build archive for ${SYSARCH}."
1167 + # Check status code first, so that we can provide nicer fallback for dry runs.
1168 + if ! check_for_remote_file "${NETDATA_STATIC_ARCHIVE_URL}"; then
1169 + warning "No static build available for ${SYSARCH} CPUs."
1170 return 2
1171 fi
1172
1173 + if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "${tmpdir}/netdata-${SYSARCH}-latest.gz.run"; then
1174 + fatal "Unable to download static build archive for ${SYSARCH}." F0208
1175 + fi
1176 +
1177 if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then
1178 fatal "Unable to fetch checksums to verify static build archive." F0206
1179 fi
1180
1112 - if ! grep "netdata-${SYSARCH}-latest.gz.run" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
1113 - fatal "Static binary checksum validation failed. 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." F0207
1181 + if [ "${DRY_RUN}" -eq 1 ]; then
1182 + progress "Would validate SHA256 checksum of downloaded static build archive."
1183 + else
1184 + if ! grep "netdata-${SYSARCH}-latest.gz.run" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
1185 + fatal "Static binary checksum validation failed. 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." F0207
1186 + fi
1187 fi
1188
1189 if [ "${INTERACTIVE}" -eq 0 ]; then
@@ -1125,18 +1198,20 @@ try_static_install() {
1198 return 2
1199 fi
1200
1201 + if [ "${DRY_RUN}" -ne 1 ]; then
1202 install_type_file="/opt/netdata/etc/netdata/.install-type"
1129 - if [ -f "${install_type_file}" ]; then
1130 - ${ROOTCMD} sh -c "cat \"${install_type_file}\" > \"${tmpdir}/install-type\""
1131 - ${ROOTCMD} chown "$(id -u)":"$(id -g)" "${tmpdir}/install-type"
1132 - # shellcheck disable=SC1090,SC1091
1133 - . "${tmpdir}/install-type"
1134 - cat > "${tmpdir}/install-type" <<- EOF
1203 + if [ -f "${install_type_file}" ]; then
1204 + ${ROOTCMD} sh -c "cat \"${install_type_file}\" > \"${tmpdir}/install-type\""
1205 + ${ROOTCMD} chown "$(id -u)":"$(id -g)" "${tmpdir}/install-type"
1206 + # shellcheck disable=SC1090,SC1091
1207 + . "${tmpdir}/install-type"
1208 + cat > "${tmpdir}/install-type" <<- EOF
1209 INSTALL_TYPE='kickstart-static'
1210 PREBUILT_ARCH='${PREBUILT_ARCH}'
1211 EOF
1138 - ${ROOTCMD} chown netdata:netdata "${tmpdir}/install-type"
1139 - ${ROOTCMD} cp "${tmpdir}/install-type" "${install_type_file}"
1212 + ${ROOTCMD} chown netdata:netdata "${tmpdir}/install-type"
1213 + ${ROOTCMD} cp "${tmpdir}/install-type" "${install_type_file}"
1214 + fi
1215 fi
1216 }
1217
@@ -1162,13 +1237,16 @@ install_local_build_dependencies() {
1237 return 1
1238 fi
1239
1165 - progress "Fetching script to detect required packages..."
1240 download "${PACKAGES_SCRIPT}" "${tmpdir}/install-required-packages.sh"
1241
1168 - if [ ! -s "${tmpdir}/install-required-packages.sh" ]; then
1242 + if [ ! -s "${tmpdir}/install-required-packages.sh" ] && [ "${DRY_RUN}" -ne 1 ]; then
1243 warning "Downloaded dependency installation script is empty."
1244 else
1171 - progress "Running downloaded script to detect required packages..."
1245 + if [ "${DRY_RUN}" -eq 1 ]; then
1246 + progress "Would run downloaded script to install required build dependencies..."
1247 + else
1248 + progress "Running downloaded script to install required build dependencies..."
1249 + fi
1250
1251 if [ "${INTERACTIVE}" -eq 0 ]; then
1252 opts="--dont-wait --non-interactive"
@@ -1188,7 +1266,11 @@ install_local_build_dependencies() {
1266 }
1267
1268 build_and_install() {
1191 - progress "Building netdata"
1269 + if [ "${DRY_RUN}" -eq 1 ]; then
1270 + progress "Would attempt to build netdata..."
1271 + else
1272 + progress "Building netdata..."
1273 + fi
1274
1275 echo "INSTALL_TYPE='kickstart-build'" > system/.install-type
1276
@@ -1226,6 +1308,12 @@ build_and_install() {
1308 }
1309
1310 try_build_install() {
1311 + if [ "${DRY_RUN}" -eq 1 ]; then
1312 + progress "Would attempt to install by building locally..."
1313 + else
1314 + progress "Attempting to install by building locally..."
1315 + fi
1316 +
1317 if ! install_local_build_dependencies; then
1318 return 1
1319 fi
@@ -1235,15 +1323,21 @@ try_build_install() {
1323 download "${NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"
1324 download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-latest.tar.gz"
1325
1238 - if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
1239 - fatal "Tarball checksum validation failed. 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." F0005
1326 + if [ "${DRY_RUN}" -eq 1 ]; then
1327 + progress "Would validate SHA256 checksum of downloaded source archive."
1328 + else
1329 + if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
1330 + fatal "Tarball checksum validation failed. 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." F0005
1331 + fi
1332 fi
1333
1334 run tar -xf "${tmpdir}/netdata-latest.tar.gz" -C "${tmpdir}"
1335 rm -rf "${tmpdir}/netdata-latest.tar.gz" > /dev/null 2>&1
1244 - cd "$(find "${tmpdir}" -mindepth 1 -maxdepth 1 -type d -name netdata-)" || fatal "Cannot cd to netdata source tree" F0006
1336 + if [ "${DRY_RUN}" -ne 1 ]; then
1337 + cd "$(find "${tmpdir}" -mindepth 1 -maxdepth 1 -type d -name netdata-)" || fatal "Cannot cd to netdata source tree" F0006
1338 + fi
1339
1246 - if [ -x netdata-installer.sh ]; then
1340 + if [ -x netdata-installer.sh ] || [ "${DRY_RUN}" -eq 1 ]; then
1341 build_and_install || return 1
1342 else
1343 # This case is needed because some platforms produce an extra directory on the source tarball extraction.
@@ -1377,6 +1471,7 @@ while [ -n "${1}" ]; do
1471 "--no-cleanup") NO_CLEANUP=1 ;;
1472 "--dont-wait"|"--non-interactive") INTERACTIVE=0 ;;
1473 "--interactive") INTERACTIVE=1 ;;
1474 + "--dry-run") DRY_RUN=1 ;;
1475 "--stable-channel") RELEASE_CHANNEL="stable" ;;
1476 "--no-updates") NETDATA_AUTO_UPDATES=0 ;;
1477 "--auto-update") NETDATA_AUTO_UPDATES="1" ;;
@@ -1473,7 +1568,7 @@ fi
1568
1569 tmpdir="$(create_tmp_directory)"
1570 progress "Using ${tmpdir} as a temporary directory."
1476 -cd "${tmpdir}" || exit 1
1571 +cd "${tmpdir}" || fatal "Failed to change current working directory to ${tmpdir}." F000A
1572
1573 handle_existing_install
1574
packaging/installer/methods/kickstart.md
+1
@@ -48,6 +48,7 @@ The `kickstart.sh` script accepts a number of optional parameters to control how
48 - `--non-interactive`: Don’t prompt for anything and assume yes whenever possible, overriding any automatic detection of an interactive run.
49 - `--interactive`: Act as if running interactively, even if automatic detection indicates a run is non-interactive.
50 - `--dont-wait`: Synonym for `--non-interactive`
51 +- `--dry-run`: Show what the installer would do, but don’t actually do any of it.
52 - `--dont-start-it`: Don’t auto-start the daemon after installing. This parameter is not guaranteed to work.
53 - `--nightly-channel`: Use a nightly build instead of a stable release (this is the default).
54 - `--stable-channel`: Use a stable release instead of a nightly build.