Improve error and warning messages in the kickstart script. (#13825)
Austin S. Hemmelgarn committed
Oct 17, 2022 at 07:19 UTC
df38c0c2c4336d2d6fdac471fc0f2f6c3db6531c
1 file changed
+41
-34
packaging/installer/kickstart.sh
+41
-34
@@ -12,7 +12,6 @@ CLOUD_BUG_REPORT_URL="https://github.com/netdata/netdata-cloud/issues/new/choose
12
DEFAULT_RELEASE_CHANNEL="nightly"
13
DISCORD_INVITE="https://discord.gg/5ygS846fR6"
14
DISCUSSIONS_URL="https://github.com/netdata/netdata/discussions"
15
-DISCUSSIONS_URL="https://github.com/netdata/netdata/discussions"
15
DOCS_URL="https://learn.netdata.cloud/docs/"
16
FORUM_URL="https://community.netdata.cloud/"
17
KICKSTART_OPTIONS="${*}"
@@ -76,6 +75,13 @@ else
75
INTERACTIVE=1
76
fi
77
78
+# ======================================================================
79
+# Shared messages used in multiple places throughout the script.
80
+
81
+BADCACHE_MSG="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"
82
+BADNET_MSG="This is usually a result of a networking issue"
83
+ERROR_F0003="Could not find a usable HTTP client. Either curl or wget is required to proceed with installation."
84
+
85
# ======================================================================
86
# Core program logic
87
@@ -532,7 +538,7 @@ check_for_remote_file() {
538
elif command -v wget > /dev/null 2>&1; then
539
wget -S --spider "${url}" 2>&1 | grep -q 'HTTP/1.1 200 OK' || return 1
540
else
535
- fatal "I need curl or wget to proceed, but neither of them are available on this system." F0003
541
+ fatal "${ERROR_F0003}" F0003
542
fi
543
}
544
@@ -547,7 +553,7 @@ download() {
553
elif command -v wget > /dev/null 2>&1; then
554
run wget -T 15 -O "${dest}" "${url}" || return 1
555
else
550
- fatal "I need curl or wget to proceed, but neither of them are available on this system." F0003
556
+ fatal "${ERROR_F0003}" F0003
557
fi
558
}
559
@@ -559,7 +565,7 @@ get_redirect() {
565
elif command -v wget > /dev/null 2>&1; then
566
run sh -c "wget --max-redirect=0 ${url} 2>&1 | grep Location | cut -d ' ' -f2 | grep -o '[^/]*$'" || return 1
567
else
562
- fatal "I need curl or wget to proceed, but neither of them are available on this system." F0003
568
+ fatal "${ERROR_F0003}" F0003
569
fi
570
}
571
@@ -571,7 +577,7 @@ safe_sha256sum() {
577
elif command -v sha256sum > /dev/null 2>&1; then
578
sha256sum "$@"
579
else
574
- fatal "I could not find a suitable checksum binary to use" F0004
580
+ fatal "Could not find a usable checksum tool. Either sha256sum, or a version of shasum supporting SHA256 checksums is required to proceed with installation." F0004
581
fi
582
}
583
@@ -586,7 +592,7 @@ get_system_info() {
592
elif [ -s "/usr/lib/os-release" ] && [ -r "/usr/lib/os-release" ]; then
593
os_release_file="/usr/lib/os-release"
594
else
589
- warning "Cannot find an os-release file ..."
595
+ warning "Cannot find usable OS release information. Native packages will not be available for this install."
596
fi
597
598
if [ -n "${os_release_file}" ]; then
@@ -673,7 +679,7 @@ confirm_root_support() {
679
fi
680
681
if [ -z "${ROOTCMD}" ]; then
676
- fatal "We need root privileges to continue, but cannot find a way to gain them. Either re-run this script as root, or set \$ROOTCMD to a command that can be used to gain root privileges" F0201
682
+ fatal "We need root privileges to continue, but cannot find a way to gain them (we support sudo, doas, and pkexec). Either re-run this script as root, or set \$ROOTCMD to a command that can be used to gain root privileges." F0201
683
fi
684
fi
685
}
@@ -722,11 +728,11 @@ update() {
728
if [ -n "${EXIT_REASON}" ]; then
729
fatal "Failed to update existing Netdata install at ${ndprefix}: ${EXIT_REASON}" "${EXIT_CODE}"
730
else
725
- fatal "Failed to update existing Netdata install at ${ndprefix}." U0000
731
+ fatal "Failed to update existing Netdata install at ${ndprefix}: Encountered an unhandled error in the updater. Further information about this error may be displayed above." U0000
732
fi
733
fi
734
else
729
- warning "Could not find a usable copy of the updater script."
735
+ warning "Could not find a usable copy of the updater script. We are unable to update this system in place."
736
return 1
737
fi
738
}
@@ -857,8 +863,7 @@ handle_existing_install() {
863
case "${INSTALL_TYPE}" in
864
kickstart-*|legacy-*|binpkg-*|manual-static|unknown)
865
if [ "${INSTALL_TYPE}" = "unknown" ]; then
860
- warning "Found an existing netdata install at ${ndprefix}, but could not determine the install type."
861
- warning "Usually this means you installed Netdata through your distribution’s regular package repositories or some other unsupported method."
866
+ warning "Found an existing netdata install at ${ndprefix}, but could not determine the install type. Usually this means you installed Netdata through your distribution’s regular package repositories or some other unsupported method."
867
else
868
progress "Found an existing netdata install at ${ndprefix}, with installation type '${INSTALL_TYPE}'."
869
fi
@@ -948,7 +953,7 @@ handle_existing_install() {
953
elif [ "${NETDATA_CLAIM_ONLY}" -eq 1 ]; then
954
fatal "User asked to claim, but did not proide a claiming token." F0202
955
else
951
- fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported, refusing to proceed." F0103
956
+ fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported by this script, refusing to proceed." F0103
957
fi
958
fi
959
;;
@@ -992,7 +997,7 @@ EOF
997
998
confirm_install_prefix() {
999
if [ -n "${INSTALL_PREFIX}" ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then
995
- fatal "The \`--install-prefix\` and \`--install\` options are only supported together with the \`--build-only\` option." F0204
1000
+ fatal "The --install-prefix and --install options are only supported together with the --build-only option." F0204
1001
fi
1002
1003
if [ -n "${INSTALL_PREFIX}" ]; then
@@ -1074,7 +1079,7 @@ claim() {
1079
fi
1080
1081
if [ ! -x "${NETDATA_CLAIM_PATH}" ]; then
1077
- fatal "Unable to find usable claiming script." F0106
1082
+ fatal "Unable to find usable claiming script. Reinstalling Netdata may resolve this." F0106
1083
fi
1084
1085
if ! is_netdata_running; then
@@ -1095,7 +1100,7 @@ claim() {
1100
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."
1101
;;
1102
3)
1098
- 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."
1103
+ 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}."
1104
;;
1105
4)
1106
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."
@@ -1233,7 +1238,7 @@ check_special_native_deps() {
1238
1239
# shellcheck disable=SC2086
1240
if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} epel-release; then
1236
- warning "Failed to install EPEL."
1241
+ warning "Failed to install EPEL, even though it is required to install native packages on this system."
1242
return 1
1243
fi
1244
fi
@@ -1244,6 +1249,8 @@ check_special_native_deps() {
1249
}
1250
1251
try_package_install() {
1252
+ 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."
1253
+
1254
if [ -z "${DISTRO}" ] || [ "${DISTRO}" = "unknown" ]; then
1255
warning "Unable to determine Linux distribution for native packages."
1256
return 2
@@ -1391,18 +1398,18 @@ try_package_install() {
1398
if ! pkg_installed "${repoconfig_name}"; then
1399
progress "Checking for availability of repository configuration package."
1400
if ! check_for_remote_file "${repoconfig_url}"; then
1394
- warning "No repository configuration package available for ${DISTRO} ${SYSVERSION}."
1401
+ warning "No repository configuration package available for ${DISTRO} ${SYSVERSION}. Cannot install native packages on this system."
1402
return 2
1403
fi
1404
1405
if ! download "${repoconfig_url}" "${tmpdir}/${repoconfig_file}"; then
1399
- fatal "Failed to download repository configuration package." F0209
1406
+ fatal "Failed to download repository configuration package. ${BADNET_MSG}." F0209
1407
fi
1408
1409
if [ -n "${needs_early_refresh}" ]; then
1410
# shellcheck disable=SC2086
1411
if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
1405
- warning "Failed to refresh repository metadata."
1412
+ warning "${failed_refresh_msg}"
1413
return 2
1414
fi
1415
fi
@@ -1416,7 +1423,7 @@ try_package_install() {
1423
if [ -n "${repo_subcmd}" ]; then
1424
# shellcheck disable=SC2086
1425
if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then
1419
- fatal "Failed to refresh repository metadata." F0205
1426
+ fatal "${failed_refresh_msg}" F0205
1427
fi
1428
fi
1429
else
@@ -1533,16 +1540,16 @@ try_static_install() {
1540
netdata_agent="${NETDATA_STATIC_ARCHIVE_OLD_URL#"https://github.com/netdata/netdata/releases/download/v${INSTALL_VERSION}/"}"
1541
export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_STATIC_ARCHIVE_OLD_URL}"
1542
else
1536
- warning "No static build available for ${SYSARCH} CPUs."
1543
+ warning "There is no static build available for ${SYSARCH} CPUs. This usually means we simply do not currently provide static builds for ${SYSARCH} CPUs."
1544
return 2
1545
fi
1546
1547
if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "${tmpdir}/${netdata_agent}"; then
1541
- fatal "Unable to download static build archive for ${SYSARCH}." F0208
1548
+ fatal "Unable to download static build archive for ${SYSARCH}. ${BADNET_MSG}." F0208
1549
fi
1550
1551
if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then
1545
- fatal "Unable to fetch checksums to verify static build archive." F0206
1552
+ fatal "Unable to fetch checksums to verify static build archive. ${BADNET_MSG}." F0206
1553
fi
1554
1555
if [ "${DRY_RUN}" -eq 1 ]; then
@@ -1550,7 +1557,7 @@ try_static_install() {
1557
else
1558
if [ -z "${INSTALL_VERSION}" ]; then
1559
if ! grep "${netdata_agent}" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
1553
- 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
1560
+ fatal "Static binary checksum validation failed. ${BADCACHE_MSG}." F0207
1561
fi
1562
fi
1563
fi
@@ -1618,7 +1625,7 @@ install_local_build_dependencies() {
1625
fi
1626
1627
if ! download "${PACKAGES_SCRIPT}" "${tmpdir}/install-required-packages.sh"; then
1621
- fatal "Failed to download dependency handling script for local build." F000D
1628
+ fatal "Failed to download dependency handling script for local build. ${BADNET_MSG}." F000D
1629
fi
1630
1631
if [ "${DRY_RUN}" -eq 1 ]; then
@@ -1680,7 +1687,7 @@ build_and_install() {
1687
if [ -n "${EXIT_REASON}" ]; then
1688
fatal "netdata-installer.sh failed to run: ${EXIT_REASON}" "${EXIT_CODE}"
1689
else
1683
- fatal "netdata-installer.sh failed to run correctly." I0000
1690
+ fatal "netdata-installer.sh failed to run: Encountered an unhandled error in the installer code." I0000
1691
fi
1692
;;
1693
2)
@@ -1706,14 +1713,14 @@ try_build_install() {
1713
1714
if [ -n "${INSTALL_VERSION}" ]; then
1715
if ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz"; then
1709
- fatal "Failed to download source tarball for local build." F000B
1716
+ fatal "Failed to download source tarball for local build. ${BADNET_MSG}." F000B
1717
fi
1718
elif ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-latest.tar.gz"; then
1712
- fatal "Failed to download source tarball for local build." F000B
1719
+ fatal "Failed to download source tarball for local build. ${BADNET_MSG}." F000B
1720
fi
1721
1722
if ! download "${NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then
1716
- fatal "Failed to download checksums for source tarball verification." F000C
1723
+ fatal "Failed to download checksums for source tarball verification. ${BADNET_MSG}." F000C
1724
fi
1725
1726
if [ "${DRY_RUN}" -eq 1 ]; then
@@ -1722,7 +1729,7 @@ try_build_install() {
1729
if [ -z "${INSTALL_VERSION}" ]; then
1730
# shellcheck disable=SC2086
1731
if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
1725
- 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
1732
+ fatal "Tarball checksum validation failed. ${BADCACHE_MSG}." F0005
1733
fi
1734
fi
1735
fi
@@ -1774,7 +1781,7 @@ prepare_offline_install_source() {
1781
1782
progress "Fetching ${NETDATA_STATIC_ARCHIVE_URL}"
1783
if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "netdata-${arch}-latest.gz.run"; then
1777
- warning "Failed to download static installer archive for ${arch}."
1784
+ warning "Failed to download static installer archive for ${arch}. ${BADNET_MSG}."
1785
fi
1786
done
1787
legacy=0
@@ -1784,13 +1791,13 @@ prepare_offline_install_source() {
1791
legacy=1
1792
1793
if ! download "${NETDATA_STATIC_ARCHIVE_OLD_URL}" "netdata-x86_64-latest.gz.run"; then
1787
- warning "Failed to download static installer archive for x86_64."
1794
+ warning "Failed to download static installer archive for x86_64. ${BADNET_MSG}."
1795
fi
1796
fi
1797
1798
progress "Fetching ${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}"
1799
if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "sha256sums.txt"; then
1793
- fatal "Failed to download checksum file." F0506
1800
+ fatal "Failed to download checksum file. ${BADNET_MSG}." F0506
1801
fi
1802
fi
1803
@@ -1802,7 +1809,7 @@ prepare_offline_install_source() {
1809
if [ "${DRY_RUN}" -ne 1 ]; then
1810
progress "Verifying checksums."
1811
if ! grep -e "$(find . -name '*.gz.run')" sha256sums.txt | safe_sha256sum -c -; then
1805
- fatal "Checksums for offline install files are incorrect. 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." F0507
1812
+ fatal "Checksums for offline install files are incorrect. ${BADCACHE_MSG}." F0507
1813
fi
1814
else
1815
progress "Would verify SHA256 checksums of downloaded installation files."