summaryrefslogtreecommitdiffstats
path: root/packaging/installer/kickstart.sh
diff options
context:
space:
mode:
Diffstat (limited to 'packaging/installer/kickstart.sh')
-rwxr-xr-xpackaging/installer/kickstart.sh69
1 files changed, 46 insertions, 23 deletions
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
index dde738c28..72b82be26 100755
--- a/packaging/installer/kickstart.sh
+++ b/packaging/installer/kickstart.sh
@@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
-# Next unused error code: F051A
+# Next unused error code: F051B
# ======================================================================
# Constants
@@ -21,8 +21,8 @@ KICKSTART_SOURCE="$(
)"
DEFAULT_PLUGIN_PACKAGES=""
PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
-REPOCONFIG_DEB_VERSION="2-2"
-REPOCONFIG_RPM_VERSION="2-2"
+REPOCONFIG_DEB_VERSION="3-2"
+REPOCONFIG_RPM_VERSION="3-2"
START_TIME="$(date +%s)"
STATIC_INSTALL_ARCHES="x86_64 armv7l armv6l aarch64 ppc64le"
@@ -378,12 +378,14 @@ trap 'trap_handler 15 0' TERM
# Utility functions
canonical_path() {
+ OLDPWD="$(pwd)"
cd "$(dirname "${1}")" || exit 1
case "$(basename "${1}")" in
..) dirname "$(pwd -P)" ;;
.) pwd -P ;;
*) echo "$(pwd -P)/$(basename "${1}")" ;;
esac
+ cd "${OLDPWD}" || exit 1
}
setup_terminal() {
@@ -453,7 +455,7 @@ deferred_warnings() {
fatal() {
deferred_warnings
- printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${1}"
+ printf >&2 "%b\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${1}"
printf >&2 "%s\n" "For community support, you can connect with us on:"
support_list
telemetry_event "INSTALL_FAILED" "${1}" "${2}"
@@ -741,8 +743,6 @@ get_redirect() {
}
safe_sha256sum() {
- # Within the context of the installer, we only use -c option that is common between the two commands
- # We will have to reconsider if we start using non-common options
if command -v shasum > /dev/null 2>&1; then
shasum -a 256 "$@"
elif command -v sha256sum > /dev/null 2>&1; then
@@ -752,6 +752,17 @@ safe_sha256sum() {
fi
}
+report_bad_sha256sum() {
+ file="${1}"
+ sums="${2}"
+
+ actual="$(safe_sha256sum "${file}" | awk '{ print $1 }')"
+ expected="$(grep "${file}" "${sums}" | awk '{ print $1 }')"
+
+ printf "Expected: %s\n" "${expected}"
+ printf "Actual: %s\n" "${actual}"
+}
+
get_system_info() {
SYSARCH="$(uname -m)"
@@ -1371,7 +1382,7 @@ set_auto_updates() {
if [ "${DRY_RUN}" -eq 1 ]; then
progress "Would have attempted to enable automatic updates."
# This first case is for catching using a new kickstart script with an old build. It can be safely removed after v1.34.0 is released.
- elif ! run_as_root grep -q '\-\-enable-auto-updates' "${updater}"; then
+ elif ! run_as_root grep -q '\--enable-auto-updates' "${updater}"; then
echo
elif ! run_as_root "${updater}" --enable-auto-updates "${NETDATA_AUTO_UPDATE_TYPE}"; then
warning "Failed to enable auto updates. Netdata will still work, but you will need to update manually."
@@ -1794,11 +1805,11 @@ try_static_install() {
return 2
fi
- if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "${tmpdir}/${netdata_agent}"; then
+ if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "./${netdata_agent}"; then
fatal "Unable to download static build archive for ${SYSARCH}. ${BADNET_MSG}." F0208
fi
- if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then
+ if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "./sha256sum.txt"; then
fatal "Unable to fetch checksums to verify static build archive. ${BADNET_MSG}." F0206
fi
@@ -1806,8 +1817,9 @@ try_static_install() {
progress "Would validate SHA256 checksum of downloaded static build archive."
else
if [ -z "${INSTALL_VERSION}" ]; then
- if ! grep "${netdata_agent}" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
- fatal "Static binary checksum validation failed. ${BADCACHE_MSG}." F0207
+ if ! grep "${netdata_agent}" ./sha256sum.txt | safe_sha256sum -c - > /dev/null 2>&1; then
+ bad_sums_report="$(report_bad_sha256sum "${netdata_agent}" "./sha256sum.txt")"
+ fatal "Static binary checksum validation failed.\n${bad_sums_report}\n${BADCACHE_MSG}." F0207
fi
fi
fi
@@ -1824,7 +1836,7 @@ try_static_install() {
progress "Installing netdata"
# shellcheck disable=SC2086
- if ! run_as_root ${env_cmd} /bin/sh "${tmpdir}/${netdata_agent}" ${opts} -- ${NETDATA_INSTALLER_OPTIONS}; then
+ if ! run_as_root ${env_cmd} /bin/sh "./${netdata_agent}" ${opts} -- ${NETDATA_INSTALLER_OPTIONS}; then
warning "Failed to install static build of Netdata on ${SYSARCH}."
run rm -rf /opt/netdata
return 2
@@ -1936,6 +1948,7 @@ build_and_install() {
run_script ./netdata-installer.sh ${opts}
case $? in
+ 0) ;;
1)
if [ -n "${EXIT_REASON}" ]; then
fatal "netdata-installer.sh failed to run: ${EXIT_REASON}" "${EXIT_CODE}"
@@ -1944,6 +1957,7 @@ build_and_install() {
fi
;;
2) fatal "Insufficient RAM to install netdata." F0008 ;;
+ *) fatal "netdata-installer.sh failed to run: Encountered an unhandled error in the installer code." F051A ;;
esac
}
@@ -1963,14 +1977,14 @@ try_build_install() {
set_source_archive_urls "${SELECTED_RELEASE_CHANNEL}"
if [ -n "${INSTALL_VERSION}" ]; then
- if ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz"; then
+ if ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "./netdata-v${INSTALL_VERSION}.tar.gz"; then
fatal "Failed to download source tarball for local build. ${BADNET_MSG}." F000B
fi
- elif ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-latest.tar.gz"; then
+ elif ! download "${NETDATA_SOURCE_ARCHIVE_URL}" "./netdata-latest.tar.gz"; then
fatal "Failed to download source tarball for local build. ${BADNET_MSG}." F000B
fi
- if ! download "${NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then
+ if ! download "${NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL}" "./sha256sum.txt"; then
fatal "Failed to download checksums for source tarball verification. ${BADNET_MSG}." F000C
fi
@@ -1979,18 +1993,19 @@ try_build_install() {
else
if [ -z "${INSTALL_VERSION}" ]; then
# shellcheck disable=SC2086
- if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
- fatal "Tarball checksum validation failed. ${BADCACHE_MSG}." F0005
+ if ! grep netdata-latest.tar.gz "./sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then
+ bad_sums_report="$(report_bad_sha256sum netdata-latest.tar.gz "./sha256sum.txt")"
+ fatal "Tarball checksum validation failed.\n${bad_sums_report}\n${BADCACHE_MSG}." F0005
fi
fi
fi
if [ -n "${INSTALL_VERSION}" ]; then
- run tar -xf "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz" -C "${tmpdir}"
- rm -rf "${tmpdir}/netdata-v${INSTALL_VERSION}.tar.gz" > /dev/null 2>&1
+ run tar -xf "./netdata-v${INSTALL_VERSION}.tar.gz" -C "${tmpdir}"
+ rm -rf "./netdata-v${INSTALL_VERSION}.tar.gz" > /dev/null 2>&1
else
- run tar -xf "${tmpdir}/netdata-latest.tar.gz" -C "${tmpdir}"
- rm -rf "${tmpdir}/netdata-latest.tar.gz" > /dev/null 2>&1
+ run tar -xf "./netdata-latest.tar.gz" -C "${tmpdir}"
+ rm -rf "./netdata-latest.tar.gz" > /dev/null 2>&1
fi
if [ "${DRY_RUN}" -ne 1 ]; then
@@ -2073,8 +2088,16 @@ prepare_offline_install_source() {
if [ "${DRY_RUN}" -ne 1 ]; then
progress "Verifying checksums."
- if ! grep -e "$(find . -name '*.gz.run')" sha256sums.txt | safe_sha256sum -c -; then
- fatal "Checksums for offline install files are incorrect. ${BADCACHE_MSG}." F0507
+
+ failed_files=""
+ for file in $(find . -name '*.gz.run'); do
+ if ! grep -e "${file}" sha256sums.txt | safe_sha256sum -c -; then
+ failed_files="${failed_files}\n${file}\n$(report_bad_sha256sums "${file}" sha256sums.txt)"
+ fi
+ done
+
+ if [ -n "${failed_files}" ]; then
+ fatal "Checksums for offline install files are incorrect.\n${failed_files}\n${BADCACHE_MSG}." F0507
fi
else
progress "Would verify SHA256 checksums of downloaded installation files."