@cryptotaxi247 / netdata-1 / commits / cc0de9f29

Make auto-updates work on kickstart-static64 installs. (#7704)

* Store only the options for reinstall, not the full command. This simplifies handling of updates with the static installer. * Properly utilize the updater for static installs. * Disable auto-updater when using local files. If using local files, we can probably assume a system without a network connection, so don't enable the auto-updater. * Document support for auto-updates from kickstart-static64 * Fix infinite loop in auto-update option. * Update kickstart-static64 checksum in docs. * Remove unnecessary `sed` argument. Co-Authored-By: Konstantinos Natsakis <5933427+knatsakis@users.noreply.github.com> Co-authored-by: Konstantinos Natsakis <5933427+knatsakis@users.noreply.github.com>

Austin S. Hemmelgarn committed Jan 14, 2020 at 07:45 UTC cc0de9f292c4bc1e91a8ec27114624c3b4e8becf
5 files changed +41 -17
netdata-installer.sh
+4 -8
@@ -93,16 +93,12 @@ printf 'LDFLAGS="%s" ' "${LDFLAGS}" >>netdata-installer.log
93 printf "%q " "${PROGRAM}" "${@}" >>netdata-installer.log
94 printf "\\n" >>netdata-installer.log
95
96 -REINSTALL_COMMAND="$(
97 - printf "%q " "${PROGRAM}" "${@}"
96 +REINSTALL_OPTIONS="$(
97 + printf "%s" "${*}"
98 printf "\\n"
99 )"
100 # remove options that shown not be inherited by netdata-updater.sh
101 -REINSTALL_COMMAND="${REINSTALL_COMMAND// --dont-wait/}"
102 -REINSTALL_COMMAND="${REINSTALL_COMMAND// --dont-start-it/}"
103 -if [ "${REINSTALL_COMMAND:0:1}" != "." ] && [ "${REINSTALL_COMMAND:0:1}" != "/" ] && [ -f "./${PROGRAM}" ]; then
104 - REINSTALL_COMMAND="./${REINSTALL_COMMAND}"
105 -fi
101 +REINSTALL_OPTIONS="$(echo "${REINSTALL_OPTIONS}" | sed 's/--dont-wait//g' | sed 's/--dont-start-it//g')"
102
103 banner_nonroot_install() {
104 cat <<NONROOTNOPREFIX
@@ -1099,7 +1095,7 @@ NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS}"
1095 NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS}"
1096 INSTALL_UID="${UID}"
1097 NETDATA_GROUP="${NETDATA_GROUP}"
1102 -REINSTALL_COMMAND="${REINSTALL_COMMAND}"
1098 +REINSTALL_OPTIONS="${REINSTALL_OPTIONS}"
1099 RELEASE_CHANNEL="${RELEASE_CHANNEL}"
1100 IS_NETDATA_STATIC_BINARY="${IS_NETDATA_STATIC_BINARY}"
1101 NETDATA_LIB_DIR="${NETDATA_LIB_DIR}"
packaging/installer/README.md
+2 -1
@@ -116,7 +116,7 @@ This script installs Netdata at `/opt/netdata`.
116 Verify the integrity of the script with this:
117
118 ```bash
119 -[ "23e0f38dfb9d517be16393c3ed1f88bd" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
119 +[ "9e0901736a8ed5ebcc84bc1c2c7b5db9" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
120 ```
121
122 *It should print `OK, VALID` if the script is the one we ship.*
@@ -153,6 +153,7 @@ sh /tmp/kickstart-static64.sh
153 - The static binary files are kept in repo [binary-packages](https://github.com/netdata/binary-packages). You can download any of the `.run` files, and run it. These files are self-extracting shell scripts built with [makeself](https://github.com/megastep/makeself).
154 - The target system does **not** need to have bash installed.
155 - The same files can be used for updates too.
156 +- If the `--local-files` option was not specified, installs `netdata-updater.sh` to `cron.daily`, so your Netdata installation will be updated daily (you will get a message from cron only if the update fails).
157 - For QA purposes, this installation method lets us know if it succeed or failed.
158
159 </details>
packaging/installer/kickstart-static64.sh
+4
@@ -197,6 +197,9 @@ while [ -n "${1}" ]; do
197 elif [ "${1}" = "--no-updates" ]; then
198 NETDATA_UPDATES=""
199 shift 1
200 + elif [ "${1}" = "--auto-update" ]; then
201 + true # This is the default behaviour, so ignore it.
202 + shift 1
203 elif [ "${1}" = "--stable-channel" ]; then
204 RELEASE_CHANNEL="stable"
205 NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:+${NETDATA_INSTALLER_OPTIONS} }${1}"
@@ -205,6 +208,7 @@ while [ -n "${1}" ]; do
208 NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:+${NETDATA_INSTALLER_OPTIONS} }${1}"
209 shift 1
210 elif [ "${1}" = "--local-files" ]; then
211 + NETDATA_UPDATES="" # Disable autoupdates if using pre-downloaded files.
212 shift 1
213 if [ -z "${1}" ]; then
214 fatal "Option --local-files requires extra information. The desired tarball full filename is needed"
packaging/installer/netdata-updater.sh
+5 -3
@@ -7,8 +7,9 @@
7 # - PATH
8 # - CFLAGS
9 # - LDFLAGS
10 +# - IS_NETDATA_STATIC_BINARY
11 # - NETDATA_CONFIGURE_OPTIONS
11 -# - REINSTALL_COMMAND
12 +# - REINSTALL_OPTIONS
13 # - NETDATA_TARBALL_URL
14 # - NETDATA_TARBALL_CHECKSUM_URL
15 # - NETDATA_TARBALL_CHECKSUM
@@ -141,8 +142,9 @@ update() {
142 do_not_start="--dont-start-it"
143 fi
144
145 + echo "${REINSTALL_OPTIONS}"
146 info "Re-installing netdata..."
145 - eval "${REINSTALL_COMMAND} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA"
147 + eval "./netdata-installer.sh ${REINSTALL_OPTIONS} --dont-wait ${do_not_start}" >&3 2>&3 || fatal "FAILED TO COMPILE/INSTALL NETDATA"
148
149 # We no longer store checksum info here. but leave this so that we clean up all environment files upon next update.
150 sed -i '/NETDATA_TARBALL/d' "${ENVIRONMENT_FILE}"
@@ -201,7 +203,7 @@ if [ "${IS_NETDATA_STATIC_BINARY}" == "yes" ]; then
203 fi
204
205 # Do not pass any options other than the accept, for now
204 - sh "${TMPDIR}/netdata-latest.gz.run" --accept
206 + sh "${TMPDIR}/netdata-latest.gz.run" --accept ${REINSTALL_OPTIONS}
207
208 #shellcheck disable=SC2181
209 if [ $? -eq 0 ]; then
packaging/makeself/install-or-update.sh
+26 -5
@@ -25,15 +25,31 @@ fi
25
26 STARTIT=1
27 AUTOUPDATE=0
28 +REINSTALL_OPTIONS=""
29 RELEASE_CHANNEL="nightly" # check .travis/create_artifacts.sh before modifying
30
31 while [ "${1}" ]; do
32 case "${1}" in
32 - "--dont-start-it") STARTIT=0;;
33 - "--auto-update"|"-u") AUTOUPDATE=1;;
34 - "--stable-channel") RELEASE_CHANNEL="stable";;
35 - "--nightly-channel") RELEASE_CHANNEL="nightly";;
36 - "--disable-telemetry") DISABLE_TELEMETRY=1;;
33 + "--dont-start-it")
34 + STARTIT=0
35 + REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
36 + ;;
37 + "--auto-update"|"-u")
38 + AUTOUPDATE=1
39 + REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
40 + ;;
41 + "--stable-channel")
42 + RELEASE_CHANNEL="stable"
43 + REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
44 + ;;
45 + "--nightly-channel")
46 + RELEASE_CHANNEL="nightly"
47 + REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
48 + ;;
49 + "--disable-telemetry")
50 + DISABLE_TELEMETRY=1
51 + REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}"
52 + ;;
53
54 *) echo >&2 "Unknown option '${1}'. Ignoring it.";;
55 esac
@@ -241,6 +257,11 @@ then
257 run chmod 4750 bin/fping
258 fi
259
260 +# -----------------------------------------------------------------------------
261 +
262 +echo "Save install options"
263 +grep -qv 'IS_NETDATA_STATIC_BINARY="yes"' "${NETDATA_PREFIX}/etc/netdata/.environment" || echo IS_NETDATA_STATIC_BINARY=\"yes\" >> "${NETDATA_PREFIX}/etc/netdata/.environment"
264 +sed -i "s/REINSTALL_OPTIONS=\".*\"/REINSTALL_OPTIONS=\"${REINSTALL_OPTIONS}\"/" "${NETDATA_PREFIX}/etc/netdata/.environment"
265
266 # -----------------------------------------------------------------------------
267 if [ ${STARTIT} -eq 0 ]; then