@cryptotaxi247 / netdata-1 / commits / 295d407fb

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.

Austin S. Hemmelgarn committed May 24, 2021 at 07:34 UTC 295d407fb01339a7eb38b5ffa9ccf85d8d57d10c
10 files changed +47 -4
netdata-installer.sh
+1 -1
@@ -1110,7 +1110,7 @@ run $make install || exit 1
1110 # -----------------------------------------------------------------------------
1111 progress "Fix generated files permissions"
1112
1113 -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 {} \;
1113 +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 {} \;
1114
1115 # -----------------------------------------------------------------------------
1116 progress "Creating standard user and groups for netdata"
packaging/docker/Dockerfile
+1
@@ -25,6 +25,7 @@ WORKDIR /opt/netdata.git
25 # Install from source
26 RUN chmod +x netdata-installer.sh && \
27 cp -rp /deps/* /usr/local/ && \
28 + /bin/echo -e "INSTALL_TYPE='oci'\nPREBUILT_ARCH='$(uname -m)'" > ./system/.install-type && \
29 ./netdata-installer.sh --dont-wait --dont-start-it ${EXTRA_INSTALL_OPTS} \
30 "$([ "$RELEASE_CHANNEL" = stable ] && echo --stable-channel)"
31
packaging/installer/kickstart-static64.sh
+12
@@ -206,6 +206,16 @@ safe_sha256sum() {
206 fi
207 }
208
209 +mark_install_type() {
210 + install_type_file="/opt/netdata/etc/netdata/.install-type"
211 + # shellcheck disable=SC1090
212 + . "${install_type_file}"
213 + cat > "${install_type_file}" <<-EOF
214 + INSTALL_TYPE='kickstart-static'
215 + PREBUILT_ARCH='${PREBUILT_ARCH}'
216 + EOF
217 +}
218 +
219 # ----------------------------------------------------------------------------
220 umask 022
221
@@ -386,6 +396,8 @@ fi
396 progress "Installing netdata"
397 run ${sudo} sh "${TMPDIR}/netdata-latest.gz.run" ${opts} -- ${NETDATA_UPDATES} ${NETDATA_INSTALLER_OPTIONS}
398
399 +mark_install_type
400 +
401 #shellcheck disable=SC2181
402 if [ $? -eq 0 ]; then
403 run ${sudo} rm "${TMPDIR}/netdata-latest.gz.run"
packaging/installer/kickstart.sh
+1
@@ -519,6 +519,7 @@ install() {
519 }
520
521 if [ -x netdata-installer.sh ]; then
522 + echo "INSTALL_TYPE='kickstart-build'" > system/.install-type
523 install "$@"
524 else
525 if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ] && [ -x "$(find . -mindepth 1 -maxdepth 1 -type d)/netdata-installer.sh" ]; then
packaging/installer/methods/kickstart-64.md
+1 -1
@@ -97,7 +97,7 @@ To use `md5sum` to verify the integrity of the `kickstart-static64.sh` script yo
97 command above, run the following:
98
99 ```bash
100 -[ "c735fd724be5726c8a1850deed2793b8" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
100 +[ "d80cb6e7b48f2825aade13120ec5364d" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
101 ```
102
103 If the script is valid, this command will return `OK, VALID`.
packaging/installer/methods/kickstart.md
+1 -1
@@ -80,7 +80,7 @@ To use `md5sum` to verify the integrity of the `kickstart.sh` script you will do
80 run the following:
81
82 ```bash
83 -[ "a708de3790fa39188babe71eb1639c66" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
83 +[ "271aef84d0bbdabb337571a3963549c7" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
84 ```
85
86 If the script is valid, this command will return `OK, VALID`.
packaging/installer/netdata-updater.sh
+19 -1
@@ -12,7 +12,8 @@
12 # - NETDATA_TARBALL_URL
13 # - NETDATA_TARBALL_CHECKSUM_URL
14 # - NETDATA_TARBALL_CHECKSUM
15 -# - NETDATA_PREFIX / NETDATA_LIB_DIR (After 1.16.1 we will only depend on lib dir)
15 +# - NETDATA_PREFIX
16 +# - NETDATA_LIB_DIR
17 #
18 # Optional environment options:
19 #
@@ -326,6 +327,12 @@ update() {
327 fi
328 fi
329
330 + if [ -e "${NETDATA_PREFIX}/etc/netdata/.install-type" ] ; then
331 + install_type="$(cat /opt/netdata/etc/netdata/.install-type)"
332 + else
333 + install_type="INSTALL_TYPE='legacy-build'"
334 + fi
335 +
336 info "Re-installing netdata..."
337 eval "${env} ./netdata-installer.sh ${REINSTALL_OPTIONS} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA"
338
@@ -334,6 +341,8 @@ update() {
341
342 info "Updating tarball checksum info"
343 echo "${NEW_CHECKSUM}" > "${NETDATA_LIB_DIR}/netdata.tarball.checksum"
344 +
345 + echo "${install_type}" > "${NETDATA_PREFIX}/etc/netdata/.install-type"
346 fi
347
348 rm -rf "${ndtmpdir}" >&3 2>&3
@@ -415,6 +424,12 @@ if [ "${IS_NETDATA_STATIC_BINARY}" == "yes" ]; then
424 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."
425 fi
426
427 + if [ -e /opt/netdata/etc/netdata/.install-type ] ; then
428 + install_type="$(cat /opt/netdata/etc/netdata/.install-type)"
429 + else
430 + install_type="INSTALL_TYPE='legacy-static'"
431 + fi
432 +
433 # Do not pass any options other than the accept, for now
434 # shellcheck disable=SC2086
435 if sh "${ndtmpdir}/netdata-latest.gz.run" --accept -- ${REINSTALL_OPTIONS}; then
@@ -422,6 +437,9 @@ if [ "${IS_NETDATA_STATIC_BINARY}" == "yes" ]; then
437 else
438 echo >&2 "NOTE: did not remove: ${ndtmpdir}"
439 fi
440 +
441 + echo "${install_type}" > /opt/netdata/etc/netdata/.install-type
442 +
443 echo >&2 "Switching back to ${PREVDIR}"
444 cd "${PREVDIR}" || exit 1
445 else
packaging/makeself/jobs/70-netdata-git.install.sh
+6
@@ -33,6 +33,12 @@ run ./netdata-installer.sh \
33 --require-cloud \
34 --dont-scrub-cflags-even-though-it-may-break-things
35
36 +# Properly mark the install type
37 +cat > "${NETDATA_INSTALL_PATH}/etc/netdata/.install-type" <<-EOF
38 + INSTALL_TYPE='manual-static'
39 + PREBUILT_ARCH='$(uname -m)'
40 + EOF
41 +
42 # Remove the netdata.conf file from the tree. It has hard-coded sensible defaults builtin.
43 run rm -f "${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
44
system/.install-type new
+1
@@ -0,0 +1 @@
1 +INSTALL_TYPE='custom'
system/Makefile.am
+4
@@ -23,6 +23,10 @@ dist_config_SCRIPTS = \
23 edit-config \
24 $(NULL)
25
26 +dist_config_DATA = \
27 + .install-type \
28 + $(NULL)
29 +
30 # Explicitly install directories to avoid permission issues due to umask
31 install-exec-local:
32 $(INSTALL) -d $(DESTDIR)$(configdir)