diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-12-01 06:15:11 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-12-01 06:15:11 +0000 |
commit | 483926a283e118590da3f9ecfa75a8a4d62143ce (patch) | |
tree | cb77052778df9a128a8cd3ff5bf7645322a13bc5 /packaging | |
parent | Releasing debian version 1.31.0-4. (diff) | |
download | netdata-483926a283e118590da3f9ecfa75a8a4d62143ce.tar.xz netdata-483926a283e118590da3f9ecfa75a8a4d62143ce.zip |
Merging upstream version 1.32.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging')
84 files changed, 2503 insertions, 490 deletions
diff --git a/packaging/Dockerfile.packager b/packaging/Dockerfile.packager deleted file mode 100644 index 4c90f14fd..000000000 --- a/packaging/Dockerfile.packager +++ /dev/null @@ -1,43 +0,0 @@ -ARG ARCH=amd64 -ARG DISTRO=debian -ARG TEST_BASE=debian -ARG DISTRO_VERSION=10 -ARG PKG_VERSION=0.1 - -FROM netdata/package-builders:${DISTRO}${DISTRO_VERSION} AS build - -ARG ARCH -ARG DISTRO -ARG DISTRO_VERSION -ARG PKG_VERSION - -ENV ARCH=$ARCH -ENV DISTRO=$DISTRO -ENV DISTRO_VERSION=$DISTRO_VERSION -ENV VERSION=$PKG_VERSION - -WORKDIR /netdata -COPY . . - -RUN /build.sh - -FROM ${TEST_BASE}:${DISTRO_VERSION} AS runtime - -ARG ARCH -ARG DISTRO -ARG DISTRO_VERSION -ARG PKG_VERSION - -ENV ARCH=$ARCH -ENV DISTRO=$DISTRO -ENV DISTRO_VERSION=$DISTRO_VERSION -ENV VERSION=$PKG_VERSION - -COPY ./packaging/scripts/install.sh /install.sh -COPY ./packaging/scripts/test.sh /test.sh - -COPY --from=build /netdata/artifacts /packages - -RUN /install.sh - -CMD ["/test.sh"] diff --git a/packaging/bundle-ebpf.sh b/packaging/bundle-ebpf.sh index c51162987..3204345b0 100755 --- a/packaging/bundle-ebpf.sh +++ b/packaging/bundle-ebpf.sh @@ -6,12 +6,14 @@ PLUGINDIR="${2}" EBPF_VERSION="$(cat "${SRCDIR}/packaging/ebpf.version")" EBPF_TARBALL="netdata-kernel-collector-glibc-${EBPF_VERSION}.tar.xz" -mkdir -p "${SRCDIR}/tmp/ebpf" -curl -sSL --connect-timeout 10 --retry 3 "https://github.com/netdata/kernel-collector/releases/download/${EBPF_VERSION}/${EBPF_TARBALL}" > "${EBPF_TARBALL}" || exit 1 -grep "${EBPF_TARBALL}" "${SRCDIR}/packaging/ebpf.checksums" | sha256sum -c - || exit 1 -tar -xaf "${EBPF_TARBALL}" -C "${SRCDIR}/tmp/ebpf" || exit 1 -if [ ! -d "${PLUGINDIR}/ebpf.d" ];then - mkdir "${PLUGINDIR}/ebpf.d" +if [ -x "${PLUGINDIR}/ebpf.plugin" ] ; then + mkdir -p "${SRCDIR}/tmp/ebpf" + curl -sSL --connect-timeout 10 --retry 3 "https://github.com/netdata/kernel-collector/releases/download/${EBPF_VERSION}/${EBPF_TARBALL}" > "${EBPF_TARBALL}" || exit 1 + grep "${EBPF_TARBALL}" "${SRCDIR}/packaging/ebpf.checksums" | sha256sum -c - || exit 1 + tar -xaf "${EBPF_TARBALL}" -C "${SRCDIR}/tmp/ebpf" || exit 1 + if [ ! -d "${PLUGINDIR}/ebpf.d" ];then + mkdir "${PLUGINDIR}/ebpf.d" + fi + # shellcheck disable=SC2046 + cp -a $(find "${SRCDIR}/tmp/ebpf" -mindepth 1 -maxdepth 1) "${PLUGINDIR}/ebpf.d" fi -# shellcheck disable=SC2046 -cp -a $(find "${SRCDIR}/tmp/ebpf" -mindepth 1 -maxdepth 1) "${PLUGINDIR}/ebpf.d" diff --git a/packaging/bundle-libbpf.sh b/packaging/bundle-libbpf.sh index 4c16dd123..3ca183b0f 100755 --- a/packaging/bundle-libbpf.sh +++ b/packaging/bundle-libbpf.sh @@ -1,7 +1,4 @@ -#!/bin/sh - -LIBBPF_TARBALL="v$(cat "${1}/packaging/libbpf.version").tar.gz" -LIBBPF_BUILD_PATH="${1}/externaldeps/libbpf/libbpf-$(cat "${1}/packaging/libbpf.version")" +#!/bin/bash if [ "$(uname -m)" = x86_64 ]; then lib_subdir="lib64" @@ -9,6 +6,17 @@ else lib_subdir="lib" fi +if [ "${2}" != "centos7" ]; then + cp "${1}/packaging/current_libbpf.checksums" "${1}/packaging/libbpf.checksums" + cp "${1}/packaging/current_libbpf.version" "${1}/packaging/libbpf.version" +else + cp "${1}/packaging/libbpf_0_0_9.checksums" "${1}/packaging/libbpf.checksums" + cp "${1}/packaging/libbpf_0_0_9.version" "${1}/packaging/libbpf.version" +fi + +LIBBPF_TARBALL="v$(cat "${1}/packaging/libbpf.version").tar.gz" +LIBBPF_BUILD_PATH="${1}/externaldeps/libbpf/libbpf-$(cat "${1}/packaging/libbpf.version")" + mkdir -p "${1}/externaldeps/libbpf" || exit 1 curl -sSL --connect-timeout 10 --retry 3 "https://github.com/netdata/libbpf/archive/${LIBBPF_TARBALL}" > "${LIBBPF_TARBALL}" || exit 1 sha256sum -c "${1}/packaging/libbpf.checksums" || exit 1 diff --git a/packaging/bundle-lws.sh b/packaging/bundle-lws.sh index 4ecf0ca92..c4ffc7780 100755 --- a/packaging/bundle-lws.sh +++ b/packaging/bundle-lws.sh @@ -10,7 +10,7 @@ curl -sSL --connect-timeout 10 --retry 3 "https://github.com/warmcat/libwebsocke sha256sum -c "${1}/packaging/libwebsockets.checksums" || exit 1 tar -xzf "${LWS_TARBALL}" -C "${1}/externaldeps/libwebsockets" || exit 1 cd "${LWS_BUILD_PATH}" || exit 1 -cmake -D LWS_WITH_SOCKS5:boolean=YES . || exit 1 +cmake -Wno-dev -Wno-deprecated -D LWS_WITH_SOCKS5:boolean=YES -D WITHOUT_LWS_TESTAPPS:boolean=YES . || exit 1 make || exit 1 cd "${startdir}" || exit 1 cp -a "${LWS_BUILD_PATH}/lib/libwebsockets.a" "${1}/externaldeps/libwebsockets" || exit 1 diff --git a/packaging/current_libbpf.checksums b/packaging/current_libbpf.checksums new file mode 100644 index 000000000..eccbfa9f3 --- /dev/null +++ b/packaging/current_libbpf.checksums @@ -0,0 +1 @@ +47acbdf7836048fad3a585c6ab43cc08d1b70c27ce0a816e9ca92b927555530f v0.5.1_netdata.tar.gz diff --git a/packaging/current_libbpf.version b/packaging/current_libbpf.version new file mode 100644 index 000000000..74ca5f708 --- /dev/null +++ b/packaging/current_libbpf.version @@ -0,0 +1 @@ +0.5.1_netdata diff --git a/packaging/docker/Dockerfile b/packaging/docker/Dockerfile index d91d1a773..d99d393ae 100644 --- a/packaging/docker/Dockerfile +++ b/packaging/docker/Dockerfile @@ -25,7 +25,8 @@ WORKDIR /opt/netdata.git # Install from source RUN chmod +x netdata-installer.sh && \ cp -rp /deps/* /usr/local/ && \ - ./netdata-installer.sh --dont-wait --dont-start-it ${EXTRA_INSTALL_OPTS} \ + /bin/echo -e "INSTALL_TYPE='oci'\nPREBUILT_ARCH='$(uname -m)'" > ./system/.install-type && \ + ./netdata-installer.sh --dont-wait --dont-start-it --use-system-protobuf ${EXTRA_INSTALL_OPTS} \ "$([ "$RELEASE_CHANNEL" = stable ] && echo --stable-channel)" # files to one directory @@ -56,6 +57,9 @@ RUN mkdir -p /app/usr/sbin/ \ # hadolint ignore=DL3007 FROM netdata/base:latest as base +ARG OFFICIAL_IMAGE=false +ENV NETDATA_OFFICIAL_IMAGE=$OFFICIAL_IMAGE + # Configure system ARG NETDATA_UID=201 ARG NETDATA_GID=201 @@ -98,8 +102,10 @@ RUN chown -R root:root \ chmod 0755 /usr/libexec/netdata/plugins.d/*.plugin && \ chmod 4755 \ /usr/libexec/netdata/plugins.d/cgroup-network \ - /usr/libexec/netdata/plugins.d/apps.plugin \ - /usr/libexec/netdata/plugins.d/freeipmi.plugin && \ + /usr/libexec/netdata/plugins.d/apps.plugin && \ + if [ -f /usr/libexec/netdata/plugins.d/freeipmi.plugin ]; then \ + chmod 4755 /usr/libexec/netdata/plugins.d/freeipmi.plugin; \ + fi && \ # Group write permissions due to: https://github.com/netdata/netdata/pull/6543 find /var/lib/netdata /var/cache/netdata -type d -exec chmod 0770 {} \; && \ find /var/lib/netdata /var/cache/netdata -type f -exec chmod 0660 {} \; && \ @@ -112,3 +118,5 @@ EXPOSE $NETDATA_LISTENER_PORT ENTRYPOINT ["/usr/sbin/run.sh"] HEALTHCHECK --interval=60s --timeout=10s --retries=3 CMD /usr/sbin/health.sh + +ONBUILD ENV NETDATA_OFFICIAL_IMAGE=false diff --git a/packaging/docker/README.md b/packaging/docker/README.md index ed136cfa9..0a4804ae9 100644 --- a/packaging/docker/README.md +++ b/packaging/docker/README.md @@ -32,6 +32,9 @@ directive, not a COMMAND directive. Please adapt your execution scripts accordin ENTRYPOINT vs COMMAND in the [Docker documentation](https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact). +Our POWER8+ Docker images do not support our FreeIPMI collector. This is a technical limitation in FreeIPMI itself, +and unfortunately not something we can realistically work around. + ## Create a new Netdata Agent container You can create a new Agent container using either `docker run` or Docker Compose. After using either method, you can diff --git a/packaging/docker/run.sh b/packaging/docker/run.sh index c04be9ff8..3f05a1708 100755 --- a/packaging/docker/run.sh +++ b/packaging/docker/run.sh @@ -13,6 +13,23 @@ if [ ! "${DO_NOT_TRACK:-0}" -eq 0 ] || [ -n "$DO_NOT_TRACK" ]; then touch /etc/netdata/.opt-out-from-anonymous-statistics fi + +BALENA_PGID=$(ls -nd /var/run/balena.sock | awk '{print $4}') +DOCKER_PGID=$(ls -nd /var/run/docker.sock | awk '{print $4}') + +re='^[0-9]+$' +if [[ $BALENA_PGID =~ $re ]]; then + echo "Netdata detected balena-engine.sock" + DOCKER_HOST='/var/run/balena-engine.sock' + PGID="$BALENA_PGID" +elif [[ $DOCKER_PGID =~ $re ]]; then + echo "Netdata detected docker.sock" + DOCKER_HOST="/var/run/docker.sock" + PGID=$(ls -nd /var/run/docker.sock | awk '{print $4}') +fi +export PGID +export DOCKER_HOST + if [ -n "${PGID}" ]; then echo "Creating docker group ${PGID}" addgroup -g "${PGID}" "docker" || echo >&2 "Could not add group docker with ID ${PGID}, its already there probably" diff --git a/packaging/ebpf.checksums b/packaging/ebpf.checksums index 7b13f7655..8ecbc9ce1 100644 --- a/packaging/ebpf.checksums +++ b/packaging/ebpf.checksums @@ -1,3 +1,3 @@ -1442027d53cf11e1b086ec837659a498a9a2738ef43e44b32a2a0171d057544a netdata-kernel-collector-glibc-v0.6.3.tar.xz -0863b06e78bb3a596cb1f68d13560301f563683cb174fd27b1e34c232e6f3c22 netdata-kernel-collector-musl-v0.6.3.tar.xz -571dddd2b3b06d9f53cc24384ffbd88e2bb662ad953acaef46c76249186fe3b6 netdata-kernel-collector-static-v0.6.3.tar.xz +7ffd13d0f32df93bc7868a7cf040e75c40a9e041f6bb7f4a591cc6ce71b1cf72 netdata-kernel-collector-glibc-v0.8.6.tar.xz +05c10d57252941b7f6dbb8a726a243416942c58738015014dd764b4bcb0c2f9c netdata-kernel-collector-musl-v0.8.6.tar.xz +2a607729a9093538624a94dfdbf2a3660eb4eb199f86962d38806d8e1e420a71 netdata-kernel-collector-static-v0.8.6.tar.xz diff --git a/packaging/ebpf.version b/packaging/ebpf.version index e4c57af0b..85c3002dc 100644 --- a/packaging/ebpf.version +++ b/packaging/ebpf.version @@ -1 +1 @@ -v0.6.3 +v0.8.6 diff --git a/packaging/go.d.checksums b/packaging/go.d.checksums index 641563eb2..883dac747 100644 --- a/packaging/go.d.checksums +++ b/packaging/go.d.checksums @@ -1,16 +1,16 @@ -512b371cde4303bce1e0d5721dadd21738b2ef779f3b502b3094eb122dc34a5e *config.tar.gz -222f585c7dc107d3325eba9b59728b2b476c3ef46ccf3e956b113a74b5b7d51c *go.d.plugin-v0.28.2.darwin-amd64.tar.gz -32a293f2363fbd85d07317c809b3ac89df3385b1c0fa63c970c0f9be9f6fe6ba *go.d.plugin-v0.28.2.freebsd-386.tar.gz -e90d4df084395aca47a2927ece350777e7b625db43ebfc2d503aabfd29f2e5dc *go.d.plugin-v0.28.2.freebsd-amd64.tar.gz -274380b5fcef455d144c52b5d73b41d0c406743db36518be3772ace4199c8a28 *go.d.plugin-v0.28.2.freebsd-arm.tar.gz -418a36b506377c19080d76878ce8f7766da00c2b6eec5b4ebe074c7c39a0905d *go.d.plugin-v0.28.2.freebsd-arm64.tar.gz -5d3b317da540ee064a622e3a91162744b883342db4fff97ad401d297d35388f1 *go.d.plugin-v0.28.2.linux-386.tar.gz -3274c55132582df296dbbbd9705f9a7693bf71faee37959da7ed8641d88f16f0 *go.d.plugin-v0.28.2.linux-amd64.tar.gz -3f449ecc91d78616ebb7ca4550c328e810f0b1bb6d92c89dbad01b5da9616b5d *go.d.plugin-v0.28.2.linux-arm.tar.gz -f70ea1bacfb1f61e87c26a4bcb225f49b3507cf033b28dbefd4c7576e1928e22 *go.d.plugin-v0.28.2.linux-arm64.tar.gz -9b92040ac994877c8e16d83df396ca62cc2ac9df6f8ad7ab042e1a0ba59c979c *go.d.plugin-v0.28.2.linux-mips.tar.gz -691c783b2ee6107426ec3151d1218d530d5e28a505afea1ed1fdcbc127cc7c97 *go.d.plugin-v0.28.2.linux-mips64.tar.gz -9de8ab05f9744cb12b3e6cfbca33c98c50bcdda1699fddde096e8407f7354f21 *go.d.plugin-v0.28.2.linux-mips64le.tar.gz -1e20f44642ecb6fbb07d65ecf279af4030e03d40e0900374e7d9b2d8d775da07 *go.d.plugin-v0.28.2.linux-mipsle.tar.gz -6231c577070e8825557b5854748d715ebcd4be4bcfea8dee71ba5887f268f300 *go.d.plugin-v0.28.2.linux-ppc64.tar.gz -106de121c1f73b366bd3ae015db062d6fda1a7ceddb68316dc023ae2081b7d9d *go.d.plugin-v0.28.2.linux-ppc64le.tar.gz +4134de9cc397a2425c18c05a112c7e27d9a7d4bb87b0b180f58a8ffc78df5ba8 *config.tar.gz +28208cde0b8bcd9dab43f832f1c6d80bbd275a68f636a1e7a847298fcda50d3e *go.d.plugin-v0.31.0.darwin-amd64.tar.gz +6a3cbfa0e02185d50f1e6b5538550219df6279ca7bc047b832f050de6f54d9d8 *go.d.plugin-v0.31.0.freebsd-386.tar.gz +75e52904516304456da3352e710d3a028a91417ab8556c19a8836a94c4fb7e2c *go.d.plugin-v0.31.0.freebsd-amd64.tar.gz +8bb88c1c5e374bc17548fe27e01e4649bfff6199866d5175c6d90f3d3a7d7e77 *go.d.plugin-v0.31.0.freebsd-arm.tar.gz +9883d8feee823627f76498d9ce077a2fc75ebe4b2844069b9bd95a15b71aca7c *go.d.plugin-v0.31.0.freebsd-arm64.tar.gz +21babd0651684e33d36b311aa89c5f38da8a3d7e35104e8638af82baa88af2cb *go.d.plugin-v0.31.0.linux-386.tar.gz +fd9e5a674b7d42623561c152e7218dedd3dc3fe227c5c12ee6516256c35c8c1c *go.d.plugin-v0.31.0.linux-amd64.tar.gz +830b946b4c349facbc8664339c58bfb8219889aaa47c1bd5639c3db141bf11c1 *go.d.plugin-v0.31.0.linux-arm.tar.gz +7d476c7315b1bbd90b6e188219cbde2a09a2e5e309a3ee83cdccba2506db297b *go.d.plugin-v0.31.0.linux-arm64.tar.gz +b9f4a4788c4ecea76270ac5403b7dfbe9506b9b9b3ba334429f9c2a4d2602593 *go.d.plugin-v0.31.0.linux-mips.tar.gz +937f68db1eeedec5139a32cf49dc3aa26ca310b38393e99afac083393d0d309f *go.d.plugin-v0.31.0.linux-mips64.tar.gz +d09d08ab7d799dadfd06f516f51dcb16e3c79f101fa20ced2b75de9be68c9209 *go.d.plugin-v0.31.0.linux-mips64le.tar.gz +278653c3f3a0d3b54383b568dac7637f7af750c71bcc5b1ad93cb2d125c9a935 *go.d.plugin-v0.31.0.linux-mipsle.tar.gz +e66c93dbd0a38ae656a04e34f7de945dfce293a82e2fcc00da5b838af51c0cfc *go.d.plugin-v0.31.0.linux-ppc64.tar.gz +50b48186645cb72d735d929ec5a80b075366d8788d3a3b21c760c3fe5235dbae *go.d.plugin-v0.31.0.linux-ppc64le.tar.gz diff --git a/packaging/go.d.version b/packaging/go.d.version index 46e8233f9..7021025f3 100644 --- a/packaging/go.d.version +++ b/packaging/go.d.version @@ -1 +1 @@ -v0.28.2 +v0.31.0 diff --git a/packaging/installer/README.md b/packaging/installer/README.md index 5b16585fe..7bdb6a757 100644 --- a/packaging/installer/README.md +++ b/packaging/installer/README.md @@ -11,7 +11,7 @@ Netdata is a monitoring agent designed to run on all your systems: physical and IoT/edge devices. Netdata runs on Linux, FreeBSD, macOS, Kubernetes, Docker, and all their derivatives. The best way to install Netdata is with our [**automatic one-line installation -script**](#automatic-one-line-installation-script), which works with all Linux distributions, or our [**.deb/rpm +script**](#automatic-one-line-installation-script), which works with all Linux distributions and macOS environments, or our [**.deb/rpm packages**](/packaging/installer/methods/packages.md), which seamlessly install with your distribution's package manager. @@ -34,15 +34,23 @@ _actively_ contributing to Netdata's future. ![](https://registry.my-netdata.io/api/v1/badge.svg?chart=web_log_nginx.requests_per_url&options=unaligned&dimensions=kickstart&group=sum&after=-3600&label=last+hour&units=installations&value_color=orange&precision=0) ![](https://registry.my-netdata.io/api/v1/badge.svg?chart=web_log_nginx.requests_per_url&options=unaligned&dimensions=kickstart&group=sum&after=-86400&label=today&units=installations&precision=0) -This method is fully automatic on all Linux distributions, including Ubuntu, Debian, Fedora, CentOS, and others. +This method is fully automatic on all Linux distributions, including Ubuntu, Debian, Fedora, CentOS, and others, as well as on mac OS environments. To install Netdata from source, including all dependencies required to connect to Netdata Cloud, and get _automatic nightly updates_, run the following as your normal user: +**Linux** + ```bash bash <(curl -Ss https://my-netdata.io/kickstart.sh) ``` +**macOS** + +```bash +bash <(curl -Ss https://my-netdata.io/kickstart.sh) --install /usr/local/ +``` + To see more information about this installation script, including how to disable automatic updates, get nightly vs. stable releases, or disable anonymous statistics, see the [`kickstart.sh` method page](/packaging/installer/methods/kickstart.md). diff --git a/packaging/installer/dependencies/alpine.sh b/packaging/installer/dependencies/alpine.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/alpine.sh diff --git a/packaging/installer/dependencies/arch.sh b/packaging/installer/dependencies/arch.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/arch.sh diff --git a/packaging/installer/dependencies/centos.sh b/packaging/installer/dependencies/centos.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/centos.sh diff --git a/packaging/installer/dependencies/clearlinux.sh b/packaging/installer/dependencies/clearlinux.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/clearlinux.sh diff --git a/packaging/installer/dependencies/debian.sh b/packaging/installer/dependencies/debian.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/debian.sh diff --git a/packaging/installer/dependencies/freebsd.sh b/packaging/installer/dependencies/freebsd.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/freebsd.sh diff --git a/packaging/installer/dependencies/gentoo.sh b/packaging/installer/dependencies/gentoo.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/gentoo.sh diff --git a/packaging/installer/dependencies/macos.sh b/packaging/installer/dependencies/macos.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/macos.sh diff --git a/packaging/installer/dependencies/ol.sh b/packaging/installer/dependencies/ol.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/ol.sh diff --git a/packaging/installer/dependencies/opensuse.sh b/packaging/installer/dependencies/opensuse.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/opensuse.sh diff --git a/packaging/installer/dependencies/rhel.sh b/packaging/installer/dependencies/rhel.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/rhel.sh diff --git a/packaging/installer/dependencies/sabayon.sh b/packaging/installer/dependencies/sabayon.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/sabayon.sh diff --git a/packaging/installer/dependencies/ubuntu.sh b/packaging/installer/dependencies/ubuntu.sh new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/packaging/installer/dependencies/ubuntu.sh diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh index fd10fcfaf..6264c1131 100644 --- a/packaging/installer/functions.sh +++ b/packaging/installer/functions.sh @@ -224,17 +224,22 @@ safe_pidof() { # ----------------------------------------------------------------------------- find_processors() { - # Most UNIX systems have `nproc` as part of their userland (including macOS, Linux and BSD) + # Most UNIX systems have `nproc` as part of their userland (including Linux and BSD) if command -v nproc > /dev/null; then nproc && return fi + # macOS has no nproc but it may have gnproc installed from Homebrew or from Macports. + if command -v gnproc > /dev/null; then + gnproc && return + fi + local cpus if [ -f "/proc/cpuinfo" ]; then # linux cpus=$(grep -c ^processor /proc/cpuinfo) else - # freebsd + # freebsd cpus=$(sysctl hw.ncpu 2> /dev/null | grep ^hw.ncpu | cut -d ' ' -f 2) fi if [ -z "${cpus}" ] || [ $((cpus)) -lt 1 ]; then diff --git a/packaging/installer/install-required-packages.sh b/packaging/installer/install-required-packages.sh index f65535dd0..6eeda53c0 100755 --- a/packaging/installer/install-required-packages.sh +++ b/packaging/installer/install-required-packages.sh @@ -17,10 +17,10 @@ fi # These options control which packages we are going to install # They can be pre-set, but also can be controlled with command line options -PACKAGES_NETDATA=${PACKAGES_NETDATA-0} +PACKAGES_NETDATA=${PACKAGES_NETDATA-1} PACKAGES_NETDATA_NODEJS=${PACKAGES_NETDATA_NODEJS-0} PACKAGES_NETDATA_PYTHON=${PACKAGES_NETDATA_PYTHON-0} -PACKAGES_NETDATA_PYTHON3=${PACKAGES_NETDATA_PYTHON3-0} +PACKAGES_NETDATA_PYTHON3=${PACKAGES_NETDATA_PYTHON3-1} PACKAGES_NETDATA_PYTHON_MYSQL=${PACKAGES_NETDATA_PYTHON_MYSQL-0} PACKAGES_NETDATA_PYTHON_POSTGRES=${PACKAGES_NETDATA_PYTHON_POSTGRES-0} PACKAGES_NETDATA_PYTHON_MONGO=${PACKAGES_NETDATA_PYTHON_MONGO-0} @@ -31,8 +31,8 @@ PACKAGES_FIREQOS=${PACKAGES_FIREQOS-0} PACKAGES_UPDATE_IPSETS=${PACKAGES_UPDATE_IPSETS-0} PACKAGES_NETDATA_DEMO_SITE=${PACKAGES_NETDATA_DEMO_SITE-0} PACKAGES_NETDATA_SENSORS=${PACKAGES_NETDATA_SENSORS-0} -PACKAGES_NETDATA_DATABASE=${PACKAGES_NETDATA_DATABASE-0} -PACKAGES_NETDATA_EBPF=${PACKAGES_NETDATA_EBPF-0} +PACKAGES_NETDATA_DATABASE=${PACKAGES_NETDATA_DATABASE-1} +PACKAGES_NETDATA_EBPF=${PACKAGES_NETDATA_EBPF-1} # needed commands lsb_release=$(command -v lsb_release 2> /dev/null) @@ -198,7 +198,7 @@ get_os_release() { eval "$(grep -E "^(NAME|ID|ID_LIKE|VERSION|VERSION_ID)=" "${os_release_file}")" for x in "${ID}" ${ID_LIKE}; do case "${x,,}" in - alpine | arch | centos | clear-linux-os | debian | fedora | gentoo | manjaro | opensuse-leap | rhel | sabayon | sles | suse | ubuntu) + alpine | arch | centos | clear-linux-os | debian | fedora | gentoo | manjaro | opensuse-leap | ol | rhel | sabayon | sles | suse | ubuntu) distribution="${x}" version="${VERSION_ID}" codename="${VERSION}" @@ -345,7 +345,7 @@ user_picks_distribution() { if [ "${REPLY}" = "yum" ] && [ -z "${distribution}" ]; then REPLY= while [ -z "${REPLY}" ]; do - if ! read -r -p "yum in centos, rhel or fedora? > "; then + if ! read -r -p "yum in centos, rhel, ol or fedora? > "; then continue fi @@ -353,11 +353,14 @@ user_picks_distribution() { fedora | rhel) distribution="rhel" ;; + ol) + distribution="ol" + ;; centos) distribution="centos" ;; *) - echo >&2 "Please enter 'centos', 'fedora' or 'rhel'." + echo >&2 "Please enter 'centos', 'fedora', 'ol' or 'rhel'." REPLY= ;; esac @@ -417,12 +420,12 @@ detect_package_manager_from_distribution() { ;; centos* | clearos*) - echo >&2 "You should have EPEL enabled to install all the prerequisites." - echo >&2 "Check: http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/" - package_installer="install_yum" + package_installer="" tree="centos" + [ -n "${dnf}" ] && package_installer="install_dnf" + [ -n "${yum}" ] && package_installer="install_yum" if [ "${IGNORE_INSTALLED}" -eq 0 ] && [ -z "${yum}" ]; then - echo >&2 "command 'yum' is required to install packages on a '${distribution} ${version}' system." + echo >&2 "command 'yum' or 'dnf' is required to install packages on a '${distribution} ${version}' system." exit 1 fi ;; @@ -430,8 +433,19 @@ detect_package_manager_from_distribution() { fedora* | redhat* | red\ hat* | rhel*) package_installer= tree="rhel" + [ -n "${dnf}" ] && package_installer="install_dnf" [ -n "${yum}" ] && package_installer="install_yum" + if [ "${IGNORE_INSTALLED}" -eq 0 ] && [ -z "${package_installer}" ]; then + echo >&2 "command 'yum' or 'dnf' is required to install packages on a '${distribution} ${version}' system." + exit 1 + fi + ;; + + ol*) + package_installer= + tree="ol" [ -n "${dnf}" ] && package_installer="install_dnf" + [ -n "${yum}" ] && package_installer="install_yum" if [ "${IGNORE_INSTALLED}" -eq 0 ] && [ -z "${package_installer}" ]; then echo >&2 "command 'yum' or 'dnf' is required to install packages on a '${distribution} ${version}' system." exit 1 @@ -499,7 +513,13 @@ check_package_manager() { dnf) [ "${IGNORE_INSTALLED}" -eq 0 ] && [ -z "${dnf}" ] && echo >&2 "${1} is not available." && return 1 package_installer="install_dnf" - tree="rhel" + if [ "${distribution}" = "centos" ]; then + tree="centos" + elif [ "${distribution}" = "ol" ]; then + tree="ol" + else + tree="rhel" + fi detection="user-input" return 0 ;; @@ -550,6 +570,8 @@ check_package_manager() { package_installer="install_yum" if [ "${distribution}" = "centos" ]; then tree="centos" + elif [ "${distribution}" = "ol" ]; then + tree="ol" else tree="rhel" fi @@ -721,6 +743,21 @@ declare -A pkg_gcc=( ['default']="gcc" ) +# g++, required for building protobuf +# All three cases of this not being required are systems that implicitly +# include g++ when installing gcc. +declare -A pkg_gxx=( + ['alpine']="g++" + ['arch']="NOTREQUIRED" + ['clearlinux']="c-basic" + ['debian']="g++" + ['gentoo']="NOTREQUIRED" + ['macos']="NOTREQUIRED" + ['ubuntu']="g++" + ['freebsd']="NOTREQUIRED" + ['default']="gcc-c++" +) + declare -A pkg_gdb=( ['gentoo']="sys-devel/gdb" ['macos']="NOTREQUIRED" @@ -772,6 +809,7 @@ declare -A pkg_libz_dev=( ['gentoo']="sys-libs/zlib" ['sabayon']="sys-libs/zlib" ['rhel']="zlib-devel" + ['ol']="zlib-devel" ['suse']="zlib-devel" ['clearlinux']="devpkg-zlib" ['macos']="NOTREQUIRED" @@ -788,6 +826,7 @@ declare -A pkg_libuuid_dev=( ['gentoo']="sys-apps/util-linux" ['sabayon']="sys-apps/util-linux" ['rhel']="libuuid-devel" + ['ol']="libuuid-devel" ['suse']="libuuid-devel" ['macos']="NOTREQUIRED" ['freebsd']="e2fsprogs-libuuid" @@ -802,6 +841,7 @@ declare -A pkg_libmnl_dev=( ['gentoo']="net-libs/libmnl" ['sabayon']="net-libs/libmnl" ['rhel']="libmnl-devel" + ['ol']="libmnl-devel" ['suse']="libmnl-devel" ['clearlinux']="devpkg-libmnl" ['macos']="NOTREQUIRED" @@ -859,6 +899,7 @@ declare -A pkg_netcat=( ['gentoo']="net-analyzer/netcat" ['sabayon']="net-analyzer/gnu-netcat" ['rhel']="nmap-ncat" + ['ol']="nmap-ncat" ['suse']="netcat-openbsd" ['clearlinux']="sysadmin-basic" ['arch']="gnu-netcat" @@ -903,6 +944,7 @@ declare -A pkg_pkg_config=( ['gentoo']="virtual/pkgconfig" ['sabayon']="virtual/pkgconfig" ['rhel']="pkgconfig" + ['ol']="pkgconfig" ['suse']="pkg-config" ['freebsd']="pkgconf" ['clearlinux']="c-basic" @@ -934,6 +976,7 @@ declare -A pkg_python_mysqldb=( # exceptions ['fedora-24']="python2-mysql" + ['ol-8']="WARNING|" ) declare -A pkg_python3_mysqldb=( @@ -944,6 +987,7 @@ declare -A pkg_python3_mysqldb=( ['gentoo']="dev-python/mysqlclient" ['sabayon']="dev-python/mysqlclient" ['rhel']="WARNING|" + ['ol']="WARNING|" ['suse']="WARNING|" ['clearlinux']="WARNING|" ['macos']="WARNING|" @@ -975,6 +1019,7 @@ declare -A pkg_python_psycopg2=( ['gentoo']="dev-python/psycopg" ['sabayon']="dev-python/psycopg:2" ['rhel']="python-psycopg2" + ['ol']="python-psycopg2" ['suse']="python-psycopg2" ['clearlinux']="WARNING|" ['macos']="WARNING|" @@ -989,6 +1034,7 @@ declare -A pkg_python3_psycopg2=( ['gentoo']="dev-python/psycopg" ['sabayon']="dev-python/psycopg:2" ['rhel']="WARNING|" + ['ol']="WARNING|" ['suse']="WARNING|" ['clearlinux']="WARNING|" ['macos']="WARNING|" @@ -998,6 +1044,7 @@ declare -A pkg_python3_psycopg2=( ['centos-8']="python38-psycopg2" ['rhel-7']="python3-psycopg2" ['rhel-8']="python38-psycopg2" + ['ol-8']="python3-psycopg2" ) declare -A pkg_python_pip=( @@ -1028,6 +1075,7 @@ declare -A pkg_python_pymongo=( ['suse']="python-pymongo" ['clearlinux']="WARNING|" ['rhel']="WARNING|" + ['ol']="WARNING|" ['macos']="WARNING|" ['default']="python-pymongo" ) @@ -1041,6 +1089,7 @@ declare -A pkg_python3_pymongo=( ['suse']="python3-pymongo" ['clearlinux']="WARNING|" ['rhel']="WARNING|" + ['ol']="WARNING|" ['freebsd']="py37-pymongo" ['macos']="WARNING|" ['default']="python3-pymongo" @@ -1049,6 +1098,7 @@ declare -A pkg_python3_pymongo=( ['centos-8']="python3-pymongo" ['rhel-7']="python36-pymongo" ['rhel-8']="python3-pymongo" + ['ol-8']="python3-pymongo" ) declare -A pkg_python_requests=( @@ -1084,6 +1134,7 @@ declare -A pkg_python3_requests=( ['centos-8']="python3-requests" ['rhel-7']="python36-requests" ['rhel-8']="python3-requests" + ['ol-8']="python3-requests" ) declare -A pkg_lz4=( @@ -1187,6 +1238,7 @@ declare -A pkg_valgrind=( declare -A pkg_ulogd=( ['centos']="WARNING|" ['rhel']="WARNING|" + ['ol']="WARNING|" ['clearlinux']="WARNING|" ['gentoo']="app-admin/ulogd" ['arch']="ulogd" @@ -1216,6 +1268,7 @@ declare -A pkg_libelf=( ['fedora']="elfutils-libelf-devel" ['centos']="elfutils-libelf-devel" ['rhel']="elfutils-libelf-devel" + ['ol']="elfutils-libelf-devel" ['clearlinux']="devpkg-elfutils" ['suse']="libelf-devel" ['macos']="NOTREQUIRED" @@ -1291,6 +1344,7 @@ packages() { require_cmd gcc || require_cmd gcc-multilib || suitable_package gcc + require_cmd g++ || suitable_package gxx require_cmd make || suitable_package make require_cmd autoconf || suitable_package autoconf @@ -1524,21 +1578,38 @@ validate_tree_freebsd() { fi } -validate_tree_centos() { +validate_tree_ol() { local opts= if [ "${NON_INTERACTIVE}" -eq 1 ]; then echo >&2 "Running in non-interactive mode" opts="-y" fi - echo >&2 " > CentOS Version: ${version} ..." - - echo >&2 " > Checking for epel ..." - if ! rpm -qa | grep epel > /dev/null; then - if prompt "epel not found, shall I install it?"; then - run ${sudo} yum ${opts} install epel-release + if [[ "${version}" =~ ^8(\..*)?$ ]]; then + echo " > Checking for CodeReady Builder ..." + if ! run ${sudo} dnf repolist | grep -q codeready; then + if prompt "CodeReady Builder not found, shall I install it?"; then + cat > /etc/yum.repos.d/ol8_codeready.repo <<-EOF + [ol8_codeready_builder] + name=Oracle Linux \$releasever CodeReady Builder (\$basearch) + baseurl=http://yum.oracle.com/repo/OracleLinux/OL8/codeready/builder/\$basearch + gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle + gpgcheck=1 + enabled=1 + EOF + fi fi fi +} + +validate_tree_centos() { + local opts= + if [ "${NON_INTERACTIVE}" -eq 1 ]; then + echo >&2 "Running in non-interactive mode" + opts="-y" + fi + + echo >&2 " > CentOS Version: ${version} ..." if [[ "${version}" =~ ^8(\..*)?$ ]]; then echo >&2 " > Checking for config-manager ..." @@ -1555,16 +1626,19 @@ validate_tree_centos() { fi fi - echo >&2 " > Checking for Okay ..." - if ! rpm -qa | grep okay > /dev/null; then - if prompt "okay not found, shall I install it?"; then - run ${sudo} yum ${opts} install http://repo.okay.com.mx/centos/8/x86_64/release/okay-release-1-5.el8.noarch.rpm - fi - fi + echo >&2 " > Updating libarchive ..." + run ${sudo} yum ${opts} install libarchive echo >&2 " > Installing Judy-devel directly ..." - run ${sudo} yum ${opts} install http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/Judy-devel-1.0.5-18.module_el8.1.0+217+4d875839.x86_64.rpm + run ${sudo} yum ${opts} install http://mirror.centos.org/centos/8/PowerTools/x86_64/os/Packages/Judy-devel-1.0.5-18.module_el8.3.0+757+d382997d.x86_64.rpm + elif [[ "${version}" =~ ^7(\..*)?$ ]]; then + echo >&2 " > Checking for EPEL ..." + if ! rpm -qa | grep epel-release > /dev/null; then + if prompt "EPEL not found, shall I install it?"; then + run ${sudo} yum ${opts} install epel-release + fi + fi elif [[ "${version}" =~ ^6\..*$ ]]; then echo >&2 " > Detected CentOS 6.x ..." echo >&2 " > Checking for Okay ..." @@ -1601,7 +1675,7 @@ install_yum() { read -r -a yum_opts <<< "${opts}" # install the required packages - run ${sudo} yum "${yum_opts[@]}" install "${@}" # --enablerepo=epel-testing + run ${sudo} yum "${yum_opts[@]}" install "${@}" } # ----------------------------------------------------------------------------- diff --git a/packaging/installer/kickstart-ng.sh b/packaging/installer/kickstart-ng.sh new file mode 100644 index 000000000..8fcc6d5d3 --- /dev/null +++ b/packaging/installer/kickstart-ng.sh @@ -0,0 +1,1362 @@ +#!/bin/sh +# +# SPDX-License-Identifier: GPL-3.0-or-later + +# ====================================================================== +# Constants + +KICKSTART_OPTIONS="${*}" +PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packaging/installer/install-required-packages.sh" +PATH="${PATH}:/usr/local/bin:/usr/local/sbin" +REPOCONFIG_URL_PREFIX="https://packagecloud.io/netdata/netdata-repoconfig/packages" +REPOCONFIG_VERSION="1-1" +TELEMETRY_URL="https://posthog.netdata.cloud/capture/" +START_TIME="$(date +%s)" + +# ====================================================================== +# Defaults for environment variables + +SELECTED_INSTALL_METHOD="none" +INSTALL_TYPE="unknown" +INSTALL_PREFIX="" +NETDATA_AUTO_UPDATES="1" +NETDATA_CLAIM_ONLY=0 +NETDATA_CLAIM_URL="https://app.netdata.cloud" +NETDATA_DISABLE_CLOUD=0 +NETDATA_ONLY_BUILD=0 +NETDATA_ONLY_NATIVE=0 +NETDATA_ONLY_STATIC=0 +NETDATA_REQUIRE_CLOUD=1 +RELEASE_CHANNEL="nightly" + +NETDATA_DISABLE_TELEMETRY="${DO_NOT_TRACK:-0}" +NETDATA_TARBALL_BASEURL="${NETDATA_TARBALL_BASEURL:-https://storage.googleapis.com/netdata-nightlies}" +NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS:-""}" +TELEMETRY_API_KEY="${NETDATA_POSTHOG_API_KEY:-mqkwGT0JNFqO-zX2t0mW6Tec9yooaVu7xCBlXtHnt5Y}" + +if [ ! -t 1 ]; then + INTERACTIVE=0 +else + INTERACTIVE=1 +fi + +# ====================================================================== +# Usage info + +usage() { + cat << HEREDOC +USAGE: kickstart.sh [options] + where options include: + + --non-interactive Do not prompt for user input. (default: prompt if there is a controlling terminal) + --interactive Prompt for user input even if there is no controlling terminal. + --dont-start-it Do not start the agent by default (only for static installs or local builds) + --stable-channel Install a stable version instead of a nightly build (default: install a nightly build) + --nightly-channel Install a nightly build instead of a stable version + --no-updates Do not enable automatic updates (default: enable automatic updates) + --auto-update Enable automatic updates. + --disable-telemetry Opt-out of anonymous statistics. + --native-only Only install if native binary packages are available. + --static-only Only install if a static build is available. + --build-only Only install using a local build. + --reinstall Explicitly reinstall instead of updating any existing install. + --reinstall-even-if-unsafe Even try to reinstall if we don't think we can do so safely (implies --reinstall). + --disable-cloud Disable support for Netdata Cloud (default: detect) + --require-cloud Only install if Netdata Cloud can be enabled. Overrides --disable-cloud. + --install <path> Specify an installation prefix for local builds (default: autodetect based on system type). + --claim-token Use a specified token for claiming to Netdata Cloud. + --claim-rooms When claiming, add the node to the specified rooms. + --claim-only If there is an existing install, only try to claim it, not update it. + --claim-* Specify other options for the claiming script. + --no-cleanup Don't do any cleanup steps. This is intended to help with debugging the installer. + +Additionally, this script may use the following environment variables: + + TMPDIR: Used to specify where to put temporary files. On most systems, the default we select + automatically should be fine. The user running the script needs to both be able to + write files to the temporary directory, and run files from that location. + ROOTCMD: Used to specify a command to use to run another command with root privileges if needed. By + default we try to use sudo, doas, or pkexec (in that order of preference), but if + you need special options for one of those to work, or have a different tool to do + the same thing on your system, you can specify it here. + DO_NOT_TRACK If set to a value other than 0, behave as if \`--disable-telemetry\` was specified. + NETDATA_INSTALLER_OPTIONS: Specifies extra options to pass to the static installer or local build script. + +HEREDOC +} + +# ====================================================================== +# Telemetry functions + +telemetry_event() { + if [ "${NETDATA_DISABLE_TELEMETRY}" -eq 1 ]; then + return 0 + fi + + now="$(date +%s)" + total_duration="$((now - START_TIME))" + + if [ -e "/etc/os-release" ]; then + eval "$(grep -E "^(NAME|ID|ID_LIKE|VERSION|VERSION_ID)=" < /etc/os-release | sed 's/^/HOST_/')" + fi + + if [ -z "${HOST_NAME}" ] || [ -z "${HOST_VERSION}" ] || [ -z "${HOST_ID}" ]; then + if [ -f "/etc/lsb-release" ]; then + DISTRIB_ID="unknown" + DISTRIB_RELEASE="unknown" + DISTRIB_CODENAME="unknown" + eval "$(grep -E "^(DISTRIB_ID|DISTRIB_RELEASE|DISTRIB_CODENAME)=" < /etc/lsb-release)" + if [ -z "${HOST_NAME}" ]; then HOST_NAME="${DISTRIB_ID}"; fi + if [ -z "${HOST_VERSION}" ]; then HOST_VERSION="${DISTRIB_RELEASE}"; fi + if [ -z "${HOST_ID}" ]; then HOST_ID="${DISTRIB_CODENAME}"; fi + fi + fi + + KERNEL_NAME="$(uname -s)" + + if [ "${KERNEL_NAME}" = FreeBSD ]; then + TOTAL_RAM="$(sysctl -n hw.physmem)" + elif [ "${KERNEL_NAME}" = Darwin ]; then + TOTAL_RAM="$(sysctl -n hw.memsize)" + elif [ -r /proc/meminfo ]; then + TOTAL_RAM="$(grep -F MemTotal /proc/meminfo | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | cut -f 1 -d ' ')" + TOTAL_RAM="$((TOTAL_RAM * 1024))" + fi + + if [ -f /etc/machine-id ]; then + DISTINCT_ID="$(cat /etc/machine-id)" + elif command -v uuidgen > /dev/null 2>&1; then + DISTINCT_ID="$(uuidgen)" + else + DISTINCT_ID="null" + fi + + REQ_BODY="$(cat << EOF +{ + "api_key": "${TELEMETRY_API_KEY}", + "event": "${1}", + "properties": { + "distinct_id": "${DISTINCT_ID}", + "event_source": "agent installer", + "\$current_url": "agent installer", + "\$pathname": "netdata-installer", + "\$host": "installer.netdata.io", + "\$ip": "127.0.0.1", + "script_variant": "kickstart-ng", + "error_code": "${3}", + "error_message": "${2}", + "install_options": "${KICKSTART_OPTIONS}", + "total_runtime": "${total_duration}", + "selected_install_method": "${SELECTED_INSTALL_METHOD}", + "netdata_release_channel": "${RELEASE_CHANNEL:-null}", + "netdata_install_type": "${INSTALL_TYPE}", + "host_os_name": "${HOST_NAME:-unknown}", + "host_os_id": "${HOST_ID:-unknown}", + "host_os_id_like": "${HOST_ID_LIKE:-unknown}", + "host_os_version": "${HOST_VERSION:-unknown}", + "host_os_version_id": "${HOST_VERSION_ID:-unknown}", + "system_kernel_name": "${KERNEL_NAME}", + "system_kernel_version": "$(uname -r)", + "system_architecture": "$(uname -m)", + "system_total_ram": "${TOTAL_RAM:-unknown}" + } +} +EOF +)" + + if [ -n "$(command -v curl 2> /dev/null)" ]; then + curl --silent -o /dev/null -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" "${TELEMETRY_URL}" > /dev/null + else + wget -q -O - --no-check-certificate \ + --method POST \ + --timeout=1 \ + --header 'Content-Type: application/json' \ + --body-data "${REQ_BODY}" \ + "${TELEMETRY_URL}" > /dev/null + fi +} + +trap_handler() { + code="${1}" + lineno="${2}" + + printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ERROR ${TPUT_RESET} Installer exited unexpectedly (${code}-${lineno})" + + telemetry_event INSTALL_CRASH "Installer exited unexpectedly (${code}-${lineno})" "E${code}-${lineno}" + + trap - EXIT + + cleanup + + exit 1 +} + +trap 'trap_handler 0 ${LINENO}' EXIT +trap 'trap_handler 1 0' HUP +trap 'trap_handler 2 0' INT +trap 'trap_handler 3 0' QUIT +trap 'trap_handler 13 0' PIPE +trap 'trap_handler 15 0' TERM + +# ====================================================================== +# Utility functions + +setup_terminal() { + TPUT_RESET="" + TPUT_WHITE="" + TPUT_BGRED="" + TPUT_BGGREEN="" + TPUT_BOLD="" + TPUT_DIM="" + + # Is stderr on the terminal? If not, then fail + test -t 2 || return 1 + + if command -v tput > /dev/null 2>&1; then + if [ $(($(tput colors 2> /dev/null))) -ge 8 ]; then + # Enable colors + TPUT_RESET="$(tput sgr 0)" + TPUT_WHITE="$(tput setaf 7)" + TPUT_BGRED="$(tput setab 1)" + TPUT_BGGREEN="$(tput setab 2)" + TPUT_BOLD="$(tput bold)" + TPUT_DIM="$(tput dim)" + fi + fi + + echo "${TPUT_RESET}" + + return 0 +} + +cleanup() { + if [ -z "${NO_CLEANUP}" ]; then + ${ROOTCMD} rm -rf "${tmpdir}" + fi +} + +fatal() { + printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*}" + telemetry_event "INSTALL_FAILED" "${1}" "${2}" + cleanup + trap - EXIT + exit 1 +} + +run_ok() { + printf >&2 "%s\n\n" "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET}" +} + +run_failed() { + printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET}" +} + +ESCAPED_PRINT_METHOD= +# shellcheck disable=SC3050 +if printf "%q " test > /dev/null 2>&1; then + ESCAPED_PRINT_METHOD="printfq" +fi + +escaped_print() { + if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then + # shellcheck disable=SC3050 + printf "%q " "${@}" + else + printf "%s" "${*}" + fi + return 0 +} + +progress() { + echo >&2 " --- ${TPUT_BOLD}${*}${TPUT_RESET} --- " +} + +run_logfile="/dev/null" +run() { + user="${USER--}" + dir="${PWD}" + + if [ "$(id -u)" = "0" ]; then + info="[root ${dir}]# " + info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# " + else + info="[${user} ${dir}]$ " + info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ " + fi + + { + printf "%s" "${info}" + escaped_print "${@}" + printf " ... " + } >> "${run_logfile}" + + printf >&2 "%s" "${info_console}${TPUT_BOLD}" + escaped_print >&2 "${@}" + printf >&2 "%s\n" "${TPUT_RESET}" + + "${@}" + + ret=$? + if [ ${ret} -ne 0 ]; then + run_failed + printf "%s\n" "FAILED with exit code ${ret}" >> "${run_logfile}" + else + run_ok + printf "OK\n" >> "${run_logfile}" + fi + + return ${ret} +} + +warning() { + printf >&2 "%s\n\n" "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} WARNING ${TPUT_RESET} ${*}" +} + +_cannot_use_tmpdir() { + testfile="$(TMPDIR="${1}" mktemp -q -t netdata-test.XXXXXXXXXX)" + ret=0 + + if [ -z "${testfile}" ]; then + return "${ret}" + fi + + if printf '#!/bin/sh\necho SUCCESS\n' > "${testfile}"; then + if chmod +x "${testfile}"; then + if [ "$("${testfile}")" = "SUCCESS" ]; then + ret=1 + fi + fi + fi + + rm -f "${testfile}" + return "${ret}" +} + +create_tmp_directory() { + if [ -z "${TMPDIR}" ] || _cannot_use_tmpdir "${TMPDIR}"; then + if _cannot_use_tmpdir /tmp; then + if _cannot_use_tmpdir "${PWD}"; then + fatal "Unable to find a usable temporary directory. Please set \$TMPDIR to a path that is both writable and allows execution of files and try again." F0400 + else + TMPDIR="${PWD}" + fi + else + TMPDIR="/tmp" + fi + fi + + mktemp -d -t netdata-kickstart-XXXXXXXXXX +} + +download() { + url="${1}" + dest="${2}" + if command -v curl > /dev/null 2>&1; then + run curl -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}" || return 1 + elif command -v wget > /dev/null 2>&1; then + run wget -T 15 -O "${dest}" "${url}" || return 1 + else + fatal "I need curl or wget to proceed, but neither of them are available on this system." F0003 + fi +} + +get_redirect() { + url="${1}" + + if command -v curl > /dev/null 2>&1; then + run sh -c "curl ${url} -s -L -I -o /dev/null -w '%{url_effective}' | grep -o '[^/]*$'" || return 1 + elif command -v wget > /dev/null 2>&1; then + run sh -c "wget --max-redirect=0 ${url} 2>&1 | grep Location | cut -d ' ' -f2 | grep -o '[^/]*$'" || return 1 + else + fatal "I need curl or wget to proceed, but neither of them are available on this system." F0003 + fi +} + +safe_sha256sum() { + # Within the context of the installer, we only use -c option that is common between the two commands + # We will have to reconsider if we start using non-common options + if command -v sha256sum > /dev/null 2>&1; then + sha256sum "$@" + elif command -v shasum > /dev/null 2>&1; then + shasum -a 256 "$@" + else + fatal "I could not find a suitable checksum binary to use" F0004 + fi +} + +get_system_info() { + case "$(uname -s)" in + Linux) + SYSTYPE="Linux" + + os_release_file= + if [ -s "/etc/os-release" ] && [ -r "/etc/os-release" ]; then + os_release_file="/etc/os-release" + elif [ -s "/usr/lib/os-release" ] && [ -r "/usr/lib/os-release" ]; then + os_release_file="/usr/lib/os-release" + else + fatal "Cannot find an os-release file ..." F0401 + fi + + # shellcheck disable=SC1090 + . "${os_release_file}" + + DISTRO="${ID}" + SYSVERSION="${VERSION_ID}" + SYSCODENAME="${VERSION_CODENAME}" + SYSARCH="$(uname -m)" + + supported_compat_names="debian ubuntu centos fedora opensuse" + + if str_in_list "${DISTRO}" "${supported_compat_names}"; then + DISTRO_COMPAT_NAME="${DISTRO}" + else + case "${DISTRO}" in + opensuse-leap) + DISTRO_COMPAT_NAME="opensuse" + ;; + rhel) + DISTRO_COMPAT_NAME="centos" + ;; + *) + DISTRO_COMPAT_NAME="unknown" + ;; + esac + fi + ;; + Darwin) + SYSTYPE="Darwin" + SYSVERSION="$(sw_vers -buildVersion)" + SYSARCH="$(uname -m)" + ;; + FreeBSD) + SYSTYPE="FreeBSD" + SYSVERSION="$(uname -K)" + SYSARCH="$(uname -m)" + ;; + *) + fatal "Unsupported system type detected. Netdata cannot be installed on this system using this script." F0200 + ;; + esac +} + +str_in_list() { + printf "%s\n" "${2}" | tr ' ' "\n" | grep -qE "^${1}\$" + return $? +} + +confirm_root_support() { + if [ "$(id -u)" -ne "0" ]; then + if [ -z "${ROOTCMD}" ] && command -v sudo > /dev/null; then + ROOTCMD="sudo" + fi + + if [ -z "${ROOTCMD}" ] && command -v doas > /dev/null; then + ROOTCMD="doas" + fi + + if [ -z "${ROOTCMD}" ] && command -v pkexec > /dev/null; then + ROOTCMD="pkexec" + fi + + if [ -z "${ROOTCMD}" ]; then + fatal "We need root privileges to continue, but cannot find a way to gain them. Either re-run this script as root, or set \$ROOTCMD to a command that can be used to gain root privileges" F0201 + fi + fi +} + +confirm() { + prompt="${1} [y/n]" + + while true; do + echo "${prompt}" + read -r yn + + case "$yn" in + [Yy]*) return 0;; + [Nn]*) return 1;; + *) echo "Please answer yes or no.";; + esac + done +} + +# ====================================================================== +# Existing install handling code + +update() { + updater="${ndprefix}/usr/libexec/netdata/netdata-updater.sh" + + if [ -x "${updater}" ]; then + if run ${ROOTCMD} "${updater}" --not-running-from-cron; then + progress "Updated existing install at ${ndprefix}" + return 0 + else + fatal "Failed to update existing Netdata install at ${ndprefix}" F0100 + fi + else + return 1 + fi +} + +handle_existing_install() { + if pkg_installed netdata; then + ndprefix="/" + else + if [ -n "${INSTALL_PREFIX}" ]; then + searchpath="${INSTALL_PREFIX}/bin:${INSTALL_PREFIX}/sbin:${INSTALL_PREFIX}/usr/bin:${INSTALL_PREFIX}/usr/sbin:${PATH}" + searchpath="${INSTALL_PREFIX}/netdata/bin:${INSTALL_PREFIX}/netdata/sbin:${INSTALL_PREFIX}/netdata/usr/bin:${INSTALL_PREFIX}/netdata/usr/sbin:${searchpath}" + else + searchpath="${PATH}" + fi + + ndpath="$(PATH="${searchpath}" command -v netdata 2>/dev/null)" + + if [ -z "$ndpath" ] && [ -x /opt/netdata/bin/netdata ]; then + ndpath="/opt/netdata/bin/netdata" + fi + + if [ -n "${ndpath}" ]; then + ndprefix="$(dirname "$(dirname "${ndpath}")")" + fi + + if echo "${ndprefix}" | grep -Eq '/usr$'; then + ndprefix="$(dirname "${ndprefix}")" + fi + fi + + if [ -n "${ndprefix}" ]; then + typefile="${ndprefix}/etc/netdata/.install-type" + if [ -r "${typefile}" ]; then + ${ROOTCMD} sh -c "cat \"${typefile}\" > \"${tmpdir}/install-type\"" + # shellcheck disable=SC1091 + . "${tmpdir}/install-type" + else + INSTALL_TYPE="unknown" + fi + fi + + if [ -z "${ndprefix}" ]; then + progress "No existing installations of netdata found, assuming this is a fresh install." + return 0 + fi + + case "${INSTALL_TYPE}" in + kickstart-*|legacy-*|binpkg-*|manual-static|unknown) + if [ "${INSTALL_TYPE}" = "unknown" ]; then + warning "Found an existing netdata install at ${ndprefix}, but could not determine the install type." + else + progress "Found an existing netdata install at ${ndprefix}, with installation type '${INSTALL_TYPE}'." + fi + + if [ -n "${NETDATA_REINSTALL}" ] || [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then + progress "Found an existing netdata install at ${ndprefix}, but user requested reinstall, continuing." + + case "${INSTALL_TYPE}" in + binpkg-*) NETDATA_ONLY_NATIVE=1 ;; + *-build) NETDATA_ONLY_BUILD=1 ;; + *-static) NETDATA_ONLY_STATIC=1 ;; + *) + if [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then + warning "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, but the user has requested we proceed." + elif [ "${INTERACTIVE}" -eq 0 ]; then + fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting." F0104 + else + if confirm "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, do you want to continue?"; then + progress "OK, continuing." + else + fatal "Cancelling reinstallation at user request." F0105 + fi + fi + ;; + esac + + return 0 + fi + + ret=0 + + if [ "${NETDATA_CLAIM_ONLY}" -eq 0 ] && echo "${INSTALL_TYPE}" | grep -vq "binpkg-*"; then + if ! update; then + warning "Unable to find usable updater script, not updating existing install at ${ndprefix}." + fi + else + warning "Not updating existing install at ${ndprefix}." + fi + + if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then + progress "Attempting to claim existing install at ${ndprefix}." + INSTALL_PREFIX="${ndprefix}" + claim + ret=$? + elif [ "${NETDATA_CLAIM_ONLY}" -eq 1 ]; then + fatal "User asked to claim, but did not proide a claiming token." F0202 + else + progress "Not attempting to claim existing install at ${ndprefix} (no claiming token provided)." + fi + + cleanup + trap - EXIT + exit $ret + ;; + oci) + fatal "This is an OCI container, use the regular image lifecycle management commands in your container instead of this script for managing it." F0203 + ;; + *) + if [ -n "${NETDATA_REINSTALL}" ] || [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then + if [ -n "${NETDATA_UNSAFE_REINSTALL}" ]; then + warning "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, but the user has requested we proceed." + elif [ "${INTERACTIVE}" -eq 0 ]; then + fatal "User requested reinstall, but we cannot safely reinstall over top of a ${INSTALL_TYPE} installation, exiting." F0104 + else + if confirm "Reinstalling over top of a ${INSTALL_TYPE} installation may be unsafe, do you want to continue?"; then + progress "OK, continuing." + else + fatal "Cancelling reinstallation at user request." F0105 + fi + fi + else + fatal "Found an existing netdata install at ${ndprefix}, but the install type is '${INSTALL_TYPE}', which is not supported, refusing to proceed." F0103 + fi + ;; + esac +} + +soft_disable_cloud() { + cloud_prefix="${INSTALL_PREFIX}/var/lib/netdata/cloud.d" + + run ${ROOTCMD} mkdir -p "${cloud_prefix}" + + cat > "${tmpdir}/cloud.conf" << EOF +[global] + enabled = no +EOF + + run ${ROOTCMD} cp "${tmpdir}/cloud.conf" "${cloud_prefix}/cloud.conf" + + if [ -z "${NETDATA_NO_START}" ]; then + case "${SYSTYPE}" in + Darwin) run ${ROOTCMD} launchctl kickstart -k com.github.netdata ;; + FreeBSD) run ${ROOTCMD} service netdata restart ;; + Linux) + initpath="$(${ROOTCMD} readlink /proc/1/exe)" + + if command -v service > /dev/null 2>&1; then + run ${ROOTCMD} service netdata restart + elif command -v rc-service > /dev/null 2>&1; then + run ${ROOTCMD} rc-service netdata restart + elif [ "$(basename "${initpath}" 2> /dev/null)" = "systemd" ]; then + run ${ROOTCMD} systemctl restart netdata + elif [ -f /etc/init.d/netdata ]; then + run ${ROOTCMD} /etc/init.d/netdata restart + fi + ;; + esac + fi +} + +confirm_install_prefix() { + if [ -n "${INSTALL_PREFIX}" ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then + fatal "The \`--install\` option is only supported together with the \`--only-build\` option." F0204 + fi + + if [ -n "${INSTALL_PREFIX}" ]; then + NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install ${INSTALL_PREFIX}" + else + case "${SYSTYPE}" in + Darwin) + INSTALL_PREFIX="/usr/local/netdata" + NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install-no-prefix ${INSTALL_PREFIX}" + ;; + FreeBSD) + INSTALL_PREFIX="/usr/local" + NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --install-no-prefix ${INSTALL_PREFIX}" + ;; + esac + fi +} + +# ====================================================================== +# Claiming support code + +check_claim_opts() { +# shellcheck disable=SC2235,SC2030 + if [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_ROOMS}" ]; then + fatal "Invalid claiming options, claim rooms may only be specified when a token and URL are specified." F0204 + elif [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_EXTRA}" ]; then + fatal "Invalid claiming options, a claiming token must be specified." F0204 + elif [ "${NETDATA_DISABLE_CLOUD}" -eq 1 ] && [ -n "${NETDATA_CLAIM_TOKEN}" ]; then + fatal "Cloud explicitly disabled, but automatic claiming requested. Either enable Netdata Cloud, or remove the --claim-* options." F0204 + fi +} + +claim() { + progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}" + if [ -z "${INSTALL_PREFIX}" ]; then + NETDATA_CLAIM_PATH=/usr/sbin/netdata-claim.sh + elif [ "${INSTALL_PREFIX}" = "/opt/netdata" ]; then + NETDATA_CLAIM_PATH="/opt/netdata/bin/netdata-claim.sh" + else + NETDATA_CLAIM_PATH="${INSTALL_PREFIX}/netdata/usr/sbin/netdata-claim.sh" + fi + + if ! pgrep netdata > /dev/null; then + NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -daemon-not-running" + fi + + # shellcheck disable=SC2086 + if ${ROOTCMD} "${NETDATA_CLAIM_PATH}" -token="${NETDATA_CLAIM_TOKEN}" -rooms="${NETDATA_CLAIM_ROOMS}" -url="${NETDATA_CLAIM_URL}" ${NETDATA_CLAIM_EXTRA}; then + progress "Successfully claimed node" + else + warning "Unable to claim node, you must do so manually." + if [ -z "${NETDATA_NEW_INSTALL}" ]; then + cleanup + trap - EXIT + exit 1 + fi + fi +} + +# ====================================================================== +# Native package install code. + +# Check for an already installed package with a given name. +pkg_installed() { + case "${DISTRO_COMPAT_NAME}" in + debian|ubuntu) + dpkg -l "${1}" > /dev/null 2>&1 + return $? + ;; + centos|fedora|opensuse) + rpm -q "${1}" > /dev/null 2>&1 + return $? + ;; + *) + return 1 + ;; + esac +} + +# Check for the existence of a usable netdata package in the repo. +netdata_avail_check() { + case "${DISTRO_COMPAT_NAME}" in + debian|ubuntu) + env DEBIAN_FRONTEND=noninteractive apt-cache policy netdata | grep -q packagecloud.io/netdata/netdata; + return $? + ;; + centos|fedora) + # shellcheck disable=SC2086 + ${pm_cmd} search -v netdata | grep -qE 'Repo *: netdata(-edge)?$' + return $? + ;; + opensuse) + zypper packages -r "$(zypper repos | grep -E 'netdata |netdata-edge ' | cut -f 1 -d '|' | tr -d ' ')" | grep -E 'netdata ' + return $? + ;; + *) + return 1 + ;; + esac +} + +# Check for any distro-specific dependencies we know we need. +check_special_native_deps() { + if [ "${DISTRO_COMPAT_NAME}" = "centos" ] && [ "${SYSVERSION}" = "7" ]; then + progress "Checking for libuv availability." + # shellcheck disable=SC2086 + if ${pm_cmd} search ${interactive_opts} -v libuv | grep -q "No matches found"; then + progress "libv not found, checking for EPEL availability." + # shellcheck disable=SC2086 + if ${pm_cmd} search ${interactive_opts} -v epel-release | grep -q "No matches found"; then + warning "Unable to find a suitable source for libuv, cannot install on this system." + return 1 + else + progress "EPEL is available, attempting to install so that required dependencies are available." + + # shellcheck disable=SC2086 + if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} epel-release; then + warning "Failed to install EPEL." + return 1 + fi + fi + else + return 0 + fi + fi +} + +try_package_install() { + if [ -z "${DISTRO}" ]; then + warning "Unable to determine Linux distribution for native packages." + return 1 + fi + + progress "Attempting to install using native packages..." + + if [ "${RELEASE_CHANNEL}" = "nightly" ]; then + release="-edge" + else + release="" + fi + + if [ "${INTERACTIVE}" = "0" ]; then + interactive_opts="-y" + env="DEBIAN_FRONTEND=noninteractive" + else + interactive_opts="" + env="" + fi + + case "${DISTRO_COMPAT_NAME}" in + debian) + needs_early_refresh=1 + pm_cmd="apt-get" + repo_subcmd="update" + repo_prefix="debian/${SYSCODENAME}" + pkg_type="deb" + pkg_suffix="_all" + pkg_vsep="_" + pkg_install_opts="${interactive_opts}" + repo_update_opts="${interactive_opts}" + uninstall_subcmd="uninstall" + INSTALL_TYPE="binpkg-deb" + ;; + ubuntu) + needs_early_refresh=1 + pm_cmd="apt-get" + repo_subcmd="update" + repo_prefix="ubuntu/${SYSCODENAME}" + pkg_type="deb" + pkg_suffix="_all" + pkg_vsep="_" + pkg_install_opts="${interactive_opts}" + repo_update_opts="${interactive_opts}" + uninstall_subcmd="uninstall" + INSTALL_TYPE="binpkg-deb" + ;; + centos) + if command -v dnf > /dev/null; then + pm_cmd="dnf" + repo_subcmd="makecache" + else + pm_cmd="yum" + fi + repo_prefix="el/${SYSVERSION}" + pkg_type="rpm" + pkg_suffix=".noarch" + pkg_vsep="-" + pkg_install_opts="${interactive_opts}" + repo_update_opts="${interactive_opts}" + uninstall_subcmd="remove" + INSTALL_TYPE="binpkg-rpm" + ;; + fedora) + if command -v dnf > /dev/null; then + pm_cmd="dnf" + repo_subcmd="makecache" + else + pm_cmd="yum" + fi + repo_prefix="fedora/${SYSVERSION}" + pkg_type="rpm" + pkg_suffix=".noarch" + pkg_vsep="-" + pkg_install_opts="${interactive_opts}" + repo_update_opts="${interactive_opts}" + uninstall_subcmd="remove" + INSTALL_TYPE="binpkg-rpm" + ;; + opensuse) + pm_cmd="zypper" + repo_subcmd="--gpg-auto-import-keys refresh" + repo_prefix="opensuse/${SYSVERSION}" + pkg_type="rpm" + pkg_suffix=".noarch" + pkg_vsep="-" + pkg_install_opts="${interactive_opts} --allow-unsigned-rpm" + repo_update_opts="" + uninstall_subcmd="remove" + INSTALL_TYPE="binpkg-rpm" + ;; + *) + warning "We do not provide native packages for ${DISTRO}." + return 2 + ;; + esac + + repoconfig_name="netdata-repo${release}" + repoconfig_file="${repoconfig_name}${pkg_vsep}${REPOCONFIG_VERSION}${pkg_suffix}.${pkg_type}" + repoconfig_url="${REPOCONFIG_URL_PREFIX}/${repo_prefix}/${repoconfig_file}/download.${pkg_type}" + + if ! pkg_installed "${repoconfig_name}"; then + progress "Downloading repository configuration package." + if ! download "${repoconfig_url}" "${tmpdir}/${repoconfig_file}"; then + warning "Failed to download repository configuration package." + return 2 + fi + + if [ -n "${needs_early_refresh}" ]; then + progress "Updating repository metadata." + # shellcheck disable=SC2086 + if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then + warning "Failed to refresh repository metadata." + return 2 + fi + fi + + progress "Installing repository configuration package." + # shellcheck disable=SC2086 + if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} "${tmpdir}/${repoconfig_file}"; then + warning "Failed to install repository configuration package." + return 2 + fi + + if [ -n "${repo_subcmd}" ]; then + progress "Updating repository metadata." + # shellcheck disable=SC2086 + if ! run ${ROOTCMD} env ${env} ${pm_cmd} ${repo_subcmd} ${repo_update_opts}; then + fatal "Failed to update repository metadata." F0205 + fi + fi + else + progress "Repository configuration is already present, attempting to install netdata." + fi + + if ! check_special_native_deps; then + warning "Could not find secondary dependencies ${DISTRO} on ${SYSARCH}." + if [ -z "${NO_CLEANUP}" ]; then + progress "Attempting to uninstall repository configuration package." + # shellcheck disable=SC2086 + run ${ROOTCMD} env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}" + fi + return 2 + fi + + progress "Checking for usable Netdata package." + if ! netdata_avail_check "${DISTRO_COMPAT_NAME}"; then + warning "Could not find a usable native package for ${DISTRO} on ${SYSARCH}." + if [ -z "${NO_CLEANUP}" ]; then + progress "Attempting to uninstall repository configuration package." + # shellcheck disable=SC2086 + run ${ROOTCMD} env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}" + fi + return 2 + fi + + if [ "${NETDATA_DISABLE_TELEMETRY}" -eq 1 ]; then + run ${ROOTCMD} mkdir -p "/etc/netdata" + run ${ROOTCMD} touch "/etc/netdata/.opt-out-from-anonymous-statistics" + fi + + progress "Installing Netdata package." + # shellcheck disable=SC2086 + if ! run ${ROOTCMD} env ${env} ${pm_cmd} install ${pkg_install_opts} netdata; then + warning "Failed to install Netdata package." + if [ -z "${NO_CLEANUP}" ]; then + progress "Attempting to uninstall repository configuration package." + # shellcheck disable=SC2086 + run ${ROOTCMD} env ${env} ${pm_cmd} ${uninstall_subcmd} ${pkg_install_opts} "${repoconfig_name}" + fi + return 2 + fi +} + +# ====================================================================== +# Static build install code + +set_static_archive_urls() { + if [ "${RELEASE_CHANNEL}" = "stable" ]; then + latest="$(get_redirect "https://github.com/netdata/netdata/releases/latest")" + export NETDATA_STATIC_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/${latest}/netdata-${SYSARCH}-${latest}.gz.run" + export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/${latest}/sha256sums.txt" + else + export NETDATA_STATIC_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-latest.gz.run" + export NETDATA_STATIC_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt" + fi +} + +try_static_install() { + set_static_archive_urls "${RELEASE_CHANNEL}" + progress "Downloading static netdata binary: ${NETDATA_STATIC_ARCHIVE_URL}" + + if ! download "${NETDATA_STATIC_ARCHIVE_URL}" "${tmpdir}/netdata-${SYSARCH}-latest.gz.run"; then + warning "Unable to download static build archive for ${SYSARCH}." + return 2 + fi + + if ! download "${NETDATA_STATIC_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt"; then + fatal "Unable to fetch checksums to verify static build archive." F0206 + fi + + if ! grep "netdata-${SYSARCH}-latest.gz.run" "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then + fatal "Static binary checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0207 + fi + + if [ "${INTERACTIVE}" -eq 0 ]; then + opts="${opts} --accept" + fi + + progress "Installing netdata" + # shellcheck disable=SC2086 + if ! run ${ROOTCMD} sh "${tmpdir}/netdata-${SYSARCH}-latest.gz.run" ${opts} -- ${NETDATA_AUTO_UPDATES:+--auto-update} ${NETDATA_INSTALLER_OPTIONS}; then + warning "Failed to install static build of Netdata on ${SYSARCH}." + run rm -rf /opt/netdata + return 2 + fi + + install_type_file="/opt/netdata/etc/netdata/.install-type" + if [ -f "${install_type_file}" ]; then + ${ROOTCMD} sh -c "cat \"${install_type_file}\" > \"${tmpdir}/install-type\"" + ${ROOTCMD} chown "$(id -u)":"$(id -g)" "${tmpdir}/install-type" + # shellcheck disable=SC1091 + . "${tmpdir}/install-type" + cat > "${tmpdir}/install-type" <<- EOF + INSTALL_TYPE='kickstart-static' + PREBUILT_ARCH='${PREBUILT_ARCH}' + EOF + ${ROOTCMD} chown netdata:netdata "${tmpdir}/install-type" + ${ROOTCMD} cp "${tmpdir}/install-type" "${install_type_file}" + fi +} + +# ====================================================================== +# Local build install code + +set_source_archive_urls() { + if [ "$1" = "stable" ]; then + latest="$(get_redirect "https://github.com/netdata/netdata/releases/latest")" + export NETDATA_SOURCE_ARCHIVE_URL="https://github.com/netdata/netdata/releases/download/${latest}/netdata-${latest}.tar.gz" + export NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/${latest}/sha256sums.txt" + else + export NETDATA_SOURCE_ARCHIVE_URL="${NETDATA_TARBALL_BASEURL}/netdata-latest.tar.gz" + export NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL="${NETDATA_TARBALL_BASEURL}/sha256sums.txt" + fi +} + +install_local_build_dependencies() { + bash="$(command -v bash 2> /dev/null)" + + if [ -z "${bash}" ] || [ ! -x "${bash}" ]; then + warning "Unable to find a usable version of \`bash\` (required for local build)." + return 1 + fi + + progress "Fetching script to detect required packages..." + download "${PACKAGES_SCRIPT}" "${tmpdir}/install-required-packages.sh" + + if [ ! -s "${tmpdir}/install-required-packages.sh" ]; then + warning "Downloaded dependency installation script is empty." + else + progress "Running downloaded script to detect required packages..." + + if [ "${INTERACTIVE}" -eq 0 ]; then + opts="--dont-wait --non-interactive" + fi + + if [ "${SYSTYPE}" = "Darwin" ]; then + sudo="" + else + sudo="${ROOTCMD}" + fi + + # shellcheck disable=SC2086 + if ! run ${sudo} "${bash}" "${tmpdir}/install-required-packages.sh" ${opts} netdata; then + warning "It failed to install all the required packages, but installation might still be possible." + fi + fi +} + +build_and_install() { + progress "Building netdata" + + echo "INSTALL_TYPE='kickstart-build'" > system/.install-type + + opts="${NETDATA_INSTALLER_OPTIONS}" + + if [ "${INTERACTIVE}" -eq 0 ]; then + opts="${opts} --dont-wait" + fi + + if [ "${NETDATA_AUTO_UPDATES}" -eq 1 ]; then + opts="${opts} --auto-update" + fi + + if [ "${RELEASE_CHANNEL}" = "stable" ]; then + opts="${opts} --stable-channel" + fi + + if [ "${NETDATA_REQUIRE_CLOUD}" -eq 1 ]; then + opts="${opts} --require-cloud" + elif [ "${NETDATA_DISABLE_CLOUD}" -eq 1 ]; then + opts="${opts} --disable-cloud" + fi + + # shellcheck disable=SC2086 + run ${ROOTCMD} ./netdata-installer.sh ${opts} + + case $? in + 1) + fatal "netdata-installer.sh exited with error" F0007 + ;; + 2) + fatal "Insufficient RAM to install netdata" F0008 + ;; + esac +} + +try_build_install() { + if ! install_local_build_dependencies; then + return 1 + fi + + set_source_archive_urls "${RELEASE_CHANNEL}" + + download "${NETDATA_SOURCE_ARCHIVE_CHECKSUM_URL}" "${tmpdir}/sha256sum.txt" + download "${NETDATA_SOURCE_ARCHIVE_URL}" "${tmpdir}/netdata-latest.tar.gz" + + if ! grep netdata-latest.tar.gz "${tmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then + fatal "Tarball checksum validation failed. Usually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0005 + fi + + run tar -xf "${tmpdir}/netdata-latest.tar.gz" -C "${tmpdir}" + rm -rf "${tmpdir}/netdata-latest.tar.gz" > /dev/null 2>&1 + cd "$(find "${tmpdir}" -mindepth 1 -maxdepth 1 -type d -name netdata-)" || fatal "Cannot cd to netdata source tree" F0006 + + if [ -x netdata-installer.sh ]; then + build_and_install || return 1 + else + # This case is needed because some platforms produce an extra directory on the source tarball extraction. + if [ "$(find . -mindepth 1 -maxdepth 1 -type d | wc -l)" -eq 1 ] && [ -x "$(find . -mindepth 1 -maxdepth 1 -type d)/netdata-installer.sh" ]; then + cd "$(find . -mindepth 1 -maxdepth 1 -type d)" && build_and_install || return 1 + else + fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh). Leaving all files in ${tmpdir}" F0009 + fi + fi +} + +# ====================================================================== +# Per system-type install logic + +install_on_linux() { + if [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ]; then + SELECTED_INSTALL_METHOD="native" + try_package_install + + case "$?" in + 0) + NETDATA_INSTALL_SUCCESSFUL=1 + ;; + 1) + fatal "Unable to install on this system." F0300 + ;; + 2) + if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then + fatal "Could not install native binary packages." F0301 + else + warning "Could not install native binary packages, falling back to alternative installation method." + fi + ;; + esac + fi + + if [ "${NETDATA_ONLY_NATIVE}" -ne 1 ] && [ "${NETDATA_ONLY_BUILD}" -ne 1 ] && [ -z "${NETDATA_INSTALL_SUCCESSFUL}" ]; then + SELECTED_INSTALL_METHOD="static" + INSTALL_TYPE="kickstart-static" + try_static_install + + case "$?" in + 0) + NETDATA_INSTALL_SUCCESSFUL=1 + INSTALL_PREFIX="/opt/netdata" + ;; + 1) + fatal "Unable to install on this system." F0302 + ;; + 2) + if [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then + fatal "Could not install static build." F0303 + else + warning "Could not install static build, falling back to alternative installation method." + fi + ;; + esac + fi + + if [ "${NETDATA_ONLY_NATIVE}" -ne 1 ] && [ "${NETDATA_ONLY_STATIC}" -ne 1 ] && [ -z "${NETDATA_INSTALL_SUCCESSFUL}" ]; then + SELECTED_INSTALL_METHOD="build" + INSTALL_TYPE="kickstart-build" + try_build_install + + case "$?" in + 0) + NETDATA_INSTALL_SUCCESSFUL=1 + ;; + *) + fatal "Unable to install on this system." F0304 + ;; + esac + fi +} + +install_on_macos() { + if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then + fatal "User requested native package, but native packages are not available for macOS. Try installing without \`--only-native\` option." F0305 + elif [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then + fatal "User requested static build, but static builds are not available for macOS. Try installing without \`--only-static\` option." F0306 + else + SELECTED_INSTALL_METHOD="build" + INSTALL_TYPE="kickstart-build" + try_build_install + + case "$?" in + 0) + NETDATA_INSTALL_SUCCESSFUL=1 + ;; + *) + fatal "Unable to install on this system." F0307 + ;; + esac + fi +} + +install_on_freebsd() { + if [ "${NETDATA_ONLY_NATIVE}" -eq 1 ]; then + fatal "User requested native package, but native packages are not available for FreeBSD. Try installing without \`--only-native\` option." F0308 + elif [ "${NETDATA_ONLY_STATIC}" -eq 1 ]; then + fatal "User requested static build, but static builds are not available for FreeBSD. Try installing without \`--only-static\` option." F0309 + else + SELECTED_INSTALL_METHOD="build" + INSTALL_TYPE="kickstart-build" + try_build_install + + case "$?" in + 0) + NETDATA_INSTALL_SUCCESSFUL=1 + ;; + *) + fatal "Unable to install on this system." F030A + ;; + esac + fi +} + +# ====================================================================== +# Main program + +setup_terminal || echo > /dev/null + +while [ -n "${1}" ]; do + case "${1}" in + "--help") + usage + cleanup + trap - EXIT + exit 0 + ;; + "--no-cleanup") NO_CLEANUP=1 ;; + "--dont-wait"|"--non-interactive") INTERACTIVE=0 ;; + "--interactive") INTERACTIVE=1 ;; + "--stable-channel") RELEASE_CHANNEL="stable" ;; + "--no-updates") NETDATA_AUTO_UPDATES=0 ;; + "--auto-update") NETDATA_AUTO_UPDATES="1" ;; + "--reinstall") NETDATA_REINSTALL=1 ;; + "--reinstall-even-if-unsafe") NETDATA_UNSAFE_REINSTALL=1 ;; + "--claim-only") NETDATA_CLAIM_ONLY=1 ;; + "--disable-cloud") + NETDATA_DISABLE_CLOUD=1 + NETDATA_REQUIRE_CLOUD=0 + ;; + "--require-cloud") + NETDATA_DISABLE_CLOUD=0 + NETDATA_REQUIRE_CLOUD=1 + ;; + "--dont-start-it") + NETDATA_NO_START=1 + NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --dont-start-it" + ;; + "--disable-telemetry") + NETDATA_DISABLE_TELEMETRY="1" + NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --disable-telemetry" + ;; + "--install") + INSTALL_PREFIX="${2}" + shift 1 + ;; + "--native-only") + NETDATA_ONLY_NATIVE=1 + NETDATA_ONLY_STATIC=0 + NETDATA_ONLY_BUILD=0 + SELECTED_INSTALL_METHOD="native" + ;; + "--static-only") + NETDATA_ONLY_STATIC=1 + NETDATA_ONLY_NATIVE=0 + NETDATA_ONLY_BUILD=0 + SELECTED_INSTALL_METHOD="static" + ;; + "--build-only") + NETDATA_ONLY_BUILD=1 + NETDATA_ONLY_NATIVE=0 + NETDATA_ONLY_STATIC=0 + SELECTED_INSTALL_METHOD="build" + ;; + "--claim-token") + NETDATA_CLAIM_TOKEN="${2}" + shift 1 + ;; + "--claim-rooms") + NETDATA_CLAIM_ROOMS="${2}" + shift 1 + ;; + "--claim-url") + NETDATA_CLAIM_URL="${2}" + shift 1 + ;; + "--claim-*") + optname="$(echo "${1}" | cut -d '-' -f 4-)" + case "${optname}" in + id|proxy|user|hostname) + NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname} ${2}" + shift 1 + ;; + verbose|insecure|noproxy|noreload|daemon-not-running) + NETDATA_CLAIM_EXTRA="${NETDATA_CLAIM_EXTRA} -${optname}" + ;; + *) + warning "Ignoring unrecognized claiming option ${optname}" + ;; + esac + ;; + *) + warning "Passing unrecognized option '${1}' to installer script. If this is intended, please add it to \$NETDATA_INSTALLER_OPTIONS instead." + NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} ${1}" + ;; + esac + shift 1 +done + +check_claim_opts +confirm_root_support +get_system_info +confirm_install_prefix + +tmpdir="$(create_tmp_directory)" +progress "Using ${tmpdir} as a temporary directory." +cd "${tmpdir}" || exit 1 + +handle_existing_install + +case "${SYSTYPE}" in + Linux) install_on_linux ;; + Darwin) install_on_macos ;; + FreeBSD) install_on_freebsd ;; +esac + +if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then + claim +elif [ "${NETDATA_DISABLE_CLOUD}" -eq 1 ]; then + soft_disable_cloud +fi + +telemetry_event INSTALL_SUCCESS "" "" +cleanup +trap - EXIT diff --git a/packaging/installer/kickstart-static64.sh b/packaging/installer/kickstart-static64.sh index 36aca54d7..ec1800a61 100755 --- a/packaging/installer/kickstart-static64.sh +++ b/packaging/installer/kickstart-static64.sh @@ -206,6 +206,33 @@ safe_sha256sum() { fi } +mark_install_type() { + install_type_file="/opt/netdata/etc/netdata/.install-type" + if [ -f "${install_type_file}" ]; then + # shellcheck disable=SC1090 + . "${install_type_file}" + cat > "${TMPDIR}/install-type" <<- EOF + INSTALL_TYPE='kickstart-static' + PREBUILT_ARCH='${PREBUILT_ARCH}' + EOF + ${sudo} chown netdata:netdata "${TMPDIR}/install-type" + ${sudo} cp "${TMPDIR}/install-type" "${install_type_file}" + fi +} + +claim() { + progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}" + NETDATA_CLAIM_PATH=/opt/netdata/bin/netdata-claim.sh + + if ${sudo} "${NETDATA_CLAIM_PATH}" -token=${NETDATA_CLAIM_TOKEN} -rooms=${NETDATA_CLAIM_ROOMS} -url=${NETDATA_CLAIM_URL} ${NETDATA_CLAIM_EXTRA}; then + progress "Successfully claimed node" + return 0 + else + run_failed "Unable to claim node, you must do so manually." + return 1 + fi +} + # ---------------------------------------------------------------------------- umask 022 @@ -326,7 +353,10 @@ if [ -n "$ndpath" ] ; then if [ -r "${ndprefix}/etc/netdata/.environment" ] ; then ndstatic="$(grep IS_NETDATA_STATIC_BINARY "${ndprefix}/etc/netdata/.environment" | cut -d "=" -f 2 | tr -d \")" if [ -z "${NETDATA_REINSTALL}" ] && [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE}" ] ; then - if [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then + if [ -n "${NETDATA_CLAIM_TOKEN}" ] ; then + claim + exit $? + elif [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then progress "Attempting to update existing install instead of creating a new one" if run ${sudo} "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" --not-running-from-cron ; then progress "Updated existing install at ${ndpath}" @@ -353,7 +383,10 @@ if [ -n "$ndpath" ] ; then fi else progress "Existing install appears to be handled manually or through the system package manager." - if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then + if [ -n "${NETDATA_CLAIM_TOKEN}" ] ; then + claim + exit $? + elif [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue." exit 1 else @@ -386,6 +419,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" @@ -400,12 +435,5 @@ fi # -------------------------------------------------------------------------------------------------------------------- if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then - progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}" - NETDATA_CLAIM_PATH=/opt/netdata/bin/netdata-claim.sh - - if "${NETDATA_CLAIM_PATH}" -token=${NETDATA_CLAIM_TOKEN} -rooms=${NETDATA_CLAIM_ROOMS} -url=${NETDATA_CLAIM_URL} ${NETDATA_CLAIM_EXTRA}; then - progress "Successfully claimed node" - else - run_failed "Unable to claim node, you must do so manually." - fi + claim fi diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh index 3c90cc816..2fa762968 100755 --- a/packaging/installer/kickstart.sh +++ b/packaging/installer/kickstart.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash # SPDX-License-Identifier: GPL-3.0-or-later # # Run me with: @@ -16,6 +16,7 @@ # --local-files set the full path of the desired tarball to run install with # --allow-duplicate-install do not bail if we detect a duplicate install # --reinstall if an existing install would be updated, reinstall instead +# --disable-telemetry opt out of anonymous statistics # --claim-token specify a token to use for claiming the newly installed instance # --claim-url specify a URL to use for claiming the newly installed isntance # --claim-rooms specify a list of rooms to claim the newly installed instance to @@ -43,6 +44,10 @@ PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata/master/packag # Netdata Tarball Base URL (defaults to our Google Storage Bucket) [ -z "$NETDATA_TARBALL_BASEURL" ] && NETDATA_TARBALL_BASEURL=https://storage.googleapis.com/netdata-nightlies +TELEMETRY_URL="https://posthog.netdata.cloud/capture/" +TELEMETRY_API_KEY="${NETDATA_POSTHOG_API_KEY:-mqkwGT0JNFqO-zX2t0mW6Tec9yooaVu7xCBlXtHnt5Y}" +KICKSTART_OPTIONS="${*}" + # --------------------------------------------------------------------------------------------------------------------- # library functions copied from packaging/installer/functions.sh @@ -76,8 +81,93 @@ setup_terminal() { setup_terminal || echo > /dev/null # ----------------------------------------------------------------------------- +telemetry_event() { + if [ -n "${NETDATA_DISABLE_TELEMETRY}" ]; then + return 0 + fi + + if [ -e "/etc/os-release" ]; then + eval "$(grep -E "^(NAME|ID|ID_LIKE|VERSION|VERSION_ID)=" < /etc/os-release | sed 's/^/HOST_/')" + fi + + if [ -z "${HOST_NAME}" ] || [ -z "${HOST_VERSION}" ] || [ -z "${HOST_ID}" ]; then + if [ -f "/etc/lsb-release" ]; then + DISTRIB_ID="unknown" + DISTRIB_RELEASE="unknown" + DISTRIB_CODENAME="unknown" + eval "$(grep -E "^(DISTRIB_ID|DISTRIB_RELEASE|DISTRIB_CODENAME)=" < /etc/lsb-release)" + if [ -z "${HOST_NAME}" ]; then HOST_NAME="${DISTRIB_ID}"; fi + if [ -z "${HOST_VERSION}" ]; then HOST_VERSION="${DISTRIB_RELEASE}"; fi + if [ -z "${HOST_ID}" ]; then HOST_ID="${DISTRIB_CODENAME}"; fi + fi + fi + + KERNEL_NAME="$(uname -s)" + + if [ "${KERNEL_NAME}" = FreeBSD ]; then + TOTAL_RAM="$(sysctl -n hw.physmem)" + elif [ "${KERNEL_NAME}" = Darwin ]; then + TOTAL_RAM="$(sysctl -n hw.memsize)" + elif [ -r /proc/meminfo ]; then + TOTAL_RAM="$(grep -F MemTotal /proc/meminfo | cut -f 2 -d ':' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | cut -f 1 -d ' ')" + TOTAL_RAM="$((TOTAL_RAM * 1024))" + fi + + if [ -f /etc/machine-id ]; then + DISTINCT_ID="$(cat /etc/machine-id)" + elif command -v uuidgen 2> /dev/null; then + DISTINCT_ID="$(uuidgen)" + else + DISTINCT_ID="null" + fi + + REQ_BODY="$(cat << EOF +{ + "api_key": "${TELEMETRY_API_KEY}", + "event": "${1}", + "properties": { + "distinct_id": "${DISTINCT_ID}", + "event_source": "agent installer", + "\$current_url": "agent installer", + "\$pathname": "netdata-installer", + "\$host": "installer.netdata.io", + "\$ip": "127.0.0.1", + "script_variant": "legacy-kickstart", + "error_code": "${2}", + "error_message": "${3}", + "install_options": "${KICKSTART_OPTIONS}", + "netdata_release_channel": "${RELEASE_CHANNEL:-null}", + "netdata_install_type": "kickstart-build", + "host_os_name": "${HOST_NAME:-unknown}", + "host_os_id": "${HOST_ID:-unknown}", + "host_os_id_like": "${HOST_ID_LIKE:-unknown}", + "host_os_version": "${HOST_VERSION:-unknown}", + "host_os_version_id": "${HOST_VERSION_ID:-unknown}", + "system_kernel_name": "${KERNEL_NAME}", + "system_kernel_version": "$(uname -r)", + "system_architecture": "$(uname -m)", + "system_total_ram": "${TOTAL_RAM:-unknown}" + } +} +EOF +)" + +if [ -n "$(command -v curl 2> /dev/null)" ]; then + curl --silent -o /dev/null --write-out '%{http_code}' -X POST --max-time 2 --header "Content-Type: application/json" -d "${REQ_BODY}" "${TELEMETRY_URL}" +else + wget -q -O - --no-check-certificate \ + --server-response \ + --method POST \ + --timeout=1 \ + --header 'Content-Type: application/json' \ + --body-data "${REQ_BODY}" \ + "${TELEMETRY_URL}" 2>&1 | awk '/^ HTTP/{print $2}' +fi +} + fatal() { - printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n" + printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${1} \n\n" + telemetry_event "INSTALL_FAILED" "${1}" "${2}" exit 1 } @@ -142,15 +232,10 @@ run() { return ${ret} } -fatal() { - printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n" - exit 1 -} - warning() { printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} WARNING ${TPUT_RESET} ${*} \n\n" if [ "${INTERACTIVE}" = "0" ]; then - fatal "Stopping due to non-interactive mode. Fix the issue or retry installation in an interactive mode." + fatal "Stopping due to non-interactive mode. Fix the issue or retry installation in an interactive mode." F0001 else read -r -p "Press ENTER to attempt netdata installation > " progress "OK, let's give it a try..." @@ -200,11 +285,11 @@ download() { url="${1}" dest="${2}" if command -v curl > /dev/null 2>&1; then - run curl -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}" + run curl -q -sSL --connect-timeout 10 --retry 3 --output "${dest}" "${url}" || fatal "Cannot download ${url}" F0002 elif command -v wget > /dev/null 2>&1; then - run wget -T 15 -O "${dest}" "${url}" || fatal "Cannot download ${url}" + run wget -T 15 -O "${dest}" "${url}" || fatal "Cannot download ${url}" F0002 else - fatal "I need curl or wget to proceed, but neither is available on this system." + fatal "I need curl or wget to proceed, but neither is available on this system." F0003 fi } @@ -243,7 +328,7 @@ detect_bash4() { echo >&2 "No BASH is available on this system" return 1 elif [ $((BASH_MAJOR_VERSION)) -lt 4 ]; then - echo >&2 "No BASH v4+ is available on this system (installed bash is v${BASH_MAJOR_VERSION}" + echo >&2 "No BASH v4+ is available on this system (installed bash is v${BASH_MAJOR_VERSION})" return 1 fi return 0 @@ -259,36 +344,32 @@ dependencies() { echo "Machine : ${MACHINE}" echo "BASH major version: ${BASH_MAJOR_VERSION}" - if [ "${OS}" != "GNU/Linux" ] && [ "${SYSTEM}" != "Linux" ]; then - warning "Cannot detect the packages to be installed on a ${SYSTEM} - ${OS} system." + bash="$(command -v bash 2> /dev/null)" + if ! detect_bash4 "${bash}"; then + warning "Cannot detect packages to be installed in this system, without BASH v4+." else - bash="$(command -v bash 2> /dev/null)" - if ! detect_bash4 "${bash}"; then - warning "Cannot detect packages to be installed in this system, without BASH v4+." - else - progress "Fetching script to detect required packages..." - if [ -n "${NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT}" ]; then - if [ -f "${NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT}" ]; then - run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT}" "${ndtmpdir}/install-required-packages.sh" - else - fatal "Invalid given dependency file, please check your --local-files parameter options and try again" - fi + progress "Fetching script to detect required packages..." + if [ -n "${NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT}" ]; then + if [ -f "${NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT}" ]; then + run cp "${NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT}" "${ndtmpdir}/install-required-packages.sh" else - download "${PACKAGES_SCRIPT}" "${ndtmpdir}/install-required-packages.sh" + fatal "Invalid given dependency file, please check your --local-files parameter options and try again" F1001 fi + else + download "${PACKAGES_SCRIPT}" "${ndtmpdir}/install-required-packages.sh" + fi - if [ ! -s "${ndtmpdir}/install-required-packages.sh" ]; then - warning "Downloaded dependency installation script is empty." - else - progress "Running downloaded script to detect required packages..." - run ${sudo} "${bash}" "${ndtmpdir}/install-required-packages.sh" ${PACKAGES_INSTALLER_OPTIONS} - # shellcheck disable=SC2181 - if [ $? -ne 0 ]; then - warning "It failed to install all the required packages, but installation might still be possible." - fi + if [ ! -s "${ndtmpdir}/install-required-packages.sh" ]; then + warning "Downloaded dependency installation script is empty." + else + progress "Running downloaded script to detect required packages..." + run ${sudo} "${bash}" "${ndtmpdir}/install-required-packages.sh" ${PACKAGES_INSTALLER_OPTIONS} + # shellcheck disable=SC2181 + if [ $? -ne 0 ]; then + warning "It failed to install all the required packages, but installation might still be possible." fi - fi + fi } @@ -300,7 +381,24 @@ safe_sha256sum() { elif command -v shasum > /dev/null 2>&1; then shasum -a 256 "$@" else - fatal "I could not find a suitable checksum binary to use" + fatal "I could not find a suitable checksum binary to use" F0004 + fi +} + +claim() { + progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}" + if [ -z "${NETDATA_PREFIX}" ] ; then + NETDATA_CLAIM_PATH=/usr/sbin/netdata-claim.sh + else + NETDATA_CLAIM_PATH="${NETDATA_PREFIX}/netdata/usr/sbin/netdata-claim.sh" + fi + + if ${sudo} "${NETDATA_CLAIM_PATH}" -token=${NETDATA_CLAIM_TOKEN} -rooms=${NETDATA_CLAIM_ROOMS} -url=${NETDATA_CLAIM_URL} ${NETDATA_CLAIM_EXTRA}; then + progress "Successfully claimed node" + return 0 + else + run_failed "Unable to claim node, you must do so manually." + return 1 fi } @@ -361,33 +459,37 @@ while [ -n "${1}" ]; do NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --disable-cloud" NETDATA_DISABLE_CLOUD=1 ;; + "--disable-telemetry") + NETDATA_INSTALLER_OPTIONS="${NETDATA_INSTALLER_OPTIONS} --disable-telemetry" + NETDATA_DISABLE_TELEMETRY=1 + ;; "--local-files") if [ -z "${2}" ]; then - fatal "Missing netdata: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" + fatal "Missing netdata: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" F1002 fi export NETDATA_LOCAL_TARBALL_OVERRIDE="${2}" if [ -z "${3}" ]; then - fatal "Missing checksum file: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" + fatal "Missing checksum file: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" F1003 fi export NETDATA_LOCAL_TARBALL_OVERRIDE_CHECKSUM="${3}" if [ -z "${4}" ]; then - fatal "Missing go.d tarball: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" + fatal "Missing go.d tarball: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" F1004 fi export NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN="${4}" if [ -z "${5}" ]; then - fatal "Missing go.d config tarball: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" + fatal "Missing go.d config tarball: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" F1005 fi export NETDATA_LOCAL_TARBALL_OVERRIDE_GO_PLUGIN_CONFIG="${5}" if [ -z "${6}" ]; then - fatal "Missing dependencies management scriptlet: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" + fatal "Missing dependencies management scriptlet: Option --local-files requires extra information. The desired tarball for netdata, the checksum, the go.d plugin tarball , the go.d plugin config tarball and the dependency management script, in this particular order" F1006 fi export NETDATA_LOCAL_TARBALL_OVERRIDE_DEPS_SCRIPT="${6}" @@ -413,7 +515,7 @@ if [ -n "${NETDATA_DISABLE_CLOUD}" ]; then fi fi -# shellcheck disable=SC2235,SC2030 +# shellcheck disable=SC2235,SC2030,SC2031 if ( [ -z "${NETDATA_CLAIM_TOKEN}" ] && [ -n "${NETDATA_CLAIM_URL}" ] ) || ( [ -n "${NETDATA_CLAIM_TOKEN}" ] && [ -z "${NETDATA_CLAIM_URL}" ] ); then run_failed "Invalid claiming options, both a claiming token and URL must be specified." exit 1 @@ -442,19 +544,24 @@ if [ -n "$ndpath" ] ; then if [ -r "${ndprefix}/etc/netdata/.environment" ] ; then ndstatic="$(grep IS_NETDATA_STATIC_BINARY "${ndprefix}/etc/netdata/.environment" | cut -d "=" -f 2 | tr -d \")" if [ -z "${NETDATA_REINSTALL}" ] && [ -z "${NETDATA_LOCAL_TARBALL_OVERRIDE}" ] ; then - if [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then + if [ -n "${NETDATA_CLAIM_TOKEN}" ] ; then + if [ "${ndprefix}" != '/' ] ; then + NETDATA_PREFIX="${ndprefix}" + fi + + claim + exit $? + elif [ -x "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" ] ; then progress "Attempting to update existing install instead of creating a new one" if run ${sudo} "${ndprefix}/usr/libexec/netdata/netdata-updater.sh" --not-running-from-cron ; then progress "Updated existing install at ${ndpath}" exit 0 else - fatal "Failed to update existing Netdata install" - exit 1 + fatal "Failed to update existing Netdata install" F0100 fi else if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] || [ "${ndstatic}" = "yes" ] ; then - fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue." - exit 1 + fatal "Existing installation detected which cannot be safely updated by this script. Refusing to continue." F0101 else progress "User explicitly requested duplicate install, proceeding." fi @@ -463,15 +570,20 @@ if [ -n "$ndpath" ] ; then if [ "${ndstatic}" = "no" ] ; then progress "User requested reinstall instead of update, proceeding." else - fatal "Existing install is a static install, please use kickstart-static64.sh instead." - exit 1 + fatal "Existing install is a static install. Please use kickstart-static64.sh instead." F0102 fi fi else progress "Existing install appears to be handled manually or through the system package manager." - if [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then - fatal "Existing installation detected which cannot be safely updated by this script, refusing to continue." - exit 1 + if [ -n "${NETDATA_CLAIM_TOKEN}" ] ; then + if [ "${ndprefix}" != '/' ] ; then + NETDATA_PREFIX="${ndprefix}" + fi + + claim + exit $? + elif [ -z "${NETDATA_ALLOW_DUPLICATE_INSTALL}" ] ; then + fatal "Existing installation detected which cannot be safely updated by this script. Refusing to continue." F0103 else progress "User explicitly requested duplicate install, proceeding." fi @@ -501,30 +613,39 @@ else fi if ! grep netdata-latest.tar.gz "${ndtmpdir}/sha256sum.txt" | safe_sha256sum -c - > /dev/null 2>&1; then - fatal "Tarball checksum validation failed. Stopping Netdata Agent installation and leaving tarball in ${ndtmpdir}.\nUsually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." + fatal "Tarball checksum validation failed. Stopping Netdata Agent installation and leaving tarball in ${ndtmpdir}.\nUsually this is a result of an older copy of the file being cached somewhere upstream and can be resolved by retrying in an hour." F0005 fi run tar -xf netdata-latest.tar.gz rm -rf netdata-latest.tar.gz > /dev/null 2>&1 -cd netdata-* || fatal "Cannot cd to netdata source tree" +cd netdata-* || fatal "Cannot cd to netdata source tree" F0006 # --------------------------------------------------------------------------------------------------------------------- # install netdata from source install() { progress "Installing netdata..." - run ${sudo} ./netdata-installer.sh ${NETDATA_UPDATES} ${NETDATA_INSTALLER_OPTIONS} || fatal "netdata-installer.sh exited with error" + run ${sudo} ./netdata-installer.sh ${NETDATA_UPDATES} ${NETDATA_INSTALLER_OPTIONS} + case $? in + 1) + fatal "netdata-installer.sh exited with error" F0007 + ;; + 2) + fatal "Insufficient RAM to install netdata" F0008 + ;; + esac if [ -d "${ndtmpdir}" ] && [ ! "${ndtmpdir}" = "/" ]; then run ${sudo} rm -rf "${ndtmpdir}" > /dev/null 2>&1 fi } 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 cd "$(find . -mindepth 1 -maxdepth 1 -type d)" && install "$@" else - fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh). Leaving all files in ${ndtmpdir}" + fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh). Leaving all files in ${ndtmpdir}" F0009 exit 1 fi fi @@ -532,16 +653,5 @@ fi # -------------------------------------------------------------------------------------------------------------------- if [ -n "${NETDATA_CLAIM_TOKEN}" ]; then - progress "Attempting to claim agent to ${NETDATA_CLAIM_URL}" - if [ -z "${NETDATA_PREFIX}" ] ; then - NETDATA_CLAIM_PATH=/usr/sbin/netdata-claim.sh - else - NETDATA_CLAIM_PATH="${NETDATA_PREFIX}/bin/netdata-claim.sh" - fi - - if "${NETDATA_CLAIM_PATH}" -token=${NETDATA_CLAIM_TOKEN} -rooms=${NETDATA_CLAIM_ROOMS} -url=${NETDATA_CLAIM_URL} ${NETDATA_CLAIM_EXTRA}; then - progress "Successfully claimed node" - else - run_failed "Unable to claim node, you must do so manually." - fi + claim fi diff --git a/packaging/installer/methods/kickstart-64.md b/packaging/installer/methods/kickstart-64.md index c390b873a..176d63ad4 100644 --- a/packaging/installer/methods/kickstart-64.md +++ b/packaging/installer/methods/kickstart-64.md @@ -71,18 +71,18 @@ your installation. Here are a few important parameters: kickstart run the process using those files. This option conflicts with the `--stable-channel` option. If you set this _and_ `--stable-channel`, Netdata will use the local files. -### Claim node to Netdata Cloud during installation +### Connect node to Netdata Cloud during installation -The `kickstart.sh` script accepts additional parameters to automatically [claim](/claim/README.md) your node to Netdata +The `kickstart.sh` script accepts additional parameters to automatically [connect](/claim/README.md) your node to Netdata Cloud immediately after installation. Find the `token` and `rooms` strings by [signing in to Netdata -Cloud](https://app.netdata.cloud/sign-in?cloudRoute=/spaces), then clicking on **Claim Nodes** in the [Spaces management +Cloud](https://app.netdata.cloud/sign-in?cloudRoute=/spaces), then clicking on **Connect Nodes** in the [Spaces management area](https://learn.netdata.cloud/docs/cloud/spaces#manage-spaces). - `--claim-token`: The unique token associated with your Space in Netdata Cloud. - `--claim-rooms`: A comma-separated list of tokens for each War Room this node should appear in. - `--claim-proxy`: Should take the form of `socks5[h]://[user:pass@]host:ip` for a SOCKS5 proxy, or - `http://[user:pass@]host:ip` for an HTTP(S) proxy.See [claiming through a - proxy](/claim/README.md#claim-through-a-proxy) for details. + `http://[user:pass@]host:ip` for an HTTP(S) proxy.See [connecting through a + proxy](/claim/README.md#connect-through-a-proxy) for details. - `--claim-url`: Defaults to `https://app.netdata.cloud`. For example: @@ -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" +[ "78461a3055aee03011a577a716e2dee5" = "$(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`. diff --git a/packaging/installer/methods/kickstart.md b/packaging/installer/methods/kickstart.md index e874d637d..7792989ee 100644 --- a/packaging/installer/methods/kickstart.md +++ b/packaging/installer/methods/kickstart.md @@ -11,15 +11,23 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/packaging/instal This page covers detailed instructions on using and configuring the automatic one-line installation script named `kickstart.sh`. -This method is fully automatic on all Linux distributions. To install Netdata from source, including all dependencies +This method is fully automatic on all Linux distributions and macOS environments. To install Netdata from source, including all dependencies required to connect to Netdata Cloud, and get _automatic nightly updates_, run the following as your normal user: +**Linux** + ```bash bash <(curl -Ss https://my-netdata.io/kickstart.sh) ``` -> See our [installation guide](../README.md) for details about [automatic updates](../README.md#automatic-updates) or -> [nightly vs. stable releases](../README.md#nightly-vs-stable-releases). +**macOS** + +```bash +bash <(curl -Ss https://my-netdata.io/kickstart.sh) --install /usr/local/ +``` + +> See our [installation guide](/packaging/installer/README.md) for details about [automatic updates](/packaging/installer/README.md#automatic-updates) or +> [nightly vs. stable releases](/packaging/installer/README.md#nightly-vs-stable-releases). ## What does `kickstart.sh` do? @@ -40,33 +48,39 @@ The `kickstart.sh` script does the following after being downloaded and run usin The `kickstart.sh` script passes all its parameters to `netdata-installer.sh`, which you can use to customize your installation. Here are a few important parameters: -- `--dont-wait`: Enable automated installs by not prompting for permission to install any required packages. -- `--dont-start-it`: Prevent the installer from starting Netdata automatically. -- `--stable-channel`: Automatically update only on the release of new major versions. -- `--nightly-channel`: Automatically update on every new nightly build. -- `--disable-telemetry`: Opt-out of [anonymous statistics](/docs/anonymous-statistics.md) we use to make - Netdata better. -- `--no-updates`: Prevent automatic updates of any kind. -- `--reinstall`: If an existing install is detected, reinstall instead of trying to update it. Note that this - cannot be used to change installation types. -- `--local-files`: Used for [offline installations](offline.md). Pass four file paths: the Netdata +- `--dont-wait`: Synonym for `--non-interactive` +- `--non-interactive`: Don’t prompt for anything and assume yes whenever possible. +- `--no-updates`: Disable automatic updates. +- `--stable-channel`: Use a stable build instead of a nightly build. +- `--reinstall`: If an existing install is found, reinstall instead of trying to update it in place. +- `--dont-start-it`: Don’t auto-start the daemon after installing. This parameter is not guaranteed to work. +- `--install`: Specify an alternative install prefix. +- `--disable-cloud`: For local builds, don’t build any of the cloud code at all. For native packages and static builds, + use runtime configuration to disable cloud support. +- `--auto-update-type`: Specify how auto-updates are to be scheduled, overriding auto-detection. +- `--disable-telemetry`: Disable anonymous statistics. +- `--local-files`: Used for [offline installations](offline.md). Pass four file paths: the Netdata tarball, the checksum file, the go.d plugin tarball, and the go.d plugin config tarball, to force kickstart run the process using those files. This option conflicts with the `--stable-channel` option. If you set this _and_ `--stable-channel`, Netdata will use the local files. +- `all`: Ask for all dependencies in the dependency handling script. + + > Note: The `all` and `--local-files` parameters are scheduled to be removed in a forthcoming update. + +### Connect node to Netdata Cloud during installation -### Claim node to Netdata Cloud during installation - -The `kickstart.sh` script accepts additional parameters to automatically [claim](/claim/README.md) your node to Netdata +The `kickstart.sh` script accepts additional parameters to automatically [connect](/claim/README.md) your node to Netdata Cloud immediately after installation. Find the `token` and `rooms` strings by [signing in to Netdata -Cloud](https://app.netdata.cloud/sign-in?cloudRoute=/spaces), then clicking on **Claim Nodes** in the [Spaces management +Cloud](https://app.netdata.cloud/sign-in?cloudRoute=/spaces), then clicking on **Connect Nodes** in the [Spaces management area](https://learn.netdata.cloud/docs/cloud/spaces#manage-spaces). -- `--claim-token`: The unique token associated with your Space in Netdata Cloud. -- `--claim-rooms`: A comma-separated list of tokens for each War Room this node should appear in. -- `--claim-proxy`: Should take the form of `socks5[h]://[user:pass@]host:ip` for a SOCKS5 proxy, or - `http://[user:pass@]host:ip` for an HTTP(S) proxy.See [claiming through a - proxy](/claim/README.md#claim-through-a-proxy) for details. -- `--claim-url`: Defaults to `https://app.netdata.cloud`. +- `--claim-token`: Specify a unique claiming token associated with your Space in Netdata Cloud to be used to connect to the node + after the install. +- `--claim-rooms`: Specify a comma-separated list of tokens for each War Room this node should appear in. +- `--claim-proxy`: Specify a proxy to use when connecting to the cloud in the form of + `socks5[h]://[user:pass@]host:ip` for a SOCKS5 proxy, or `http://[user:pass@]host:ip` for an HTTP(S) proxy. + See [connecting through a proxy](/claim/README.md#connect-through-a-proxy) for details. +- `--claim-url`: Specify a URL to use when connecting to the cloud. Defaults to `https://app.netdata.cloud`. For example: @@ -74,13 +88,15 @@ For example: bash <(curl -Ss https://my-netdata.io/kickstart.sh) --claim-token=TOKEN --claim-rooms=ROOM1,ROOM2 ``` +Please note that to run it you will either need to have root privileges or run it with the user that is running the agent, more details on the [Connect an agent without root privileges](#connect-an-agent-without-root-privileges) section. + ## Verify script integrity To use `md5sum` to verify the integrity of the `kickstart.sh` script you will download using the one-line command above, run the following: ```bash -[ "a708de3790fa39188babe71eb1639c66" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID" +[ "7e8b449ca44e49b7074b5b9d6022cbcc" = "$(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`. diff --git a/packaging/installer/methods/kubernetes.md b/packaging/installer/methods/kubernetes.md index f593765fc..f12850665 100644 --- a/packaging/installer/methods/kubernetes.md +++ b/packaging/installer/methods/kubernetes.md @@ -39,25 +39,34 @@ parent pod, and multiple child pods. You've now installed Netdata on your Kubernetes cluster. Next, it's time to opt-in and enable the powerful Kubernetes dashboards available in Netdata Cloud. -## Claim your Kubernetes cluster to Netdata Cloud +## Connect your Kubernetes cluster to Netdata Cloud To start [Kubernetes monitoring](https://learn.netdata.cloud/docs/cloud/visualize/kubernetes/), you must first -[claim](/claim/README.md) your Kubernetes cluster to [Netdata Cloud](https://app.netdata.cloud). Claiming securely +[connect](/claim/README.md) your Kubernetes cluster to [Netdata Cloud](https://app.netdata.cloud). The connection process securely connects your Kubernetes cluster to stream metrics data to Netdata Cloud, enabling Kubernetes-specific visualizations like the health map and time-series composite charts. -First, find your claiming script in Netdata Cloud by clicking on your Space's dropdown, then **Manage your Space**. -Click the **Nodes** tab to reveal the `netdata-claim.sh` script for your Space in Netdata Cloud. You need the `TOKEN` +### New installations + +First, find the script to run an `helm install` command. You can get it by clicking on your Space's dropdown, then **Manage your Space**. +Click the **Nodes** tab and select the environment your node is running, in this case **kubernetes**, to reveal the script for your Space in Netdata Cloud. You need the `TOKEN` and `ROOM` values. -Next, create a file called `override.yml`. +The script should be similar to: + +```bash +helm install netdata netdata/netdata --set parent.claiming.enabled="true" --set parent.claiming.token="TOKEN" --set parent.claiming.rooms="ROOM" --set child.claiming.enabled=true --set child.claiming.token="TOKEN" --set child.claiming.rooms="ROOM" +``` + +### Existing installations + +On an existing installation, you will need to override the configuration values by running the `helm upgrade` command and provide a file with the values to override. You can start with creating a file called `override.yml`. ```bash touch override.yml ``` -Paste the following into your `override.yml` file, replacing instances of `ROOM` and `TOKEN` with those from the -claiming script from Netdata Cloud. These settings claim your `parent`/`child` nodes to Netdata Cloud and store more +Paste the following into your `override.yml` file, replacing instances of `ROOM` and `TOKEN` with those from the script from Netdata Cloud. These settings connect your `parent`/`child` nodes to Netdata Cloud and store more metrics in the nodes' time-series databases. ```yaml @@ -92,7 +101,7 @@ Apply these new settings: helm upgrade -f override.yml netdata netdata/netdata ``` -The cluster terminates the old pods and creates new ones with the proper persistence and claiming configuration. You'll +The cluster terminates the old pods and creates new ones with the proper persistence and connection configuration. You'll see your nodes, containers, and pods appear in Netdata Cloud in a few seconds. ![Netdata's Kubernetes monitoring @@ -107,7 +116,7 @@ Read up on the various configuration options in the [Helm chart documentation](https://github.com/netdata/helmchart#configuration) if you need to tweak your Kubernetes monitoring. Your first option is to create an `override.yml` file, if you haven't created one already for -[claiming](#claim-your-kubernetes-cluster-to-netdata-cloud), then apply the new configuration to your cluster with `helm +[connect](#connect-your-kubernetes-cluster-to-netdata-cloud), then apply the new configuration to your cluster with `helm upgrade`. ```bash diff --git a/packaging/installer/methods/macos.md b/packaging/installer/methods/macos.md index 3fa21d0cd..48d53fd08 100644 --- a/packaging/installer/methods/macos.md +++ b/packaging/installer/methods/macos.md @@ -10,12 +10,27 @@ can use any of Netdata's [external plugins](../../../collectors/plugins.d/README have installed on your macOS system. You could also use a macOS system as the parent node in a [streaming configuration](/streaming/README.md). -We recommend installing Netdata with the community-created and -maintained [**Homebrew +We recommend you to **[install Netdata with the our automatic one-line installation script](#install-netdata-with-the-automatic-one-line-installation-script)**, + + +As an alternative you also have community-created and -maintained [**Homebrew package**](#install-netdata-with-the-homebrew-package). - [Install Netdata via the Homebrew package](#install-netdata-with-the-homebrew-package) - [Install Netdata from source](#install-netdata-from-source) +Being community-created and -maintained we don't guarantee that the features made available on our installation script will also be available or give support to it. + +## Install Netdata with our automatic one-line installation script + +To install Netdata using our automatic [kickstart](/packaging/installer/#automatic-one-line-installation-script) script you will just need to run: + +```bash +bash <(curl -Ss https://my-netdata.io/kickstart.sh) --install /usr/local/ +``` + +With this script, you are also able to connect your nodes directly to Netdata Cloud if you wish, see more details on [Connect an agent running in macOS](/claim/README.md#connect-an-agent-running-in-macos) + ## Install Netdata with the Homebrew package If you don't have [Homebrew](https://brew.sh/) installed already, begin with their installation script: diff --git a/packaging/installer/methods/manual.md b/packaging/installer/methods/manual.md index aa49c81ac..ae96dd954 100644 --- a/packaging/installer/methods/manual.md +++ b/packaging/installer/methods/manual.md @@ -217,13 +217,13 @@ cd netdata process using those files. This option conflicts with the `--stable-channel` option. If you set this _and_ `--stable-channel`, Netdata will use the local files. -### Claim node to Netdata Cloud during installation +### Connect node to Netdata Cloud during installation Unlike the [`kickstart.sh`](/packaging/installer/methods/kickstart.md) or [`kickstart-static64.sh`](/packaging/installer/methods/kickstart-64.md) methods, the `netdata-installer.sh` script does -not allow you to automatically [claim](/claim/README.md) your node to Netdata Cloud immediately after installation. +not allow you to automatically [connect](/claim/README.md) your node to Netdata Cloud immediately after installation. -See the [claiming](/claim/README.md) doc for details on claiming a node with a manual installation of Netdata. +See the [connect to cloud](/claim/README.md) doc for details on connecting a node with a manual installation of Netdata. ### 'nonrepresentable section on output' errors diff --git a/packaging/installer/methods/packages.md b/packaging/installer/methods/packages.md index cf1e33591..20dbaf060 100644 --- a/packaging/installer/methods/packages.md +++ b/packaging/installer/methods/packages.md @@ -6,8 +6,6 @@ custom_edit_url: https://github.com/netdata/netdata/edit/master/packaging/instal # Install Netdata with .deb/.rpm packages -![](https://raw.githubusercontent.com/netdata/netdata/master/web/gui/images/packaging-beta-tag.svg?sanitize=true) - Netdata provides our own flavour of binary packages for the most common operating systems that use with `.deb` and `.rpm` packaging formats. diff --git a/packaging/installer/methods/pfsense.md b/packaging/installer/methods/pfsense.md index ee1a453db..6d9de7606 100644 --- a/packaging/installer/methods/pfsense.md +++ b/packaging/installer/methods/pfsense.md @@ -25,19 +25,19 @@ pkg install -y pkgconf bash e2fsprogs-libuuid libuv nano Then run the following commands to download various dependencies from the FreeBSD repository. ```sh -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/Judy-1.0.5_2.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/json-c-0.15_1.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-certifi-2020.6.20.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-asn1crypto-1.3.0.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-pycparser-2.20.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-cffi-1.14.3.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-six-1.15.0.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-cryptography-2.6.1.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-idna-2.10.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-openssl-19.0.0.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-pysocks-1.7.1.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-urllib3-1.25.11,1.txz -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-yaml-5.3.1.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/Judy-1.0.5_3.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/json-c-0.15_1.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-certifi-2021.10.8.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-asn1crypto-1.4.0.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-pycparser-2.20.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-cffi-1.14.6.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-six-1.16.0.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-cryptography-3.3.2.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-idna-2.10.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-openssl-20.0.1.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-pysocks-1.7.1.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-urllib3-1.26.7,1.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/py38-yaml-5.4.1.txz ``` > ⚠️ If any of the above commands return a `Not Found` error, you need to manually search for the latest package in the @@ -56,7 +56,7 @@ pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/py37-yaml-5.3.1.txz You can now install Netdata from the FreeBSD repository. ```bash -pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/netdata-1.28.0.txz +pkg add http://pkg.freebsd.org/FreeBSD:12:amd64/latest/All/netdata-1.31.0_1.txz ``` > ⚠️ If the above command returns a `Not Found` error, you need to manually search for the latest version of Netdata in diff --git a/packaging/installer/methods/source.md b/packaging/installer/methods/source.md index e0827fc17..ba29a188d 100644 --- a/packaging/installer/methods/source.md +++ b/packaging/installer/methods/source.md @@ -99,7 +99,7 @@ library for the build system: `externaldeps/libwebsockets`. 6. Copy `lib/libwebsockets.a` from the libwebsockets source directory to `externaldeps/libwebsockets/libwebsockets.a` in the Netdata source tree. -7. Copy the entire contents of `lib/include` from the libwebsockets source +7. Copy the entire contents of `include/` from the libwebsockets source directory to `externaldeps/libwebsockets/include` in the Netdata source tree. #### JSON-C @@ -120,7 +120,7 @@ you can do the following to prepare a copy for the build system: 4. Build JSON-C by running `make` in the JSON-C source directory. 5. In the Netdata source directory, create a directory called `externaldeps/jsonc`. -6. Copy `libjson-c.a` fro the JSON-C source directory to +6. Copy `libjson-c.a` from the JSON-C source directory to `externaldeps/jsonc/libjson-c.a` in the Netdata source tree. 7. Copy all of the header files (`*.h`) from the JSON-C source directory to `externaldeps/jsonc/json-c` in the Netdata source tree. diff --git a/packaging/installer/methods/synology.md b/packaging/installer/methods/synology.md index 4a0ae3551..07b1596fd 100644 --- a/packaging/installer/methods/synology.md +++ b/packaging/installer/methods/synology.md @@ -21,7 +21,7 @@ will install the content into `/opt/netdata`, making future removal safe and sim When Netdata is first installed, it will run as _root_. This may or may not be acceptable for you, and since other installations run it as the `netdata` user, you might wish to do the same. This requires some extra work: -1. Creat a group `netdata` via the Synology group interface. Give it no access to anything. +1. Create a group `netdata` via the Synology group interface. Give it no access to anything. 2. Create a user `netdata` via the Synology user interface. Give it no access to anything and a random password. Assign the user to the `netdata` group. Netdata will chuid to this user when running. 3. Change ownership of the following directories, as defined in [Netdata @@ -33,6 +33,14 @@ chown -R netdata:netdata /opt/netdata/var/lib/netdata /opt/netdata/var/cache/net chown -R netdata:root /opt/netdata/var/log/netdata ``` +4. Uncomment and set `web files owner` to `root`, and `web files group` to `netdata` in + the `/opt/netdata/etc/netdata/netdata.conf`. +5. Restart Netdata + +```sh +/etc/rc.netdata restart +``` + ## Create startup script Additionally, as of 2018/06/24, the Netdata installer doesn't recognize DSM as an operating system, so no init script is diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh index ad7412255..59c5fab11 100755 --- a/packaging/installer/netdata-updater.sh +++ b/packaging/installer/netdata-updater.sh @@ -6,13 +6,15 @@ # - PATH # - CFLAGS # - LDFLAGS +# - MAKEOPTS # - IS_NETDATA_STATIC_BINARY # - NETDATA_CONFIGURE_OPTIONS # - REINSTALL_OPTIONS # - 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: # @@ -170,6 +172,26 @@ download() { fi } +get_netdata_latest_tag() { + local dest="${1}" + local url="https://github.com/netdata/netdata/releases/latest" + local tag + + if command -v curl >/dev/null 2>&1; then + tag=$(curl "${url}" -s -L -I -o /dev/null -w '%{url_effective}' | grep -m 1 -o '[^/]*$') + elif command -v wget >/dev/null 2>&1; then + tag=$(wget --max-redirect=0 "${url}" 2>&1 | grep Location | cut -d ' ' -f2 | grep -m 1 -o '[^/]*$') + else + fatal "I need curl or wget to proceed, but neither of them are available on this system." + fi + + if [[ ! $tag =~ ^v[0-9]+\..+ ]]; then + fatal "Cannot download latest stable tag from ${url}" + fi + + echo "${tag}" >"${dest}" +} + newer_commit_date() { echo >&3 "Checking if a newer version of the updater script is available." @@ -235,7 +257,7 @@ parse_version() { get_latest_version() { if [ "${RELEASE_CHANNEL}" == "stable" ]; then - download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4 + get_netdata_latest_tag /dev/stdout else download "$NETDATA_NIGHTLIES_BASEURL/latest-version.txt" /dev/stdout fi @@ -250,8 +272,7 @@ set_tarball_urls() { if [ "$1" = "stable" ]; then local latest - # Simple version - latest="$(download "https://api.github.com/repos/netdata/netdata/releases/latest" /dev/stdout | grep tag_name | cut -d'"' -f4)" + latest="$(get_netdata_latest_tag /dev/stdout)" export NETDATA_TARBALL_URL="https://github.com/netdata/netdata/releases/download/$latest/netdata-$latest.${extension}" export NETDATA_TARBALL_CHECKSUM_URL="https://github.com/netdata/netdata/releases/download/$latest/sha256sums.txt" else @@ -326,6 +347,12 @@ update() { fi fi + if [ -e "${NETDATA_PREFIX}/etc/netdata/.install-type" ] ; then + install_type="$(cat "${NETDATA_PREFIX}"/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 +361,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 @@ -393,7 +422,7 @@ if [ -t 2 ]; then else # we are headless # create a temporary file for the log - logfile="$(mktemp "${logfile}"/netdata-updater.log.XXXXXX)" + logfile="$(mktemp -t netdata-updater.log.XXXXXX)" # open fd 3 and send it to logfile exec 3> "${logfile}" fi @@ -415,6 +444,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,8 +457,11 @@ 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 + cd "${PREVDIR}" else # the installer updates this script - so we run and exit in a single line update && exit 0 diff --git a/packaging/libbpf.checksums b/packaging/libbpf.checksums index d4ff87a12..eccbfa9f3 100644 --- a/packaging/libbpf.checksums +++ b/packaging/libbpf.checksums @@ -1 +1 @@ -fc33402ba33c8f8c5aa18afbb86a9932965886f2906c50e8f2110a1a2126e3ee v0.0.9_netdata-1.tar.gz +47acbdf7836048fad3a585c6ab43cc08d1b70c27ce0a816e9ca92b927555530f v0.5.1_netdata.tar.gz diff --git a/packaging/libbpf.version b/packaging/libbpf.version index d2362909d..74ca5f708 100644 --- a/packaging/libbpf.version +++ b/packaging/libbpf.version @@ -1 +1 @@ -0.0.9_netdata-1 +0.5.1_netdata diff --git a/packaging/libbpf_0_0_9.checksums b/packaging/libbpf_0_0_9.checksums new file mode 100644 index 000000000..d4ff87a12 --- /dev/null +++ b/packaging/libbpf_0_0_9.checksums @@ -0,0 +1 @@ +fc33402ba33c8f8c5aa18afbb86a9932965886f2906c50e8f2110a1a2126e3ee v0.0.9_netdata-1.tar.gz diff --git a/packaging/libbpf_0_0_9.version b/packaging/libbpf_0_0_9.version new file mode 100644 index 000000000..d2362909d --- /dev/null +++ b/packaging/libbpf_0_0_9.version @@ -0,0 +1 @@ +0.0.9_netdata-1 diff --git a/packaging/makeself/build-static.sh b/packaging/makeself/build-static.sh new file mode 100755 index 000000000..e9cf620b4 --- /dev/null +++ b/packaging/makeself/build-static.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# SPDX-License-Identifier: GPL-3.0-or-later + +# shellcheck source=./packaging/installer/functions.sh +. "$(dirname "$0")"/../installer/functions.sh || exit 1 + +BUILDARCH="${1}" + +set -e + +case ${BUILDARCH} in + x86_64) platform=linux/amd64 ;; + armv7l) platform=linux/arm/v7 ;; + aarch64) platform=linux/arm64/v8 ;; + ppc64le) platform=linux/ppc64le ;; + *) + echo "Unknown target architecture '${BUILDARCH}'." + exit 1 + ;; +esac + +DOCKER_CONTAINER_NAME="netdata-package-${BUILDARCH}-static-alpine314" + +if [ "${BUILDARCH}" != "$(uname -m)" ] && [ "$(uname -m)" = 'x86_64' ] && [ -z "${SKIP_EMULATION}" ]; then + docker run --rm --privileged multiarch/qemu-user-static --reset -p yes || exit 1 +fi + +if ! docker inspect "${DOCKER_CONTAINER_NAME}" > /dev/null 2>&1; then + # To run interactively: + # docker run -it netdata-package-x86_64-static /bin/sh + # (add -v host-dir:guest-dir:rw arguments to mount volumes) + # + # To remove images in order to re-create: + # docker rm -v $(sudo docker ps -a -q -f status=exited) + # docker rmi netdata-package-x86_64-static + # + # This command maps the current directory to + # /usr/src/netdata.git + # inside the container and runs the script install-alpine-packages.sh + # (also inside the container) + # + if docker inspect alpine:3.14 > /dev/null 2>&1; then + run docker image remove alpine:3.14 + run docker pull --platform=${platform} alpine:3.14 + fi + + run docker run --platform=${platform} -v "$(pwd)":/usr/src/netdata.git:rw alpine:3.14 \ + /bin/sh /usr/src/netdata.git/packaging/makeself/install-alpine-packages.sh + + # save the changes made permanently + id=$(docker ps -l -q) + run docker commit "${id}" "${DOCKER_CONTAINER_NAME}" +fi + +# Run the build script inside the container +if [ -t 1 ]; then + run docker run -e BUILDARCH="${BUILDARCH}" -a stdin -a stdout -a stderr -i -t -v "$(pwd)":/usr/src/netdata.git:rw \ + "${DOCKER_CONTAINER_NAME}" \ + /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}" +else + run docker run -e BUILDARCH="${BUILDARCH}" -v "$(pwd)":/usr/src/netdata.git:rw \ + -e GITHUB_ACTIONS="${GITHUB_ACTIONS}" "${DOCKER_CONTAINER_NAME}" \ + /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}" +fi + +if [ "${USER}" ]; then + sudo chown -R "${USER}" . +fi diff --git a/packaging/makeself/build-x86_64-static.sh b/packaging/makeself/build-x86_64-static.sh index 83fa0dba9..0f5f1df14 100755 --- a/packaging/makeself/build-x86_64-static.sh +++ b/packaging/makeself/build-x86_64-static.sh @@ -2,47 +2,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later -# shellcheck source=./packaging/installer/functions.sh -. "$(dirname "$0")"/../installer/functions.sh || exit 1 +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -set -e - -DOCKER_CONTAINER_NAME="netdata-package-x86_64-static-alpine312" - -if ! docker inspect "${DOCKER_CONTAINER_NAME}" > /dev/null 2>&1; then - # To run interactively: - # docker run -it netdata-package-x86_64-static /bin/sh - # (add -v host-dir:guest-dir:rw arguments to mount volumes) - # - # To remove images in order to re-create: - # docker rm -v $(sudo docker ps -a -q -f status=exited) - # docker rmi netdata-package-x86_64-static - # - # This command maps the current directory to - # /usr/src/netdata.git - # inside the container and runs the script install-alpine-packages.sh - # (also inside the container) - # - run docker run -v "$(pwd)":/usr/src/netdata.git:rw alpine:3.12 \ - /bin/sh /usr/src/netdata.git/packaging/makeself/install-alpine-packages.sh - - # save the changes made permanently - id=$(docker ps -l -q) - run docker commit "${id}" "${DOCKER_CONTAINER_NAME}" -fi - -# Run the build script inside the container -if [ -t 1 ]; then - run docker run -a stdin -a stdout -a stderr -i -t -v \ - "$(pwd)":/usr/src/netdata.git:rw \ - "${DOCKER_CONTAINER_NAME}" \ - /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}" -else - run docker run -v "$(pwd)":/usr/src/netdata.git:rw \ - "${DOCKER_CONTAINER_NAME}" \ - /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}" -fi - -if [ "${USER}" ]; then - sudo chown -R "${USER}" . -fi +"${SCRIPT_DIR}/build-static.sh" x86_64 diff --git a/packaging/makeself/build.sh b/packaging/makeself/build.sh index 85cb8fca7..4eb2c9f41 100755 --- a/packaging/makeself/build.sh +++ b/packaging/makeself/build.sh @@ -38,6 +38,9 @@ if [ ! -f ../../netdata-installer.sh ]; then exit $? fi +git clean -dxf +git submodule foreach --recursive git clean -dxf + cat >&2 << EOF This program will create a self-extracting shell package containing a statically linked netdata, able to run on any 64bit Linux system, @@ -49,6 +52,12 @@ EOF if [ ! -d tmp ]; then mkdir tmp || exit 1 +else + rm -rf tmp/* +fi + +if [ -z "${GITHUB_ACTIONS}" ]; then + export GITHUB_ACTIONS=false fi if ! ./run-all-jobs.sh "$@"; then diff --git a/packaging/makeself/functions.sh b/packaging/makeself/functions.sh index 15818d3b2..afc8a9ac9 100755 --- a/packaging/makeself/functions.sh +++ b/packaging/makeself/functions.sh @@ -29,13 +29,25 @@ set -euo pipefail # ----------------------------------------------------------------------------- fetch() { - local dir="${1}" url="${2}" + local dir="${1}" url="${2}" sha256="${3}" local tar="${dir}.tar.gz" if [ ! -f "${NETDATA_MAKESELF_PATH}/tmp/${tar}" ]; then run wget -O "${NETDATA_MAKESELF_PATH}/tmp/${tar}" "${url}" fi + # Check SHA256 of gzip'd tar file (apparently alpine's sha256sum requires + # two empty spaces between the checksum and the file's path) + set +e + echo "${sha256} ${NETDATA_MAKESELF_PATH}/tmp/${tar}" | sha256sum -c -s + local rc=$? + if [ ${rc} -ne 0 ]; then + echo >&2 "SHA256 verification of tar file ${tar} failed (rc=${rc})" + echo >&2 "expected: ${sha256}, got $(sha256sum "${NETDATA_MAKESELF_PATH}/tmp/${tar}")" + exit 1 + fi + set -e + if [ ! -d "${NETDATA_MAKESELF_PATH}/tmp/${dir}" ]; then cd "${NETDATA_MAKESELF_PATH}/tmp" run tar -zxpf "${tar}" diff --git a/packaging/makeself/install-alpine-packages.sh b/packaging/makeself/install-alpine-packages.sh index a3e8cf605..6258d5dda 100755 --- a/packaging/makeself/install-alpine-packages.sh +++ b/packaging/makeself/install-alpine-packages.sh @@ -9,43 +9,37 @@ # Add required APK packages apk add --no-cache -U \ - bash \ - wget \ - curl \ - ncurses \ - git \ - netcat-openbsd \ alpine-sdk \ autoconf \ automake \ - gcc \ - make \ + bash \ + binutils \ cmake \ - libtool \ - pkgconfig \ - util-linux-dev \ + curl \ + elfutils-dev \ + gcc \ + git \ gnutls-dev \ - zlib-dev \ - zlib-static \ + gzip \ + libelf-static \ libmnl-dev \ libnetfilter_acct-dev \ + libtool \ libuv-dev \ libuv-static \ lz4-dev \ lz4-static \ - snappy-dev \ + make \ + ncurses \ + netcat-openbsd \ + openssh \ + pkgconfig \ protobuf-dev \ - binutils \ - gzip \ - xz || exit 1 - -# snappy doesn't have static version in alpine, let's compile it -export SNAPPY_VER="1.1.7" -wget -O /snappy.tar.gz https://github.com/google/snappy/archive/${SNAPPY_VER}.tar.gz -tar -C / -xf /snappy.tar.gz -rm /snappy.tar.gz -cd /snappy-${SNAPPY_VER} || exit 1 -mkdir build -cd build || exit 1 -cmake -DCMAKE_BUILD_SHARED_LIBS=true -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_LIBDIR=lib ../ -make && make install + snappy-dev \ + snappy-static \ + util-linux-dev \ + wget \ + xz \ + zlib-dev \ + zlib-static || + exit 1 diff --git a/packaging/makeself/install-or-update.sh b/packaging/makeself/install-or-update.sh index 11fcc091c..ae12cce7b 100755 --- a/packaging/makeself/install-or-update.sh +++ b/packaging/makeself/install-or-update.sh @@ -49,6 +49,7 @@ while [ "${1}" ]; do REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}" ;; "--disable-telemetry") + NETDATA_DISABLE_TELEMETRY=1 REINSTALL_OPTIONS="${REINSTALL_OPTIONS} ${1}" ;; @@ -58,6 +59,7 @@ while [ "${1}" ]; do done if [ ! "${DO_NOT_TRACK:-0}" -eq 0 ] || [ -n "$DO_NOT_TRACK" ]; then + NETDATA_DISABLE_TELEMETRY=1 REINSTALL_OPTIONS="${REINSTALL_OPTIONS} --disable-telemetry" fi @@ -138,7 +140,7 @@ install_netdata_logrotate || run_failed "Cannot install logrotate file for netda progress "Telemetry configuration" # Opt-out from telemetry program -if [ -n "${NETDATA_DISABLE_TELEMETRY+x}" ]; then +if [ -n "${NETDATA_DISABLE_TELEMETRY}" ]; then run touch "${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics" else printf "You can opt out from anonymous statistics via the --disable-telemetry option, or by creating an empty file %s \n\n" "${NETDATA_USER_CONFIG_DIR}/.opt-out-from-anonymous-statistics" @@ -212,7 +214,7 @@ run chown -R ${NETDATA_USER}:${NETDATA_GROUP} /opt/netdata progress "fix plugin permissions" -for x in apps.plugin freeipmi.plugin ioping cgroup-network; do +for x in apps.plugin freeipmi.plugin ioping cgroup-network ebpf.plugin; do f="usr/libexec/netdata/plugins.d/${x}" if [ -f "${f}" ]; then diff --git a/packaging/makeself/jobs/10-prepare-destination.install.sh b/packaging/makeself/jobs/10-prepare-destination.install.sh index 8cce2d442..4686841b5 100755 --- a/packaging/makeself/jobs/10-prepare-destination.install.sh +++ b/packaging/makeself/jobs/10-prepare-destination.install.sh @@ -4,14 +4,20 @@ # shellcheck source=packaging/makeself/functions.sh . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1 +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Preparing build environment" || true + [ -d "${NETDATA_INSTALL_PATH}.old" ] && run rm -rf "${NETDATA_INSTALL_PATH}.old" [ -d "${NETDATA_INSTALL_PATH}" ] && run mv -f "${NETDATA_INSTALL_PATH}" "${NETDATA_INSTALL_PATH}.old" run mkdir -p "${NETDATA_INSTALL_PATH}/bin" run mkdir -p "${NETDATA_INSTALL_PATH}/usr" -run cd "${NETDATA_INSTALL_PATH}" +run cd "${NETDATA_INSTALL_PATH}" || exit 1 run ln -s bin sbin -run cd "${NETDATA_INSTALL_PATH}/usr" +run cd "${NETDATA_INSTALL_PATH}/usr" || exit 1 run ln -s ../bin bin run ln -s ../sbin sbin run ln -s . local + +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true diff --git a/packaging/makeself/jobs/20-openssl.install.sh b/packaging/makeself/jobs/20-openssl.install.sh index 10863f90f..96d53fc86 100755 --- a/packaging/makeself/jobs/20-openssl.install.sh +++ b/packaging/makeself/jobs/20-openssl.install.sh @@ -4,17 +4,24 @@ # shellcheck source=packaging/makeself/functions.sh . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1 +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building OpenSSL" || true + version="$(cat "$(dirname "${0}")/../openssl.version")" +export CFLAGS='-fno-lto' export LDFLAGS='-static' export PKG_CONFIG="pkg-config --static" # Might be bind-mounted if [ ! -d "${NETDATA_MAKESELF_PATH}/tmp/openssl" ]; then - run git clone --branch "${version}" --single-branch git://git.openssl.org/openssl.git "${NETDATA_MAKESELF_PATH}/tmp/openssl" + run git clone --branch "${version}" --single-branch --depth 1 git://git.openssl.org/openssl.git "${NETDATA_MAKESELF_PATH}/tmp/openssl" fi cd "${NETDATA_MAKESELF_PATH}/tmp/openssl" || exit 1 -run ./config no-shared no-tests --prefix=/openssl-static --openssldir=/opt/netdata/etc/ssl +run ./config -static no-tests --prefix=/openssl-static --openssldir=/opt/netdata/etc/ssl run make -j "$(nproc)" run make -j "$(nproc)" install_sw + +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true diff --git a/packaging/makeself/jobs/50-bash-5.0.install.sh b/packaging/makeself/jobs/50-bash-5.1.8.install.sh index a204c1575..22c9286af 100755 --- a/packaging/makeself/jobs/50-bash-5.0.install.sh +++ b/packaging/makeself/jobs/50-bash-5.1.8.install.sh @@ -4,7 +4,11 @@ # shellcheck source=packaging/makeself/functions.sh . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1 -fetch "bash-5.0" "http://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz" +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::building bash" || true + +fetch "bash-5.1.8" "http://ftp.gnu.org/gnu/bash/bash-5.1.8.tar.gz" \ + 0cfb5c9bb1a29f800a97bd242d19511c997a1013815b805e0fdd32214113d6be export PKG_CONFIG_PATH="/openssl-static/lib/pkgconfig" @@ -14,6 +18,7 @@ run ./configure \ --enable-static-link \ --enable-net-redirections \ --enable-array-variables \ + --disable-progcomp \ --disable-profiling \ --disable-nls @@ -28,6 +33,9 @@ EOF run make install -if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]; then +if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then run strip "${NETDATA_INSTALL_PATH}"/bin/bash fi + +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true diff --git a/packaging/makeself/jobs/50-curl-7.73.0.install.sh b/packaging/makeself/jobs/50-curl-7.78.0.install.sh index 4a9505e58..a2bb24e2c 100755 --- a/packaging/makeself/jobs/50-curl-7.73.0.install.sh +++ b/packaging/makeself/jobs/50-curl-7.78.0.install.sh @@ -4,7 +4,11 @@ # shellcheck source=packaging/makeself/functions.sh . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1 -fetch "curl-7.73.0" "https://curl.haxx.se/download/curl-7.73.0.tar.gz" +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building cURL" || true + +fetch "curl-7.78.0" "https://curl.haxx.se/download/curl-7.78.0.tar.gz" \ + ed936c0b02c06d42cf84b39dd12bb14b62d77c7c4e875ade022280df5dcc81d7 export CFLAGS="-I/openssl-static/include" export LDFLAGS="-static -L/openssl-static/lib" @@ -19,10 +23,21 @@ run ./configure \ --disable-shared \ --enable-static \ --enable-http \ + --disable-ldap \ + --disable-ldaps \ --enable-proxy \ + --disable-dict \ + --disable-telnet \ + --disable-tftp \ + --disable-pop3 \ + --disable-imap \ + --disable-smb \ + --disable-smtp \ + --disable-gopher \ --enable-ipv6 \ --enable-cookies \ - --with-ca-fallback + --with-ca-fallback \ + --with-openssl # Curl autoconf does not honour the curl_LDFLAGS environment variable run sed -i -e "s/curl_LDFLAGS =/curl_LDFLAGS = -all-static/" src/Makefile @@ -31,6 +46,9 @@ run make clean run make -j "$(nproc)" run make install -if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]; then +if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then run strip "${NETDATA_INSTALL_PATH}"/bin/curl fi + +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Preparing build environment" || true diff --git a/packaging/makeself/jobs/50-fping-5.0.install.sh b/packaging/makeself/jobs/50-fping-5.0.install.sh index e62c47e45..8bef27d4d 100755 --- a/packaging/makeself/jobs/50-fping-5.0.install.sh +++ b/packaging/makeself/jobs/50-fping-5.0.install.sh @@ -4,7 +4,11 @@ # shellcheck source=packaging/makeself/functions.sh . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1 -fetch "fping-5.0" "https://fping.org/dist/fping-5.0.tar.gz" +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building fping" || true + +fetch "fping-5.0" "https://fping.org/dist/fping-5.0.tar.gz" \ + ed38c0b9b64686a05d1b3bc1d66066114a492e04e44eef1821d43b1263cd57b8 export CFLAGS="-static -I/openssl-static/include" export LDFLAGS="-static -L/openssl-static/lib" @@ -25,6 +29,9 @@ run make clean run make -j "$(nproc)" run make install -if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]; then +if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then run strip "${NETDATA_INSTALL_PATH}"/bin/fping fi + +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true diff --git a/packaging/makeself/jobs/50-ioping-1.2.install.sh b/packaging/makeself/jobs/50-ioping-1.2.install.sh index 22f26914a..9e9505022 100755 --- a/packaging/makeself/jobs/50-ioping-1.2.install.sh +++ b/packaging/makeself/jobs/50-ioping-1.2.install.sh @@ -4,7 +4,11 @@ # shellcheck source=packaging/makeself/functions.sh . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1 -fetch "ioping-1.2" "https://github.com/koct9i/ioping/archive/v1.2.tar.gz" +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building ioping" || true + +fetch "ioping-1.2" "https://github.com/koct9i/ioping/archive/v1.2.tar.gz" \ + d3e4497c653a1e96df67c72ce2b70da18e9f5e3b93179a5bb57a6e30ceacfa75 export CFLAGS="-static" @@ -13,6 +17,9 @@ run make -j "$(nproc)" run mkdir -p "${NETDATA_INSTALL_PATH}"/usr/libexec/netdata/plugins.d/ run install -o root -g root -m 4750 ioping "${NETDATA_INSTALL_PATH}"/usr/libexec/netdata/plugins.d/ -if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]; then +if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then run strip "${NETDATA_INSTALL_PATH}"/usr/libexec/netdata/plugins.d/ioping fi + +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true diff --git a/packaging/makeself/jobs/70-netdata-git.install.sh b/packaging/makeself/jobs/70-netdata-git.install.sh index 21d4fd0ac..98fc4dbe8 100755 --- a/packaging/makeself/jobs/70-netdata-git.install.sh +++ b/packaging/makeself/jobs/70-netdata-git.install.sh @@ -6,7 +6,7 @@ cd "${NETDATA_SOURCE_PATH}" || exit 1 -if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]; then +if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then export CFLAGS="-static -O3 -I/openssl-static/include" else export CFLAGS="-static -O1 -ggdb -Wall -Wextra -Wformat-signedness -fstack-protector-all -D_FORTIFY_SOURCE=2 -DNETDATA_INTERNAL_CHECKS=1 -I/openssl-static/include" @@ -31,8 +31,18 @@ run ./netdata-installer.sh \ --dont-wait \ --dont-start-it \ --require-cloud \ + --use-system-protobuf \ --dont-scrub-cflags-even-though-it-may-break-things +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Finishing netdata install" || true + +# Properly mark the install type +cat > "${NETDATA_INSTALL_PATH}/etc/netdata/.install-type" <<-EOF + INSTALL_TYPE='manual-static' + PREBUILT_ARCH='${BUILDARCH}' + 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" @@ -43,8 +53,11 @@ if run readelf -l "${NETDATA_INSTALL_PATH}"/bin/netdata | grep 'INTERP'; then exit 1 fi -if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]; then +if [ "${NETDATA_BUILD_WITH_DEBUG}" -eq 0 ]; then run strip "${NETDATA_INSTALL_PATH}"/bin/netdata run strip "${NETDATA_INSTALL_PATH}"/usr/libexec/netdata/plugins.d/apps.plugin run strip "${NETDATA_INSTALL_PATH}"/usr/libexec/netdata/plugins.d/cgroup-network fi + +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true diff --git a/packaging/makeself/jobs/99-makeself.install.sh b/packaging/makeself/jobs/99-makeself.install.sh index de641027b..9dfcfbed7 100755 --- a/packaging/makeself/jobs/99-makeself.install.sh +++ b/packaging/makeself/jobs/99-makeself.install.sh @@ -4,6 +4,9 @@ # shellcheck source=packaging/makeself/functions.sh . "$(dirname "${0}")/../functions.sh" "${@}" || exit 1 +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::group::Building self-extracting archive" || true + run cd "${NETDATA_SOURCE_PATH}" || exit 1 # ----------------------------------------------------------------------------- @@ -90,12 +93,22 @@ run rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp" # ----------------------------------------------------------------------------- # copy it to the netdata build dir -FILE="netdata-${VERSION}.gz.run" +FILE="netdata-${BUILDARCH}-${VERSION}.gz.run" run mkdir -p artifacts run mv "${NETDATA_INSTALL_PATH}.gz.run" "artifacts/${FILE}" -[ -f netdata-latest.gz.run ] && rm netdata-latest.gz.run -run ln -s "artifacts/${FILE}" netdata-latest.gz.run +[ -f "netdata-${BUILDARCH}-latest.gz.run" ] && rm "netdata-${BUILDARCH}-latest.gz.run" +run ln -s "artifacts/${FILE}" "netdata-${BUILDARCH}-latest.gz.run" + +if [ "${BUILDARCH}" = "x86_64" ]; then + [ -f "netdata-latest.gz.run" ] && rm "netdata-latest.gz.run" + run ln -s "artifacts/${FILE}" "netdata-latest.gz.run" + [ -f "artifacts/netdata-${VERSION}.gz.run" ] && rm "netdata-${VERSION}.gz.run" + run ln -s "./${FILE}" "artifacts/netdata-${VERSION}.gz.run" +fi + +# shellcheck disable=SC2015 +[ "${GITHUB_ACTIONS}" = "true" ] && echo "::endgroup::" || true echo >&2 "Self-extracting installer moved to 'artifacts/${FILE}'" diff --git a/packaging/makeself/makeself.sh b/packaging/makeself/makeself.sh index 15a002884..1581f499e 100755 --- a/packaging/makeself/makeself.sh +++ b/packaging/makeself/makeself.sh @@ -7,7 +7,7 @@ # Utility to create self-extracting tar.gz archives. # The resulting archive is a file holding the tar.gz archive with # a small Shell script stub that uncompresses the archive to a temporary -# directory and then executes a given script from withing that directory. +# directory and then executes a given script from within that directory. # # Makeself home page: http://makeself.io/ # diff --git a/packaging/makeself/openssl.version b/packaging/makeself/openssl.version index aa2c66c02..5b309eb4f 100644 --- a/packaging/makeself/openssl.version +++ b/packaging/makeself/openssl.version @@ -1 +1 @@ -OpenSSL_1_1_1k +OpenSSL_1_1_1l diff --git a/packaging/protobuf.checksums b/packaging/protobuf.checksums new file mode 100644 index 000000000..b901a0be4 --- /dev/null +++ b/packaging/protobuf.checksums @@ -0,0 +1 @@ +51cec99f108b83422b7af1170afd7aeb2dd77d2bcbb7b6bad1f92509e9ccf8cb protobuf-cpp-3.17.3.tar.gz diff --git a/packaging/protobuf.version b/packaging/protobuf.version new file mode 100644 index 000000000..56cc1b61f --- /dev/null +++ b/packaging/protobuf.version @@ -0,0 +1 @@ +3.17.3 diff --git a/packaging/repoconfig/Makefile b/packaging/repoconfig/Makefile new file mode 100644 index 000000000..d0f246ac3 --- /dev/null +++ b/packaging/repoconfig/Makefile @@ -0,0 +1,31 @@ +FILES = netdata.list netdata-edge.list netdata-archive-keyring.gpg netdata-edge-archive-keyring.gpg netdata-repoconfig-archive-keyring.gpg + +all: $(FILES) + +netdata.list: netdata.list.in + cp netdata.list.in netdata.list + set -a && . /etc/os-release && sed -i -e "s/__DISTRO__/$${ID}/" -e "s/__SUITE__/$${VERSION_CODENAME}/" -e "s/__VARIANT__//" netdata.list + +netdata-edge.list: netdata.list.in + cp netdata.list.in netdata-edge.list + set -a && . /etc/os-release && sed -i -e "s/__DISTRO__/$${ID}/" -e "s/__SUITE__/$${VERSION_CODENAME}/" -e "s/__VARIANT__/-edge/" netdata-edge.list + +netdata-archive-keyring.gpg: + curl -L https://packagecloud.io/netdata/netdata/gpgkey | gpg --dearmor > netdata-archive-keyring.gpg + +netdata-edge-archive-keyring.gpg: + curl -L https://packagecloud.io/netdata/netdata-edge/gpgkey | gpg --dearmor > netdata-edge-archive-keyring.gpg + +netdata-repoconfig-archive-keyring.gpg: + curl -L https://packagecloud.io/netdata/netdata-repoconfig/gpgkey | gpg --dearmor > netdata-repoconfig-archive-keyring.gpg + +debian/tmp: + mkdir -p debian/tmp + +install: $(FILES) debian/tmp + cp $(FILES) debian/tmp/ + +clean: + rm -f $(FILES) + +.PHONY: clean diff --git a/packaging/repoconfig/build-deb.sh b/packaging/repoconfig/build-deb.sh new file mode 100755 index 000000000..f1e0d7266 --- /dev/null +++ b/packaging/repoconfig/build-deb.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +# Needed because dpkg is stupid and tries to configure things interactively if it sees a terminal. +export DEBIAN_FRONTEND=noninteractive + +# Pull in our dependencies +apt update || exit 1 +apt upgrade -y || exit 1 +apt install -y build-essential debhelper curl gnupg || exit 1 + +# Run the builds in an isolated source directory. +# This removes the need for cleanup, and ensures anything the build does +# doesn't muck with the user's sources. +cp -a /netdata/packaging/repoconfig /usr/src || exit 1 +cd /usr/src/repoconfig || exit 1 + +# pre/post options are after 1.18.8, is simpler to just check help for their existence than parsing version +if dpkg-buildpackage --help | grep "\-\-post\-clean" 2> /dev/null > /dev/null; then + dpkg-buildpackage --post-clean --pre-clean -b -us -uc || exit 1 +else + dpkg-buildpackage -b -us -uc || exit 1 +fi + +# Copy the built packages to /netdata/artifacts (which may be bind-mounted) +# Also ensure /netdata/artifacts exists and create it if it doesn't +[ -d /netdata/artifacts ] || mkdir -p /netdata/artifacts +cp -a /usr/src/*.deb /netdata/artifacts/ || exit 1 + +# Correct ownership of the artifacts. +# Without this, the artifacts directory and it's contents end up owned +# by root instead of the local user on Linux boxes +chown -R --reference=/netdata /netdata/artifacts diff --git a/packaging/repoconfig/build-rpm.sh b/packaging/repoconfig/build-rpm.sh new file mode 100755 index 000000000..6c07c6619 --- /dev/null +++ b/packaging/repoconfig/build-rpm.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +prefix='/root/rpmbuild' + +if command -v dnf > /dev/null ; then + dnf distro-sync -y --nodocs || exit 1 + dnf install -y --nodocs --setopt=install_weak_deps=False rpm-build || exit 1 +elif command -v yum > /dev/null ; then + yum distro-sync -y || exit 1 + yum install -y rpm-build || exit 1 +elif command -v zypper > /dev/null ; then + zypper update -y || exit 1 + zypper install -y rpm-build || exit 1 + prefix="/usr/src/packages" +fi + +mkdir -p "${prefix}/BUILD" "${prefix}/RPMS" "${prefix}/SRPMS" "${prefix}/SPECS" "${prefix}/SOURCES" || exit 1 +cp -a /netdata/packaging/repoconfig/netdata-repo.spec "${prefix}/SPECS" || exit 1 +cp -a /netdata/packaging/repoconfig/* "${prefix}/SOURCES/" || exit 1 + +rpmbuild -bb --rebuild "${prefix}/SPECS/netdata-repo.spec" || exit 1 + +[ -d /netdata/artifacts ] || mkdir -p /netdata/artifacts +find "${prefix}/RPMS/" -type f -name '*.rpm' -exec cp '{}' /netdata/artifacts \; || exit 1 + +chown -R --reference=/netdata /netdata/artifacts diff --git a/packaging/repoconfig/debian/changelog b/packaging/repoconfig/debian/changelog new file mode 100644 index 000000000..61d2e746b --- /dev/null +++ b/packaging/repoconfig/debian/changelog @@ -0,0 +1,6 @@ +netdata-repo (1-1) unstable; urgency=medium + + * Initial Release + + -- Netdata Builder <bot@netdata.cloud> Mon, 14 Jun 2021 08:00:00 -0500 + diff --git a/packaging/repoconfig/debian/compat b/packaging/repoconfig/debian/compat new file mode 100644 index 000000000..ec635144f --- /dev/null +++ b/packaging/repoconfig/debian/compat @@ -0,0 +1 @@ +9 diff --git a/packaging/repoconfig/debian/control b/packaging/repoconfig/debian/control new file mode 100644 index 000000000..5fdcf140b --- /dev/null +++ b/packaging/repoconfig/debian/control @@ -0,0 +1,19 @@ +Source: netdata-repo +Section: net +Priority: optional +Maintainer: Netdata Builder <bot@netdata.cloud> +Standards-Version: 3.9.6 +Build-Depends: debhelper (>= 9), curl, gnupg +Homepage: https://netdata.cloud + +Package: netdata-repo +Architecture: all +Depends: apt-transport-https, debian-archive-keyring, gnupg +Conflicts: netdata-repo-edge +Description: Configuration for the official Netdata Stable package repository. + +Package: netdata-repo-edge +Architecture:all +Depends: apt-transport-https, debian-archive-keyring, gnupg +Conflicts: netdata-repo +Description: Configuration for the official Netdata Edge package repository. diff --git a/packaging/repoconfig/debian/copyright b/packaging/repoconfig/debian/copyright new file mode 100644 index 000000000..193b45e6a --- /dev/null +++ b/packaging/repoconfig/debian/copyright @@ -0,0 +1,10 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: Netdata +Upstream-Contact: Costa Tsaousis <costa@netdata.cloud> +Source: https://github.com/netdata/netdata + +Files: * +Copyright: 2021 Netdata Inc. +License: GPL-3+ + On Debian systems, the complete text of the GNU General Public + License version 3 can be found in /usr/share/common-licenses/GPL-3. diff --git a/packaging/repoconfig/debian/rules b/packaging/repoconfig/debian/rules new file mode 100755 index 000000000..0151b96ea --- /dev/null +++ b/packaging/repoconfig/debian/rules @@ -0,0 +1,21 @@ +#!/usr/bin/make -f + +TOP = $(CURDIR)/debian/netdata-repo +TOP_EDGE = $(CURDIR)/debian/netdata-repo-edge +TEMPTOP = $(CURDIR)/debian/tmp + +%: + dh $@ + +override_dh_configure: + true + +override_dh_install: + mkdir -p $(TOP)/etc/apt/sources.list.d $(TOP)/etc/apt/trusted.gpg.d/ + mv -f $(TEMPTOP)/netdata.list $(TOP)/etc/apt/sources.list.d + mv -f $(TEMPTOP)/netdata-archive-keyring.gpg $(TOP)/etc/apt/trusted.gpg.d + cp $(TEMPTOP)/netdata-repoconfig-archive-keyring.gpg $(TOP)/etc/apt/trusted.gpg.d + mkdir -p $(TOP_EDGE)/etc/apt/sources.list.d $(TOP_EDGE)/etc/apt/trusted.gpg.d/ + mv -f $(TEMPTOP)/netdata-edge.list $(TOP_EDGE)/etc/apt/sources.list.d + mv -f $(TEMPTOP)/netdata-edge-archive-keyring.gpg $(TOP_EDGE)/etc/apt/trusted.gpg.d + cp $(TEMPTOP)/netdata-repoconfig-archive-keyring.gpg $(TOP_EDGE)/etc/apt/trusted.gpg.d diff --git a/packaging/repoconfig/debian/source/format b/packaging/repoconfig/debian/source/format new file mode 100644 index 000000000..163aaf8d8 --- /dev/null +++ b/packaging/repoconfig/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/packaging/repoconfig/netdata-edge.repo.centos b/packaging/repoconfig/netdata-edge.repo.centos new file mode 100644 index 000000000..124cf612e --- /dev/null +++ b/packaging/repoconfig/netdata-edge.repo.centos @@ -0,0 +1,19 @@ +[netdata-edge] +name=Netdata Edge +baseurl=https://packagecloud.io/netdata/netdata-edge/el/$releasever/$basearch +repo_gpgcheck=1 +gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-edge/gpgkey +enabled=1 +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt + +[netdata-repoconfig] +name=Netdata Repository Config +baseurl=https://packagecloud.io/netdata/netdata-repoconfig/el/$releasever/$basearch +repo_gpgcheck=1 +gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-repoconfig/gpgkey +enabled=1 +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt diff --git a/packaging/repoconfig/netdata-edge.repo.fedora b/packaging/repoconfig/netdata-edge.repo.fedora new file mode 100644 index 000000000..636fba6e4 --- /dev/null +++ b/packaging/repoconfig/netdata-edge.repo.fedora @@ -0,0 +1,19 @@ +[netdata-edge] +name=Netdata Edge +baseurl=https://packagecloud.io/netdata/netdata-edge/fedora/$releasever/$basearch +repo_gpgcheck=1 +gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-edge/gpgkey +enabled=1 +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt + +[netdata-repoconfig] +name=Netdata Repository Config +baseurl=https://packagecloud.io/netdata/netdata-repoconfig/fedora/$releasever/$basearch +repo_gpgcheck=1 +gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-repoconfig/gpgkey +enabled=1 +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt diff --git a/packaging/repoconfig/netdata-edge.repo.suse b/packaging/repoconfig/netdata-edge.repo.suse new file mode 100644 index 000000000..94db12a51 --- /dev/null +++ b/packaging/repoconfig/netdata-edge.repo.suse @@ -0,0 +1,19 @@ +[netdata-edge] +name=Netdata Edge +baseurl=https://packagecloud.io/netdata/netdata-edge/opensuse/$releasever/$basearch +repo_gpgcheck=1 +pkg_gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-edge/gpgkey +enabled=1 +type=rpm-md +autorefresh=1 + +[netdata-repoconfig] +name=Netdata Repoconfig +baseurl=https://packagecloud.io/netdata/netdata-repoconfig/opensuse/$releasever/$basearch +repo_gpgcheck=1 +pkg_gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-repoconfig/gpgkey +enabled=1 +type=rpm-md +autorefresh=1 diff --git a/packaging/repoconfig/netdata-repo.spec b/packaging/repoconfig/netdata-repo.spec new file mode 100644 index 000000000..6c280b3e7 --- /dev/null +++ b/packaging/repoconfig/netdata-repo.spec @@ -0,0 +1,89 @@ +%{?rhel:%global centos_ver %rhel} + +Name: netdata-repo +Version: 1 +Release: 1 +Summary: Netdata stable repositories configuration. + +Group: System Environment/Base +License: GPLv2 + +Source0: netdata.repo.fedora +Source1: netdata-edge.repo.fedora +Source2: netdata.repo.suse +Source3: netdata-edge.repo.suse +Source4: netdata.repo.centos +Source5: netdata-edge.repo.centos + +BuildArch: noarch + +# Overlapping file installs +Conflicts: netdata-repo-edge + +%description +This package contains the official Netdata package repository configuration for stable versions of Netdata. + +%prep +%setup -q -c -T + +%if 0%{?fedora} +install -pm 644 %{SOURCE0} ./netdata.repo +install -pm 644 %{SOURCE1} ./netdata-edge.repo +%endif + +%if 0%{?suse_version} +install -pm 644 %{SOURCE2} ./netdata.repo +install -pm 644 %{SOURCE3} ./netdata-edge.repo +%endif + +%if 0%{?centos_ver} +install -pm 644 %{SOURCE4} ./netdata.repo +install -pm 644 %{SOURCE5} ./netdata-edge.repo +%endif + +%build +true + +%install +rm -rf $RPM_BUILD_ROOT + +%if 0%{?suse_version} +install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d +install -pm 644 netdata.repo $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d +install -pm 644 netdata-edge.repo $RPM_BUILD_ROOT%{_sysconfdir}/zypp/repos.d +%else +install -dm 755 $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d +install -pm 644 netdata.repo $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d +install -pm 644 netdata-edge.repo $RPM_BUILD_ROOT%{_sysconfdir}/yum.repos.d +%endif + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%if 0%{?suse_version} +%attr(644,root,root) /etc/zypp/repos.d/netdata.repo +%else +%attr(644,root,root) /etc/yum.repos.d/netdata.repo +%endif + +%package edge +Summary: Netdata nightly repositories configuration. +Group: System Environment/Base + +# Overlapping file installs +Conflicts: netdata-repo + +%description edge +This package contains the official Netdata package repository configuration for nightly versions of Netdata. + +%files edge +%if 0%{?suse_version} +%attr(644,root,root) /etc/zypp/repos.d/netdata-edge.repo +%else +%attr(644,root,root) /etc/yum.repos.d/netdata-edge.repo +%endif + +%changelog +* Mon Jun 14 2021 Austin Hemmelgarn <austin@netdata.cloud> 1-1 +- Initial revision diff --git a/packaging/repoconfig/netdata.list.in b/packaging/repoconfig/netdata.list.in new file mode 100644 index 000000000..9c3ddba01 --- /dev/null +++ b/packaging/repoconfig/netdata.list.in @@ -0,0 +1,2 @@ +deb https://packagecloud.io/netdata/netdata__VARIANT__/__DISTRO__/ __SUITE__ main +deb https://packagecloud.io/netdata/netdata-repoconfig/__DISTRO__/ __SUITE__ main diff --git a/packaging/repoconfig/netdata.repo.centos b/packaging/repoconfig/netdata.repo.centos new file mode 100644 index 000000000..1eb2f2616 --- /dev/null +++ b/packaging/repoconfig/netdata.repo.centos @@ -0,0 +1,19 @@ +[netdata] +name=Netdata +baseurl=https://packagecloud.io/netdata/netdata/el/$releasever/$basearch +repo_gpgcheck=1 +gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata/gpgkey +enabled=1 +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt + +[netdata-repoconfig] +name=Netdata Repository Config +baseurl=https://packagecloud.io/netdata/netdata-repoconfig/el/$releasever/$basearch +repo_gpgcheck=1 +gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-repoconfig/gpgkey +enabled=1 +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt diff --git a/packaging/repoconfig/netdata.repo.fedora b/packaging/repoconfig/netdata.repo.fedora new file mode 100644 index 000000000..5efb5c73a --- /dev/null +++ b/packaging/repoconfig/netdata.repo.fedora @@ -0,0 +1,19 @@ +[netdata] +name=Netdata +baseurl=https://packagecloud.io/netdata/netdata/fedora/$releasever/$basearch +repo_gpgcheck=1 +gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata/gpgkey +enabled=1 +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt + +[netdata-repoconfig] +name=Netdata Repository Config +baseurl=https://packagecloud.io/netdata/netdata-repoconfig/fedora/$releasever/$basearch +repo_gpgcheck=1 +gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-repoconfig/gpgkey +enabled=1 +sslverify=1 +sslcacert=/etc/pki/tls/certs/ca-bundle.crt diff --git a/packaging/repoconfig/netdata.repo.suse b/packaging/repoconfig/netdata.repo.suse new file mode 100644 index 000000000..55ad73e36 --- /dev/null +++ b/packaging/repoconfig/netdata.repo.suse @@ -0,0 +1,19 @@ +[netdata] +name=Netdata +baseurl=https://packagecloud.io/netdata/netdata/opensuse/$releasever/$basearch +repo_gpgcheck=1 +pkg_gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata/gpgkey +enabled=1 +type=rpm-md +autorefresh=1 + +[netdata-repoconfig] +name=Netdata Repoconfig +baseurl=https://packagecloud.io/netdata/netdata-repoconfig/opensuse/$releasever/$basearch +repo_gpgcheck=1 +pkg_gpgcheck=0 +gpgkey=https://packagecloud.io/netdata/netdata-repoconfig/gpgkey +enabled=1 +type=rpm-md +autorefresh=1 diff --git a/packaging/scripts/install.sh b/packaging/scripts/install.sh deleted file mode 100755 index b14ca11e5..000000000 --- a/packaging/scripts/install.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -install_debian_like() { - # This is needed to ensure package installs don't prompt for any user input. - export DEBIAN_FRONTEND=noninteractive - - apt-get update - - # Install NetData - apt-get install -y "/packages/netdata_${VERSION}_${ARCH}.deb" - - # Install testing tools - apt-get install -y --no-install-recommends \ - curl netcat jq -} - -install_fedora_like() { - # Using a glob pattern here because I can't reliably determine what the - # resulting package name will be (TODO: There must be a better way!) - - PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")" - - pkg_version="$(echo "${VERSION}" | tr - .)" - - # Install NetData - "$PKGMGR" install -y /packages/netdata-"${pkg_version}"-*.rpm - - # Install testing tools - "$PKGMGR" install -y curl nc jq -} - -install_centos() { - # Using a glob pattern here because I can't reliably determine what the - # resulting package name will be (TODO: There must be a better way!) - - PKGMGR="$( (command -v dnf > /dev/null && echo "dnf") || echo "yum")" - - pkg_version="$(echo "${VERSION}" | tr - .)" - - # Install EPEL (needed for `jq` - "$PKGMGR" install -y epel-release - - # Install NetData - "$PKGMGR" install -y /packages/netdata-"${pkg_version}"-*.rpm - - # Install testing tools - "$PKGMGR" install -y curl nc jq -} - -install_suse_like() { - # Using a glob pattern here because I can't reliably determine what the - # resulting package name will be (TODO: There must be a better way!) - - pkg_version="$(echo "${VERSION}" | tr - .)" - - # Install NetData - # FIXME: Allow unsigned packages (for now) #7773 - zypper install -y --allow-unsigned-rpm \ - /packages/netdata-"${pkg_version}"-*.rpm - - # Install testing tools - zypper install -y --no-recommends \ - curl gnu-netcat jq -} - -case "${DISTRO}" in - debian | ubuntu) - install_debian_like - ;; - fedora) - install_fedora_like - ;; - centos) - install_centos - ;; - opensuse) - install_suse_like - ;; - *) - printf "ERROR: unsupported distro: %s_%s\n" "${DISTRO}" "${DISTRO_VERSION}" - exit 1 - ;; -esac diff --git a/packaging/scripts/test.sh b/packaging/scripts/test.sh deleted file mode 100755 index c39082622..000000000 --- a/packaging/scripts/test.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -dump_log() { - cat ./netdata.log -} - -trap dump_log EXIT - -wait_for() { - host="${1}" - port="${2}" - name="${3}" - timeout="30" - - if command -v nc > /dev/null ; then - netcat="nc" - elif command -v netcat > /dev/null ; then - netcat="netcat" - else - printf "Unable to find a usable netcat command.\n" - return 1 - fi - - printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}" - - sleep 30 - - i=0 - while ! ${netcat} -z "${host}" "${port}"; do - sleep 1 - if [ "$i" -gt "$timeout" ]; then - printf "Timed out!\n" - return 1 - fi - i="$((i + 1))" - done - printf "OK\n" -} - -/usr/sbin/netdata -D > ./netdata.log 2>&1 & - -wait_for localhost 19999 netdata || exit 1 - -curl -sS http://127.0.0.1:19999/api/v1/info > ./response || exit 1 - -cat ./response - -jq '.version' ./response || exit 1 - -trap - EXIT - -cp -a /packages/* /artifacts diff --git a/packaging/version b/packaging/version index d3aa76971..6d101d3b1 100644 --- a/packaging/version +++ b/packaging/version @@ -1 +1 @@ -v1.31.0 +v1.32.0 |