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.
This commit is contained in:
Austin S. Hemmelgarn 2021-05-24 07:34:09 -04:00 committed by GitHub
parent 0cc48515b5
commit 295d407fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 4 deletions

View File

@ -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"

View File

@ -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)"

View File

@ -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"

View File

@ -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

View File

@ -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`.

View File

@ -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`.

View File

@ -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

View File

@ -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"

1
system/.install-type Normal file
View File

@ -0,0 +1 @@
INSTALL_TYPE='custom'

View File

@ -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)