Add support for libmosquitto to netdata-installer.sh for ACLK support. (#8025)
* Add initial libmosquitto install support. THis adds initial support for pulling in our custom version of libmosquitto during the install process and using it with Netdata. This can be manually disabled by specifying `--disable-libmosquitto` on the install command-line. * Extract the libmosquitto sources in the right place. * Fix error message to be more generic. * Fix handling of temporary directory. * Only pull in required headers. * Correct new help text. * Change option naming to disable ACLK. * Use correct name for configure option. * Adjust target directory for libs. * Properly include OpenSSL on macOS. * Change references to ACLK to Netdata Cloud. * Update version of libmosquitto being used.
Austin S. Hemmelgarn committed
Feb 11, 2020 at 16:30 UTC
e96c1229581fc92a5c65d5e865fed9926b6466a7
3 files changed
+79
-3
netdata-installer.sh
+77
-3
@@ -25,6 +25,12 @@ if [ "${NETDATA_SOURCE_DIR}" != "${INSTALLER_DIR}" ] && [ "${INSTALLER_DIR}" !=
25
echo >&2 "Warning: you are currently in '${NETDATA_SOURCE_DIR}' but the installer is in '${INSTALLER_DIR}'."
26
fi
27
28
+# -----------------------------------------------------------------------------
29
+# Pull in OpenSSL properly if on macOS
30
+if [ "$(uname -s)" = 'Darwin' ] && [ -d /usr/local/opt/openssl/include ] ; then
31
+ export C_INCLUDE_PATH="/usr/local/opt/openssl/include"
32
+fi
33
+
34
# -----------------------------------------------------------------------------
35
# reload the user profile
36
@@ -45,9 +51,11 @@ else
51
source "${NETDATA_SOURCE_DIR}/packaging/installer/functions.sh" || exit 1
52
fi
53
48
-download_go() {
54
+download_tarball() {
55
url="${1}"
56
dest="${2}"
57
+ name="${3}"
58
+ opt="${4}"
59
60
if command -v curl > /dev/null 2>&1; then
61
run curl -sSL --connect-timeout 10 --retry 3 "${url}" > "${dest}"
@@ -55,14 +63,18 @@ download_go() {
63
run wget -T 15 -O - "${url}" > "${dest}"
64
else
65
echo >&2
58
- echo >&2 "Downloading go.d plugin from '${url}' failed because of missing mandatory packages."
59
- echo >&2 "Either add packages or disable it by issuing '--disable-go' in the installer"
66
+ echo >&2 "Downloading ${name} from '${url}' failed because of missing mandatory packages."
67
+ echo >&2 "Either add packages or disable it by issuing '--disable-${opt}' in the installer"
68
echo >&2
69
70
run_failed "I need curl or wget to proceed, but neither is available on this system."
71
fi
72
}
73
74
+download_go() {
75
+ download_tarball "${1}" "${2}" "go.d plugin" "go"
76
+}
77
+
78
# make sure we save all commands we run
79
run_logfile="netdata-installer.log"
80
@@ -157,6 +169,7 @@ USAGE: ${PROGRAM} [options]
169
--nightly-channel Use most recent nightly udpates instead of GitHub releases.
170
This results in more frequent updates.
171
--disable-go Disable installation of go.d.plugin.
172
+ --disable-cloud Disable the agent-cloud link, required for Netdata Cloud functionality.
173
--enable-plugin-freeipmi Enable the FreeIPMI plugin. Default: enable it when libipmimonitoring is available.
174
--disable-plugin-freeipmi
175
--disable-https Explicitly disable TLS support
@@ -241,6 +254,7 @@ while [ -n "${1}" ]; do
254
"--disable-x86-sse") NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-x86-sse/} --disable-x86-sse" ;;
255
"--disable-telemetry") NETDATA_DISABLE_TELEMETRY=1 ;;
256
"--disable-go") NETDATA_DISABLE_GO=1 ;;
257
+ "--disable-cloud") NETDATA_DISABLE_LIBMOSQUITTO=1 ; NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-aclk/} --disable-aclk" ;;
258
"--install")
259
NETDATA_PREFIX="${2}/netdata"
260
shift 1
@@ -413,6 +427,66 @@ fi
427
428
trap build_error EXIT
429
430
+# -----------------------------------------------------------------------------
431
+
432
+fetch_libmosquitto() {
433
+ download_tarball "${1}" "${2}" "libmosquitto" "cloud"
434
+}
435
+
436
+build_libmosquitto() {
437
+ run make -C "${1}/lib"
438
+}
439
+
440
+copy_libmosquitto() {
441
+ target_dir="${PWD}/externaldeps/mosquitto"
442
+
443
+ run mkdir -p "${target_dir}"
444
+
445
+ run cp "${1}/lib/libmosquitto.a" "${target_dir}"
446
+ run cp "${1}/lib/mosquitto.h" "${target_dir}"
447
+}
448
+
449
+bundle_libmosquitto() {
450
+ if [ -n "${NETDATA_DISABLE_LIBMOSQUITTO}" ] ; then
451
+ return 0
452
+ fi
453
+
454
+ progress "Prepare custom libmosquitto version"
455
+
456
+ MOSQUITTO_PACKAGE_VERSION="$(cat packaging/mosquitto.version)"
457
+
458
+ tmp=$(mktemp -d netdata-mosquitto-XXXXXX)
459
+ MOSQUITTO_PACKAGE_BASENAME="${MOSQUITTO_PACKAGE_VERSION}.tar.gz"
460
+
461
+ if [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE_MOSQUITTO}" ]; then
462
+ fetch_libmosquitto "https://github.com/netdata/mosquitto/archive/${MOSQUITTO_PACKAGE_BASENAME}" "${tmp}/${MOSQUITTO_PACKAGE_BASENAME}"
463
+ else
464
+ progress "Using provided mosquitto tarball ${NETDATA_LOCAL_TARBALL_OVERRIDE_MOSQUITTO}"
465
+ run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_MOSQUITTO}" "${tmp}/${MOSQUITTO_PACKAGE_BASENAME}"
466
+ fi
467
+
468
+ if [ ! -f "${tmp}/${MOSQUITTO_PACKAGE_BASENAME}" ] || [ ! -s "${tmp}/${MOSQUITTO_PACKAGE_BASENAME}" ]; then
469
+ run_failed "unable to find a usable libmosquitto source archive, Netdata Cloud will not be available"
470
+ return 0
471
+ fi
472
+
473
+ grep "${MOSQUITTO_PACKAGE_BASENAME}\$" "${INSTALLER_DIR}/packaging/go.d.checksums" >"${tmp}/sha256sums.txt" 2>/dev/null
474
+
475
+ cp packaging/mosquitto.checksums "${tmp}/sha256sums.txt"
476
+
477
+ # Checksum validation
478
+ if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
479
+ run_failed "mosquitto files checksum validation failed."
480
+ return 0
481
+ fi
482
+
483
+ run tar -xf "${tmp}/${MOSQUITTO_PACKAGE_BASENAME}" -C "${tmp}"
484
+
485
+ build_libmosquitto "${tmp}/mosquitto-${MOSQUITTO_PACKAGE_VERSION}" && copy_libmosquitto "${tmp}/mosquitto-${MOSQUITTO_PACKAGE_VERSION}" && rm "${tmp}"
486
+}
487
+
488
+bundle_libmosquitto
489
+
490
# -----------------------------------------------------------------------------
491
echo >&2
492
progress "Run autotools to configure the build environment"
packaging/mosquitto.checksums
new
+1
@@ -0,0 +1 @@
1
+1bcf9caaaf28fcc3ede4bccca32c74db5d37139a1f1ba4c6cf1811722fde203b v.1.6.8_Netdata-2.tar.gz
packaging/mosquitto.version
new
+1
@@ -0,0 +1 @@
1
+v.1.6.8_Netdata-2