@cryptotaxi247 / netdata-1 / commits / e3babcb33

netdata/packaging: Adopt netdata-updater to run properly for static64 installations. (#6520)

* netdata/packaging: Start support for netdata-updater compatibility on static installation 1) Make netdata-installer.sh accept --static option, that simply passes variable IS_NETDATA_STATIC_BINARY=yes to the environment 2) Adjust the updater to check that variable and then is set to yes, make it download the static binary and run the static binary In theory, this should give us the required info on the updater. Only thing missing is how to catch the extra arguments the user might have given on the initial install. Will rework this after i test this first draft change * netdata/packaging: dont forget to enter the temp dir and also return to the original one afterwards. Print some info too. * netdata/packaging: reduce complexity on parameters for installer. Rather expect the variable to be set by the caller. this way we wont let the users get confused by the existence of a flag that only has internal usage. * netdata/packaging: dont forget to clean up the whole folder, its a temp

Paul Emm. Katsoulakis committed Jul 27, 2019 at 00:50 UTC e3babcb33931b2a5b99d14d950108e9ffea0a403
3 files changed +43 -5
netdata-installer.sh
+2
@@ -199,6 +199,7 @@ NETDATA_PREFIX=
199 LIBS_ARE_HERE=0
200 NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS-}"
201 RELEASE_CHANNEL="nightly"
202 +IS_NETDATA_STATIC_BINARY="${IS_NETDATA_STATIC_BINARY:-"no"}"
203 while [ -n "${1}" ]; do
204 case "${1}" in
205 "--zlib-is-really-here") LIBS_ARE_HERE=1;;
@@ -1073,6 +1074,7 @@ INSTALL_UID="${UID}"
1074 NETDATA_GROUP="${NETDATA_GROUP}"
1075 REINSTALL_COMMAND="${REINSTALL_COMMAND}"
1076 RELEASE_CHANNEL="${RELEASE_CHANNEL}"
1077 +IS_NETDATA_STATIC_BINARY="${IS_NETDATA_STATIC_BINARY}"
1078 # This value is meant to be populated by autoupdater (if enabled)
1079 NETDATA_TARBALL_CHECKSUM="new_installation"
1080 EOF
packaging/installer/netdata-updater.sh
+37 -5
@@ -73,21 +73,26 @@ download() {
73 }
74
75 set_tarball_urls() {
76 + local extension="tar.gz"
77
78 if [ ! -z "${NETDATA_LOCAL_TARBAL_OVERRIDE}" ]; then
79 info "Not fetching remote tarballs, local override was given"
80 return
81 fi
82
83 + if [ "$2" == "yes" ]; then
84 + extension="gz.run"
85 + fi
86 +
87 if [ "$1" = "stable" ]; then
88 local latest
89 # Simple version
90 # latest="$(curl -sSL https://api.github.com/repos/netdata/netdata/releases/latest | grep tag_name | cut -d'"' -f4)"
91 latest="$(download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4)"
87 - export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/netdata-$latest.tar.gz"
92 + export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/netdata-$latest.${extension}"
93 export NETDATA_TARBALL_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/$latest/sha256sums.txt"
94 else
90 - export NETDATA_TARBALL_URL="https://storage.googleapis.com/netdata-nightlies/netdata-latest.tar.gz"
95 + export NETDATA_TARBALL_URL="https://storage.googleapis.com/netdata-nightlies/netdata-latest.${extension}"
96 export NETDATA_TARBALL_CHECKSUM_URL="https://storage.googleapis.com/netdata-nightlies/sha256sums.txt"
97 fi
98 }
@@ -171,7 +176,34 @@ else
176 exec 3>"${logfile}"
177 fi
178
174 -set_tarball_urls "${RELEASE_CHANNEL}"
179 +set_tarball_urls "${RELEASE_CHANNEL}" "${IS_NETDATA_STATIC_BINARY}"
180 +
181 +if [ "${IS_NETDATA_STATIC_BINARY}" == "yes" ]; then
182 + TMPDIR="$(create_tmp_directory)"
183 + PREVDIR="$(pwd)"
184 +
185 + echo >&2 "Entering ${TMPDIR}"
186 + cd "${TMPDIR}"
187 +
188 + download "${NETDATA_TARBALL_CHECKSUM_URL}" "${TMPDIR}/sha256sum.txt"
189 + download "${NETDATA_TARBALL_URL}" "${TMPDIR}/netdata-latest.gz.run"
190 + if ! grep netdata-latest.gz.run "${TMPDIR}/sha256sum.txt" | safe_sha256sum -c - >/dev/null 2>&1; then
191 + fatal "Static binary checksum validation failed. Stopping netdata installation and leaving binary in ${TMPDIR}"
192 + fi
193 +
194 + # Do not pass any options other than the accept, for now
195 + sh "${TMPDIR}/netdata-latest.gz.run" --accept
196 +
197 + #shellcheck disable=SC2181
198 + if [ $? -eq 0 ]; then
199 + rm -r "${TMPDIR}"
200 + else
201 + echo >&2 "NOTE: did not remove: ${TMPDIR}"
202 + fi
203 + echo >&2 "Switching back to ${PREVDIR}"
204 + cd "${PREVDIR}"
205 +else
206 + # the installer updates this script - so we run and exit in a single line
207 + update && exit 0
208 +fi
209
176 -# the installer updates this script - so we run and exit in a single line
177 -update && exit 0
packaging/makeself/jobs/70-netdata-git.install.sh
+4
@@ -13,6 +13,10 @@ else
13 # export CFLAGS="-static -O1 -ggdb -Wall -Wextra -Wformat-signedness"
14 fi
15
16 +# We export this to 'yes', installer sets this to .environment.
17 +# The updater consumes this one, so that it can tell whether it should update a static install or a non-static one
18 +export IS_NETDATA_STATIC_BINARY="yes"
19 +
20 run ./netdata-installer.sh --install "${NETDATA_INSTALL_PARENT}" \
21 --dont-wait \
22 --dont-start-it \