From 295d407fb01339a7eb38b5ffa9ccf85d8d57d10c Mon Sep 17 00:00:00 2001 From: "Austin S. Hemmelgarn" Date: Mon, 24 May 2021 07:34:09 -0400 Subject: Store info about the installation type for later retrieval. (#11157) * Store info about the installation type for later retrieval. * Properly handle install type on updates. * Restructure install type values for easier parsing. * Fix checksums. * Fix .gitignore check. --- netdata-installer.sh | 2 +- packaging/docker/Dockerfile | 1 + packaging/installer/kickstart-static64.sh | 12 ++++++++++++ packaging/installer/kickstart.sh | 1 + packaging/installer/methods/kickstart-64.md | 2 +- packaging/installer/methods/kickstart.md | 2 +- packaging/installer/netdata-updater.sh | 20 +++++++++++++++++++- packaging/makeself/jobs/70-netdata-git.install.sh | 6 ++++++ system/.install-type | 1 + system/Makefile.am | 4 ++++ 10 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 system/.install-type diff --git a/netdata-installer.sh b/netdata-installer.sh index ea4aadb04d..c02be5203c 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -1110,7 +1110,7 @@ run $make install || exit 1 # ----------------------------------------------------------------------------- progress "Fix generated files permissions" -run find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -a \! -name \*.timer -a \! -name \*.logrotate -exec chmod 755 {} \; +run find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -a \! -name \*.timer -a \! -name \*.logrotate -a \! -name \.install-type -exec chmod 755 {} \; # ----------------------------------------------------------------------------- progress "Creating standard user and groups for netdata" diff --git a/packaging/docker/Dockerfile b/packaging/docker/Dockerfile index d91d1a7739..bee3c70942 100644 --- a/packaging/docker/Dockerfile +++ b/packaging/docker/Dockerfile @@ -25,6 +25,7 @@ WORKDIR /opt/netdata.git # Install from source RUN chmod +x netdata-installer.sh && \ cp -rp /deps/* /usr/local/ && \ + /bin/echo -e "INSTALL_TYPE='oci'\nPREBUILT_ARCH='$(uname -m)'" > ./system/.install-type && \ ./netdata-installer.sh --dont-wait --dont-start-it ${EXTRA_INSTALL_OPTS} \ "$([ "$RELEASE_CHANNEL" = stable ] && echo --stable-channel)" diff --git a/packaging/installer/kickstart-static64.sh b/packaging/installer/kickstart-static64.sh index 36aca54d7a..f29e3b094a 100755 --- a/packaging/installer/kickstart-static64.sh +++ b/packaging/installer/kickstart-static64.sh @@ -206,6 +206,16 @@ safe_sha256sum() { fi } +mark_install_type() { + install_type_file="/opt/netdata/etc/netdata/.install-type" + # shellcheck disable=SC1090 + . "${install_type_file}" + cat > "${install_type_file}" <<-EOF + INSTALL_TYPE='kickstart-static' + PREBUILT_ARCH='${PREBUILT_ARCH}' + EOF +} + # ---------------------------------------------------------------------------- umask 022 @@ -386,6 +396,8 @@ fi progress "Installing netdata" run ${sudo} sh "${TMPDIR}/netdata-latest.gz.run" ${opts} -- ${NETDATA_UPDATES} ${NETDATA_INSTALLER_OPTIONS} +mark_install_type + #shellcheck disable=SC2181 if [ $? -eq 0 ]; then run ${sudo} rm "${TMPDIR}/netdata-latest.gz.run" diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh index 3c90cc8169..8f84a38e12 100755 --- a/packaging/installer/kickstart.sh +++ b/packaging/installer/kickstart.sh @@ -519,6 +519,7 @@ install() { } if [ -x netdata-installer.sh ]; then + echo "INSTALL_TYPE='kickstart-build'" > system/.install-type install "$@" else if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ] && [ -x "$(find . -mindepth 1 -maxdepth 1 -type d)/netdata-installer.sh" ]; then diff --git a/packaging/installer/methods/kickstart-64.md b/packaging/installer/methods/kickstart-64.md index c390b873a2..6ff74203dc 100644 --- a/packaging/installer/methods/kickstart-64.md +++ b/packaging/installer/methods/kickstart-64.md @@ -97,7 +97,7 @@ To use `md5sum` to verify the integrity of the `kickstart-static64.sh` script yo command above, run the following: ```bash -[ "c735fd724be5726c8a1850deed2793b8" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" +[ "d80cb6e7b48f2825aade13120ec5364d" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" ``` If the script is valid, this command will return `OK, VALID`. diff --git a/packaging/installer/methods/kickstart.md b/packaging/installer/methods/kickstart.md index e874d637df..a5df54576f 100644 --- a/packaging/installer/methods/kickstart.md +++ b/packaging/installer/methods/kickstart.md @@ -80,7 +80,7 @@ To use `md5sum` to verify the integrity of the `kickstart.sh` script you will do run the following: ```bash -[ "a708de3790fa39188babe71eb1639c66" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" +[ "271aef84d0bbdabb337571a3963549c7" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" ``` If the script is valid, this command will return `OK, VALID`. diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index ad74122553..f4eff34986 100755 --- a/packaging/installer/netdata-updater.sh +++ b/packaging/installer/netdata-updater.sh @@ -12,7 +12,8 @@ # - NETDATA_TARBALL_URL # - NETDATA_TARBALL_CHECKSUM_URL # - NETDATA_TARBALL_CHECKSUM -# - NETDATA_PREFIX / NETDATA_LIB_DIR (After 1.16.1 we will only depend on lib dir) +# - NETDATA_PREFIX +# - NETDATA_LIB_DIR # # Optional environment options: # @@ -326,6 +327,12 @@ update() { fi fi + if [ -e "${NETDATA_PREFIX}/etc/netdata/.install-type" ] ; then + install_type="$(cat /opt/netdata/etc/netdata/.install-type)" + else + install_type="INSTALL_TYPE='legacy-build'" + fi + info "Re-installing netdata..." eval "${env} ./netdata-installer.sh ${REINSTALL_OPTIONS} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA" @@ -334,6 +341,8 @@ update() { info "Updating tarball checksum info" echo "${NEW_CHECKSUM}" > "${NETDATA_LIB_DIR}/netdata.tarball.checksum" + + echo "${install_type}" > "${NETDATA_PREFIX}/etc/netdata/.install-type" fi rm -rf "${ndtmpdir}" >&3 2>&3 @@ -415,6 +424,12 @@ if [ "${IS_NETDATA_STATIC_BINARY}" == "yes" ]; then fatal "Static binary checksum validation failed. Stopping netdata installation and leaving binary in ${ndtmpdir}\nUsually this is a result of an older copy of the file being cached somewhere and can be resolved by simply retrying in an hour." fi + if [ -e /opt/netdata/etc/netdata/.install-type ] ; then + install_type="$(cat /opt/netdata/etc/netdata/.install-type)" + else + install_type="INSTALL_TYPE='legacy-static'" + fi + # Do not pass any options other than the accept, for now # shellcheck disable=SC2086 if sh "${ndtmpdir}/netdata-latest.gz.run" --accept -- ${REINSTALL_OPTIONS}; then @@ -422,6 +437,9 @@ if [ "${IS_NETDATA_STATIC_BINARY}" == "yes" ]; then else echo >&2 "NOTE: did not remove: ${ndtmpdir}" fi + + echo "${install_type}" > /opt/netdata/etc/netdata/.install-type + echo >&2 "Switching back to ${PREVDIR}" cd "${PREVDIR}" || exit 1 else diff --git a/packaging/makeself/jobs/70-netdata-git.install.sh b/packaging/makeself/jobs/70-netdata-git.install.sh index 21d4fd0ac3..11608a4e4d 100755 --- a/packaging/makeself/jobs/70-netdata-git.install.sh +++ b/packaging/makeself/jobs/70-netdata-git.install.sh @@ -33,6 +33,12 @@ run ./netdata-installer.sh \ --require-cloud \ --dont-scrub-cflags-even-though-it-may-break-things +# Properly mark the install type +cat > "${NETDATA_INSTALL_PATH}/etc/netdata/.install-type" <<-EOF + INSTALL_TYPE='manual-static' + PREBUILT_ARCH='$(uname -m)' + EOF + # Remove the netdata.conf file from the tree. It has hard-coded sensible defaults builtin. run rm -f "${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf" diff --git a/system/.install-type b/system/.install-type new file mode 100644 index 0000000000..ebac7be598 --- /dev/null +++ b/system/.install-type @@ -0,0 +1 @@ +INSTALL_TYPE='custom' diff --git a/system/Makefile.am b/system/Makefile.am index 5323738c95..a88ccab654 100644 --- a/system/Makefile.am +++ b/system/Makefile.am @@ -23,6 +23,10 @@ dist_config_SCRIPTS = \ edit-config \ $(NULL) +dist_config_DATA = \ + .install-type \ + $(NULL) + # Explicitly install directories to avoid permission issues due to umask install-exec-local: $(INSTALL) -d $(DESTDIR)$(configdir) -- cgit v1.2.3