summaryrefslogtreecommitdiffstats
path: root/packaging
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-08 07:30:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-02-08 07:30:37 +0000
commit8a7b72f7cd1ccd547a03eb4243294e741d661d3f (patch)
tree7bc7be4a8e9e298daa1349348400aa2a653866f2 /packaging
parentNew upstream version 1.11.1+dfsg (diff)
downloadnetdata-8a7b72f7cd1ccd547a03eb4243294e741d661d3f.tar.xz
netdata-8a7b72f7cd1ccd547a03eb4243294e741d661d3f.zip
Adding upstream version 1.12.0.upstream/1.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--packaging/docker/Dockerfile (renamed from docker/Dockerfile)19
-rw-r--r--packaging/docker/README.md (renamed from docker/README.md)27
-rwxr-xr-xpackaging/docker/build.sh (renamed from docker/build.sh)47
-rw-r--r--packaging/docker/run.sh (renamed from docker/run.sh)5
-rw-r--r--packaging/go.d.checksums16
-rw-r--r--packaging/installer/.keep0
-rw-r--r--packaging/installer/README.md (renamed from installer/README.md)245
-rw-r--r--packaging/installer/UNINSTALL.md22
-rw-r--r--packaging/installer/UPDATE.md55
-rw-r--r--packaging/installer/functions.sh797
-rwxr-xr-xpackaging/installer/kickstart-static64.sh (renamed from kickstart-static64.sh)2
-rwxr-xr-xpackaging/installer/kickstart.sh272
-rwxr-xr-xpackaging/installer/netdata-uninstaller.sh169
-rw-r--r--packaging/installer/netdata-updater.sh115
-rw-r--r--packaging/maintainers/README.md75
-rw-r--r--packaging/makeself/README.md48
-rwxr-xr-xpackaging/makeself/build-x86_64-static.sh (renamed from makeself/build-x86_64-static.sh)4
-rwxr-xr-xpackaging/makeself/build.sh (renamed from makeself/build.sh)2
-rwxr-xr-xpackaging/makeself/functions.sh (renamed from makeself/functions.sh)8
-rwxr-xr-xpackaging/makeself/install-alpine-packages.sh (renamed from makeself/install-alpine-packages.sh)0
-rwxr-xr-xpackaging/makeself/install-or-update.sh (renamed from makeself/install-or-update.sh)0
-rwxr-xr-xpackaging/makeself/jobs/10-prepare-destination.install.sh (renamed from makeself/jobs/10-prepare-destination.install.sh)1
-rwxr-xr-xpackaging/makeself/jobs/50-bash-4.4.18.install.sh (renamed from makeself/jobs/50-bash-4.4.18.install.sh)2
-rwxr-xr-xpackaging/makeself/jobs/50-curl-7.60.0.install.sh (renamed from makeself/jobs/50-curl-7.60.0.install.sh)0
-rwxr-xr-xpackaging/makeself/jobs/50-fping-4.0.install.sh (renamed from makeself/jobs/50-fping-4.0.install.sh)0
-rwxr-xr-xpackaging/makeself/jobs/70-netdata-git.install.sh (renamed from makeself/jobs/70-netdata-git.install.sh)0
-rwxr-xr-xpackaging/makeself/jobs/99-makeself.install.sh (renamed from makeself/jobs/99-makeself.install.sh)50
-rwxr-xr-xpackaging/makeself/makeself-header.sh (renamed from makeself/makeself-header.sh)4
-rw-r--r--packaging/makeself/makeself-help-header.txt (renamed from makeself/makeself-help-header.txt)8
-rw-r--r--packaging/makeself/makeself-license.txt (renamed from makeself/makeself-license.txt)8
-rw-r--r--packaging/makeself/makeself.lsm (renamed from makeself/makeself.lsm)0
-rwxr-xr-xpackaging/makeself/makeself.sh (renamed from makeself/makeself.sh)22
-rwxr-xr-xpackaging/makeself/post-installer.sh (renamed from makeself/post-installer.sh)0
-rwxr-xr-xpackaging/makeself/run-all-jobs.sh (renamed from makeself/run-all-jobs.sh)2
-rw-r--r--packaging/version1
35 files changed, 1826 insertions, 200 deletions
diff --git a/docker/Dockerfile b/packaging/docker/Dockerfile
index a852f3044..73cd9030f 100644
--- a/docker/Dockerfile
+++ b/packaging/docker/Dockerfile
@@ -6,6 +6,7 @@
ARG ARCH=amd64-v3.8
FROM multiarch/alpine:${ARCH} as builder
+ARG OUTPUT="/dev/stdout"
# Install prerequisites
RUN apk --no-cache add alpine-sdk \
autoconf \
@@ -33,8 +34,7 @@ WORKDIR /opt/netdata.git
# Install from source
RUN chmod +x netdata-installer.sh && \
- sync && sleep 1 && \
- ./netdata-installer.sh --dont-wait --dont-start-it
+ ./netdata-installer.sh --dont-wait --dont-start-it &>${OUTPUT}
# files to one directory
RUN mkdir -p /app/usr/sbin/ \
@@ -51,14 +51,14 @@ RUN mkdir -p /app/usr/sbin/ \
mv /var/lib/netdata /app/var/lib/ && \
mv /etc/netdata /app/etc/ && \
mv /usr/sbin/netdata /app/usr/sbin/ && \
- mv docker/run.sh /app/usr/sbin/ && \
+ mv packaging/docker/run.sh /app/usr/sbin/ && \
chmod +x /app/usr/sbin/run.sh
#####################################################################
ARG ARCH
FROM multiarch/alpine:${ARCH}
-# Reinstall some prerequisites
+# Install some prerequisites
RUN apk --no-cache add curl \
fping \
jq \
@@ -71,6 +71,15 @@ RUN apk --no-cache add curl \
py-yaml \
python
+# Conditional subscribiton to Polyverse's Polymorphic Linux repositories
+RUN if [ "$(uname -m)" == "x86_64" ]; then \
+ curl https://sh.polyverse.io | sh -s install gcxce5byVQbtRz0iwfGkozZwy support+netdata@polyverse.io; \
+ apk update; \
+ apk upgrade --available --no-cache; \
+ sed -in 's/^#//g' /etc/apk/repositories; \
+ fi
+
+
# Copy files over
COPY --from=builder /app /
@@ -86,7 +95,7 @@ RUN \
addgroup -g ${NETDATA_GID} -S netdata && \
adduser -S -H -s /usr/sbin/nologin -u ${NETDATA_GID} -h /etc/netdata -G netdata netdata && \
# Apply the permissions as described in
- # https://github.com/netdata/netdata/tree/master/doc/netdata-security.md#netdata-directories
+ # https://github.com/netdata/netdata/wiki/netdata-security#netdata-directories
chown -R root:netdata /etc/netdata && \
chown -R netdata:netdata /var/cache/netdata /var/lib/netdata /usr/share/netdata && \
chown -R root:netdata /usr/lib/netdata && \
diff --git a/docker/README.md b/packaging/docker/README.md
index d624855fb..dba0fa0e6 100644
--- a/docker/README.md
+++ b/packaging/docker/README.md
@@ -1,7 +1,6 @@
# Install netdata with Docker
-> :warning: As of Sep 9th, 2018 we ship [new docker builds](https://github.com/netdata/netdata/pull/3995), running netdata in docker with an ENTRYPOINT directive, not a COMMAND directive. Please adapt your execution scripts accordingly.
-> More information about ENTRYPOINT vs COMMAND is presented by goinbigdata [here](http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/) and by docker docs [here](https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact).
+> :warning: As of Sep 9th, 2018 we ship [new docker builds](https://github.com/netdata/netdata/pull/3995), running netdata in docker with an [ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) directive, not a COMMAND directive. Please adapt your execution scripts accordingly. You can find more information about ENTRYPOINT vs COMMAND is presented by goinbigdata [here](http://goinbigdata.com/docker-run-vs-cmd-vs-entrypoint/) and by docker docs [here](https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact).
>
> Also, the `latest` is now based on alpine, so **`alpine` is not updated any more** and `armv7hf` is now replaced with `armhf` (to comply with https://github.com/multiarch naming), so **`armv7hf` is not updated** either.
@@ -9,6 +8,12 @@
Running netdata in a container for monitoring the whole host, can limit its capabilities. Some data is not accessible or not as detailed as when running netdata on the host.
+## Package scrambling in runtime (x86_64 only)
+
+By default on x86_64 architecture our docker images use Polymorphic Polyverse Linux package scrambling. For increased security you can enable rescrambling of packages during runtime. To do this set environment variable `RESCRAMBLE=true` while starting netdata docker container.
+
+For more information go to [Polyverse site](https://polyverse.io/how-it-works/)
+
## Run netdata with docker command
Quickly start netdata with the docker command line.
@@ -16,8 +21,6 @@ Netdata is then available at http://host:19999
This is good for an internal network or to quickly analyse a host.
-For a permanent installation on a public server, you should [[secure the netdata instance|netdata-security]]. See below for an example of how to install netdata with an SSL reverse proxy and basic authentication.
-
```bash
docker run -d --name=netdata \
-p 19999:19999 \
@@ -29,7 +32,7 @@ docker run -d --name=netdata \
netdata/netdata
```
-above can be converted to docker-compose file for ease of management:
+The above can be converted to docker-compose file for ease of management:
```yaml
version: '3'
@@ -56,10 +59,15 @@ If you want to have your container names resolved by netdata it needs to have ac
grep docker /etc/group | cut -d ':' -f 3
```
+### Pass command line options to Netdata
+
+Since we use an [ENTRYPOINT](https://docs.docker.com/engine/reference/builder/#entrypoint) directive, you can provide [netdata daemon command line options](https://docs.netdata.cloud/daemon/#command-line-options) such as the IP address netdata will be running on, using the [command instruction](https://docs.docker.com/engine/reference/builder/#cmd).
+
## Install Netdata using Docker Compose with SSL/TLS enabled http proxy
-You can use use the following docker-compose.yml and Caddyfile files to run netdata with docker.
-Replace the Domains and email address for Letsencrypt before starting.
+For a permanent installation on a public server, you should [secure the netdata instance](../../docs/netdata-security.md). This section contains an example of how to install netdata with an SSL reverse proxy and basic authentication.
+
+You can use use the following docker-compose.yml and Caddyfile files to run netdata with docker. Replace the Domains and email address for [Letsencrypt](https://letsencrypt.org/) before starting.
### Prerequisites
* [Docker](https://docs.docker.com/install/#server)
@@ -68,8 +76,7 @@ Replace the Domains and email address for Letsencrypt before starting.
### Caddyfile
-This file needs to be placed in /opt with nams Caddyfile. Here you customize your domain and you need to provide your email address to obtain Letsencrypt certificate.
-Certificate renewal will happen automatically and will be executed internally by caddy server.
+This file needs to be placed in /opt with name `Caddyfile`. Here you customize your domain and you need to provide your email address to obtain a Letsencrypt certificate. Certificate renewal will happen automatically and will be executed internally by the caddy server.
```
netdata.example.org {
@@ -115,3 +122,5 @@ services:
### Restrict access with basic auth
You can restrict access by following [official caddy guide](https://caddyserver.com/docs/basicauth) and adding lines to Caddyfile.
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fpackaging%2Fdocker%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/docker/build.sh b/packaging/docker/build.sh
index faaa2db79..6958f05e8 100755
--- a/docker/build.sh
+++ b/packaging/docker/build.sh
@@ -6,6 +6,11 @@
set -e
+if [ ! -f .gitignore ]; then
+ echo "Run as ./packaging/docker/$(basename "$0") from top level directory of git repository"
+ exit 1
+fi
+
if [ "$1" == "" ]; then
VERSION=$(git tag --points-at)
else
@@ -15,36 +20,41 @@ if [ "${VERSION}" == "" ]; then
VERSION="latest"
fi
-REPOSITORY="${REPOSITORY:-netdata}"
-
-echo "Building $VERSION of netdata container"
-
declare -A ARCH_MAP
ARCH_MAP=( ["i386"]="386" ["amd64"]="amd64" ["armhf"]="arm" ["aarch64"]="arm64")
+if [ -z ${DEVEL+x} ]; then
+ declare -a ARCHITECTURES=(i386 armhf aarch64 amd64)
+else
+ declare -a ARCHITECTURES=(amd64)
+ unset DOCKER_PASSWORD
+ unset DOCKER_USERNAME
+fi
-docker run --rm --privileged multiarch/qemu-user-static:register --reset
+REPOSITORY="${REPOSITORY:-netdata}"
+echo "Building ${VERSION} of ${REPOSITORY} container"
-if [ -f Dockerfile ]; then
- cd ../ || exit 1
-fi
+docker run --rm --privileged multiarch/qemu-user-static:register --reset
# Build images using multi-arch Dockerfile.
-for ARCH in i386 armhf aarch64 amd64; do
- docker build --build-arg ARCH="${ARCH}-v3.8" \
- --tag "${REPOSITORY}:${VERSION}-${ARCH}" \
- --file docker/Dockerfile ./ &
+for ARCH in "${ARCHITECTURES[@]}"; do
+ eval docker build \
+ --build-arg ARCH="${ARCH}-v3.8" \
+ --build-arg OUTPUT=/dev/null \
+ --tag "${REPOSITORY}:${VERSION}-${ARCH}" \
+ --file packaging/docker/Dockerfile ./
done
-wait
+
+# There is no reason to continue if we cannot log in to docker hub
+if [ -z ${DOCKER_USERNAME+x} ] || [ -z ${DOCKER_PASSWORD+x} ]; then
+ echo "No docker hub username or password specified. Exiting without pushing images to registry"
+ exit 0
+fi
# Create temporary docker CLI config with experimental features enabled (manifests v2 need it)
mkdir -p /tmp/docker
echo '{"experimental":"enabled"}' > /tmp/docker/config.json
-# Login to docker hub to allow for futher operations
-if [ -z ${DOCKER_USERNAME+x} ] || [ -z ${DOCKER_PASSWORD+x} ]; then
- echo "No docker hub username or password specified. Exiting without pushing images to registry"
- exit 1
-fi
+# Login to docker hub to allow futher operations
echo "$DOCKER_PASSWORD" | docker --config /tmp/docker login -u "$DOCKER_USERNAME" --password-stdin
# Push images to registry
@@ -71,4 +81,3 @@ docker --config /tmp/docker manifest push -p "${REPOSITORY}:${VERSION}"
# Show current manifest (debugging purpose only)
docker --config /tmp/docker manifest inspect "${REPOSITORY}:${VERSION}"
-
diff --git a/docker/run.sh b/packaging/docker/run.sh
index b4cf52c7a..243cae8a2 100644
--- a/docker/run.sh
+++ b/packaging/docker/run.sh
@@ -2,6 +2,11 @@
#set -e
+if [ ${RESCRAMBLE+x} ]; then
+ echo "Reinstalling all packages to get the latest Polymorphic Linux scramble"
+ apk upgrade --update-cache --available
+fi
+
if [ ${PGID+x} ]; then
echo "Adding user netdata to group with id ${PGID}"
addgroup -g "${PGID}" -S hostgroup 2>/dev/null
diff --git a/packaging/go.d.checksums b/packaging/go.d.checksums
new file mode 100644
index 000000000..602852efc
--- /dev/null
+++ b/packaging/go.d.checksums
@@ -0,0 +1,16 @@
+ef1d47b5e36d48c5cc99a837899d74625aec6c5e7a6d810254c56f9e58b9463f *config.tar.gz
+ac4df4040e4b1c1f55613e9c9ea0cea8100a36669ff976e30e90dbb7968337ff *go.d.plugin-v0.0.2.darwin-386
+f0a5938df322336a36c177972d3d328c4fbad927a0abc6edbc7159537a7da870 *go.d.plugin-v0.0.2.darwin-amd64
+aff5a560d2acc5717ee83cf5751062d704050e9a993968c093de284c313f0390 *go.d.plugin-v0.0.2.freebsd-386
+8a0abf3901b25fc37a7c65b931e3a7e4386b46c2b0c37d1f77c05f67eb68c1e9 *go.d.plugin-v0.0.2.freebsd-amd64
+b4a1715435983e60fefed1ca016fa55831ebfed419298cd93961d13a8ce8ee53 *go.d.plugin-v0.0.2.freebsd-arm
+e85e6bc0614d625d2c3f5d89182a640c3adabdb7ad9f2ad6a6d1d0fcef8d8761 *go.d.plugin-v0.0.2.linux-386
+f8b7d17402cfebb20431a2dedb9a7a1097a6be379a6eb187f9df4f39d69dc286 *go.d.plugin-v0.0.2.linux-amd64
+da9a1f5d083c09c644e5234ad73b523202fca5e5872645f8e3d33e3a01b11e71 *go.d.plugin-v0.0.2.linux-arm
+bc8d834840a723472ad116c7a44c5b93dd770356810912ca86cdcb517de076d8 *go.d.plugin-v0.0.2.linux-arm64
+556ec76fea17922ac413916f16061973ad20997cdce18be9ba6da22ddcc4d82d *go.d.plugin-v0.0.2.linux-mips
+9197b386863a48b9c00138fec885049448a5b85582db4e91668d5e21ef207b1a *go.d.plugin-v0.0.2.linux-mips64
+531795a69e5e6f2243a5ee19ed3221e7c6dfdcd690066af678fda505c8b3d81d *go.d.plugin-v0.0.2.linux-mips64le
+bb07367de065958ac429c694acb638c6151a80685081be74aafb65bd72a86022 *go.d.plugin-v0.0.2.linux-mipsle
+b78fa18407b3be1aa29657ea793fec5050c7fefc75ccc88168c7c2d4d4313def *go.d.plugin-v0.0.2.linux-ppc64
+50d37f290ebe0df8d08acff6c8f3f8df0c95d619ebe8b7f592973410b42a23ac *go.d.plugin-v0.0.2.linux-ppc64le
diff --git a/packaging/installer/.keep b/packaging/installer/.keep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/packaging/installer/.keep
diff --git a/installer/README.md b/packaging/installer/README.md
index cbcefab08..eb507a5fc 100644
--- a/installer/README.md
+++ b/packaging/installer/README.md
@@ -1,72 +1,118 @@
# Installation
-![image10](https://cloud.githubusercontent.com/assets/2662304/14253729/534c6f9c-fa95-11e5-8243-93eb0df719aa.gif)
-## Linux package managers
+Netdata is a **monitoring agent**. It is designed to be installed and run on all your systems: **physical** and **virtual** servers, **containers**, even **IoT**.
-You can install the latest release of netdata, using your package manager in
+The best way to install Netdata is directly from source. Our **automatic installer** will install any required system packages and compile Netdata directly on your systems.
- - Arch Linux (`sudo pacman -S netdata`)
- - Alpine Linux (`sudo apk add netdata`)
- - Debian Linux (`sudo apt install netdata`)
- - Gentoo Linux (`sudo emerge --ask netdata`)
- - OpenSUSE (`sudo zypper install netdata`)
- - Solus Linux (`sudo eopkg install netdata`)
- - Ubuntu Linux >= 18.04 (`sudo apt install netdata`)
+!!! warning
+ You can find Netdata packages distributed by third parties. In many cases, these packages are either too old or broken. So, the suggested ways to install Netdata are the ones in this page.
+ **We are currently working to provide our binary packages for all Linux distros.** Stay tuned...
-Please note that the particular packages are not build by netdata.
+1. [Automatic one line installation](#one-line-installation), easy installation from source, **this is the default**
+2. [Install pre-built static binary on any 64bit Linux](#linux-64bit-pre-built-static-binary)
+3. [Run Netdata in a docker container](#run-netdata-in-a-docker-container)
+4. [Manual installation, step by step](#install-netdata-on-linux-manually)
+5. [Install on FreeBSD](#freebsd)
+6. [Install on pfSense](#pfsense)
+7. [Enable on FreeNAS Corral](#freenas)
+8. [Install on macOS (OS X)](#macos)
-## Docker
+See also the list of Netdata [package maintainers](../maintainers) for ASUSTOR NAS, OpenWRT, ReadyNAS, etc.
-You can [Install netdata with Docker](../docker/#install-netdata-with-docker)
+---
+
+## One line installation
+
+> This method is **fully automatic on all Linux** distributions. FreeBSD and MacOS systems need some preparations before installing Netdata for the first time. Check the [FreeBSD](#freebsd) and the [MacOS](#macos) sections for more information.
+
+To install Netdata from source and keep it up to date automatically, run the following:
-## Linux one liner
+```bash
+bash <(curl -Ss https://my-netdata.io/kickstart.sh)
+```
+
+*(do not `sudo` this command, it will do it by itself as needed)*
![](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)
-To install netdata from source to your systems and keep it up to date automatically, run the following:
+<details markdown="1"><summary>Click here for more information and advanced use of this command.</summary>
-:hash:**`bash <(curl -Ss https://my-netdata.io/kickstart.sh)`**
+&nbsp;<br/>
+Verify the integrity of the script with this:
-(do not `sudo` this command, it will do it by itself as needed)
+```bash
+[ "b4632ca6c651de0f667e6d4f6e1015fe" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
+```
+*It should print `OK, VALID` if the script is the one we ship.*
-The command:
+The `kickstart.sh` script:
-1. detects the distro and **installs the required system packages** for building netdata (will ask for confirmation)
-2. downloads the latest netdata source tree to `/usr/src/netdata.git`.
-3. installs netdata by running `./netdata-installer.sh` from the source tree.
-4. installs `netdata-updater.sh` to `cron.daily`, so your netdata installation will be updated daily (you will get a message from cron only if the update fails).
+- detects the Linux distro and **installs the required system packages** for building Netdata (will ask for confirmation)
+- downloads the latest Netdata source tree to `/usr/src/netdata.git`.
+- installs Netdata by running `./netdata-installer.sh` from the source tree.
+- installs `netdata-updater.sh` to `cron.daily`, so your Netdata installation will be updated daily (you will get a message from cron only if the update fails).
+- For QA purposes, this installation method lets us know if it succeed or failed.
The `kickstart.sh` script passes all its parameters to `netdata-installer.sh`, so you can add more parameters to change the installation directory, enable/disable plugins, etc (check below).
-For automated installs, append a space + `--dont-wait` to the command line. You can also append `--dont-start-it` to prevent the installer from starting netdata. Example:
+For automated installs, append a space + `--dont-wait` to the command line. You can also append `--dont-start-it` to prevent the installer from starting Netdata. Example:
-```sh
-bash <(curl -Ss https://my-netdata.io/kickstart.sh) all --dont-wait --dont-start-it
+```bash
+ bash <(curl -Ss https://my-netdata.io/kickstart.sh) --dont-wait --dont-start-it
```
-## Linux 64bit pre-built static binary
+If you don't want to receive automatic updates, add `--no-updates` when executing `kickstart.sh` script.
-You can install a pre-compiled static binary of netdata for any Intel/AMD 64bit Linux system (even those that don't have a package manager, like CoreOS, CirrOS, busybox systems, etc). You can also use these packages on systems with broken or unsupported package managers.
+</details>&nbsp;<br/>
-<br/>![](https://registry.my-netdata.io/api/v1/badge.svg?chart=web_log_nginx.requests_per_url&options=unaligned&dimensions=kickstart64&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=kickstart64&group=sum&after=-86400&label=today&units=installations&precision=0)
+Once Netdata is installed, see [Getting Started](../../docs/GettingStarted.md).
-To install netdata with a binary package on any Linux distro, any kernel version - for **Intel/AMD 64bit** hosts, run the following:
+---
-:hash:&nbsp; **`bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh)`**
+## Linux 64bit pre-built static binary
-(do not `sudo` this command, it will do it by itself as needed; the target system does not need `bash` installed, check below for instructions to run it without `bash`)
+You can install a pre-compiled static binary of Netdata on any Intel/AMD 64bit Linux system
+(even those that don't have a package manager, like CoreOS, CirrOS, busybox systems, etc).
+You can also use these packages on systems with broken or unsupported package managers.
-*Note: The static builds install netdata at `/opt/netdata`*
+To install Netdata with a binary package on any Linux distro, any kernel version - for **Intel/AMD 64bit** hosts, run the following:
-For automated installs, append a space + `--dont-wait` to the command line. You can also append `--dont-start-it` to prevent the installer from starting netdata. Example:
+```bash
+
+ bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh)
+
+```
+
+*(do not `sudo` this command, it will do it by itself as needed; if the target system does not have `bash` installed, see below for instructions to run it without `bash`)*
+
+![](https://registry.my-netdata.io/api/v1/badge.svg?chart=web_log_nginx.requests_per_url&options=unaligned&dimensions=kickstart64&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=kickstart64&group=sum&after=-86400&label=today&units=installations&precision=0)
+
+> The static builds install Netdata at **`/opt/netdata`**
+
+<details markdown="1"><summary>Click here for more information and advanced use of this command.</summary>
+
+&nbsp;<br/>
+Verify the integrity of the script with this:
+
+```bash
+[ "ac8e5cf25399b08c42d37e1a53e1a6d3" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
+```
+
+*It should print `OK, VALID` if the script is the one we ship.*
+
+For automated installs, append a space + `--dont-wait` to the command line. You can also append `--dont-start-it` to prevent the installer from starting Netdata.
+
+Example:
+
+```bash
+
+ bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh) --dont-wait --dont-start-it
-```sh
-bash <(curl -Ss https://my-netdata.io/kickstart-static64.sh) --dont-wait --dont-start-it
```
If your shell fails to handle the above one liner, do this:
-```sh
+```bash
# download the script with curl
curl https://my-netdata.io/kickstart-static64.sh >/tmp/kickstart-static64.sh
@@ -77,39 +123,40 @@ wget -O /tmp/kickstart-static64.sh https://my-netdata.io/kickstart-static64.sh
sh /tmp/kickstart-static64.sh
```
-The static binary files are kept in repo [binary-packages](https://github.com/netdata/binary-packages). You can download any of the `.run` files, and run it. These files are self-extracting shell scripts built with [makeself](https://github.com/megastep/makeself). The target system does **not** need to have bash installed. The same files can be used for updates too.
+- The static binary files are kept in repo [binary-packages](https://github.com/netdata/binary-packages). You can download any of the `.run` files, and run it. These files are self-extracting shell scripts built with [makeself](https://github.com/megastep/makeself).
+- The target system does **not** need to have bash installed.
+- The same files can be used for updates too.
+- For QA purposes, this installation method lets us know if it succeed or failed.
+
+</details>&nbsp;<br/>
+
+Once Netdata is installed, see [Getting Started](../../docs/GettingStarted.md).
-## Other installation methods
+---
-- **Linux manual installation from source**
+## Run Netdata in a Docker container
- Semi-automatic, with more details about the steps involved and actions taken [here](#install-netdata-on-linux-manually)
+You can [Install Netdata with Docker](../docker/#install-netdata-with-docker).
-- **Non-Linux installation**
- - [Install from package or source, on FreeBSD](#freebsd)
- - [Install from package, on pfSense](#pfsense)
- - [Enable netdata on FreeNAS Corral](#freenas)
- - [Install from package or source, on macOS (OS X)](#macos)
+---
- See also the list of netdata [package maintainers](../packaging/maintainers) for ASUSTOR NAS, OpenWRT, ReadyNAS, etc.
-
-## Install netdata on Linux manually
+## Install Netdata on Linux manually
-To install the latest git version of netdata, please follow these 2 steps:
+To install the latest git version of Netdata, please follow these 2 steps:
1. [Prepare your system](#prepare-your-system)
Install the required packages on your system.
-2. [Install netdata](#install-netdata)
+2. [Install Netdata](#install-netdata)
- Download and install netdata. You can also update it the same way.
+ Download and install Netdata. You can also update it the same way.
---
### Prepare your system
-Try our experimental automatic requirements installer (no need to be root). This will try to find the packages that should be installed on your system to build and run netdata. It supports most major Linux distributions released after 2010:
+Try our experimental automatic requirements installer (no need to be root). This will try to find the packages that should be installed on your system to build and run Netdata. It supports most major Linux distributions released after 2010:
- **Alpine** Linux and its derivatives (you have to install `bash` yourself, before using the installer)
- **Arch** Linux and its derivatives
@@ -119,13 +166,13 @@ Try our experimental automatic requirements installer (no need to be root). This
- **SuSe** Linux and its derivatives (including **openSuSe**)
- **SLE12** Must have your system registered with Suse Customer Center or have the DVD. See [#1162](https://github.com/netdata/netdata/issues/1162)
-Install the packages for having a **basic netdata installation** (system monitoring and many applications, without `mysql` / `mariadb`, `postgres`, `named`, hardware sensors and `SNMP`):
+Install the packages for having a **basic Netdata installation** (system monitoring and many applications, without `mysql` / `mariadb`, `postgres`, `named`, hardware sensors and `SNMP`):
```sh
curl -Ss 'https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh' >/tmp/kickstart.sh && bash /tmp/kickstart.sh -i netdata
```
-Install all the required packages for **monitoring everything netdata can monitor**:
+Install all the required packages for **monitoring everything Netdata can monitor**:
```sh
curl -Ss 'https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh' >/tmp/kickstart.sh && bash /tmp/kickstart.sh -i netdata-all
@@ -151,16 +198,16 @@ yum install autoconf automake curl gcc git libmnl-devel libuuid-devel lm_sensors
Please note that for RHEL/CentOS you might need [EPEL](http://www.tecmint.com/how-to-enable-epel-repository-for-rhel-centos-6-5/).
-Once netdata is compiled, to run it the following packages are required (already installed using the above commands):
+Once Netdata is compiled, to run it the following packages are required (already installed using the above commands):
package|description
:-----:|-----------
`libuuid`|part of `util-linux` for GUIDs management
-`zlib`|gzip compression for the internal netdata web server
+`zlib`|gzip compression for the internal Netdata web server
-*netdata will fail to start without the above.*
+*Netdata will fail to start without the above.*
-netdata plugins and various aspects of netdata can be enabled or benefit when these are installed (they are optional):
+Netdata plugins and various aspects of Netdata can be enabled or benefit when these are installed (they are optional):
package|description
:-----:|-----------
@@ -180,34 +227,34 @@ package|description
`libmnl`|for collecting netfilter metrics
`netcat`|for shell plugins to collect metrics from remote systems
-*netdata will greatly benefit if you have the above packages installed, but it will still work without them.*
+*Netdata will greatly benefit if you have the above packages installed, but it will still work without them.*
---
-### Install netdata
+### Install Netdata
-Do this to install and run netdata:
+Do this to install and run Netdata:
```sh
# download it - the directory 'netdata' will be created
-git clone https://github.com/netdata/netdata.git --depth=1
+git clone https://github.com/netdata/netdata.git --depth=100
cd netdata
-# run script with root privileges to build, install, start netdata
+# run script with root privileges to build, install, start Netdata
./netdata-installer.sh
```
* If you don't want to run it straight-away, add `--dont-start-it` option.
-* If you don't want to install it on the default directories, you can run the installer like this: `./netdata-installer.sh --install /opt`. This one will install netdata in `/opt/netdata`.
+* If you don't want to install it on the default directories, you can run the installer like this: `./netdata-installer.sh --install /opt`. This one will install Netdata in `/opt/netdata`.
Once the installer completes, the file `/etc/netdata/netdata.conf` will be created (if you changed the installation directory, the configuration will appear in that directory too).
-You can edit this file to set options. One common option to tweak is `history`, which controls the size of the memory database netdata will use. By default is `3600` seconds (an hour of data at the charts) which makes netdata use about 10-15MB of RAM (depending on the number of charts detected on your system). Check **[[Memory Requirements]]**.
+You can edit this file to set options. One common option to tweak is `history`, which controls the size of the memory database Netdata will use. By default is `3600` seconds (an hour of data at the charts) which makes Netdata use about 10-15MB of RAM (depending on the number of charts detected on your system). Check **[[Memory Requirements]]**.
-To apply the changes you made, you have to restart netdata.
+To apply the changes you made, you have to restart Netdata.
---
@@ -217,49 +264,49 @@ To apply the changes you made, you have to restart netdata.
##### FreeBSD
-You can install netdata from ports or packages collection.
+You can install Netdata from ports or packages collection.
-This is how to install the latest netdata version from sources on FreeBSD:
+This is how to install the latest Netdata version from sources on FreeBSD:
```sh
# install required packages
pkg install bash e2fsprogs-libuuid git curl autoconf automake pkgconf pidof
-# download netdata
-git clone https://github.com/netdata/netdata.git --depth=1
+# download Netdata
+git clone https://github.com/netdata/netdata.git --depth=100
-# install netdata in /opt/netdata
+# install Netdata in /opt/netdata
cd netdata
./netdata-installer.sh --install /opt
```
##### pfSense
-To install netdata on pfSense run the following commands (within a shell or under Diagnostics/Command Prompt within the pfSense web interface).
+To install Netdata on pfSense run the following commands (within a shell or under Diagnostics/Command Prompt within the pfSense web interface).
-Change platform (i386/amd64, etc) and FreeBSD versions (10/11, etc) according to your environment and change netdata version (1.10.0 in example) according to latest version present within the FreeSBD repository:-
+Change platform (i386/amd64, etc) and FreeBSD versions (10/11, etc) according to your environment and change Netdata version (1.10.0 in example) according to latest version present within the FreeSBD repository:-
-Note first three packages are downloaded from the pfSense repository for maintaining compatibility with pfSense, netdata is downloaded from the FreeBSD repository.
+Note first three packages are downloaded from the pfSense repository for maintaining compatibility with pfSense, Netdata is downloaded from the FreeBSD repository.
```
pkg install pkgconf
pkg install bash
pkg install e2fsprogs-libuuid
pkg add http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/netdata-1.11.0.txz
```
-To start netdata manually run `service netdata onestart`
+To start Netdata manually run `service netdata onestart`
-To start netdata automatically at each boot add `service netdata start` as a Shellcmd within the pfSense web interface (under **Services/Shellcmd**, which you need to install beforehand under **System/Package Manager/Available Packages**).
-Shellcmd Type should be set to `Shellcmd`.
+To start Netdata automatically at each boot add `service netdata start` as a Shellcmd within the pfSense web interface (under **Services/Shellcmd**, which you need to install beforehand under **System/Package Manager/Available Packages**).
+Shellcmd Type should be set to `Shellcmd`.
![](https://user-images.githubusercontent.com/36808164/36930790-4db3aa84-1f0d-11e8-8752-cdc08bb7207c.png)
-Alternatively more information can be found in https://doc.pfsense.org/index.php/Installing_FreeBSD_Packages, for achieving the same via the command line and scripts.
+Alternatively more information can be found in https://doc.pfsense.org/index.php/Installing_FreeBSD_Packages, for achieving the same via the command line and scripts.
If you experience an issue with `/usr/bin/install` absense on pfSense 2.3 or earlier, update pfSense or use workaround from [https://redmine.pfsense.org/issues/6643](https://redmine.pfsense.org/issues/6643)
##### FreeNAS
-On FreeNAS-Corral-RELEASE (>=10.0.3), netdata is pre-installed.
+On FreeNAS-Corral-RELEASE (>=10.0.3), Netdata is pre-installed.
-To use netdata, the service will need to be enabled and started from the FreeNAS **[CLI](https://github.com/freenas/cli)**.
+To use Netdata, the service will need to be enabled and started from the FreeNAS **[CLI](https://github.com/freenas/cli)**.
-To enable the netdata service:
+To enable the Netdata service:
```
service netdata config set enable=true
```
@@ -271,9 +318,9 @@ service netdata start
##### macOS
-netdata on macOS still has limited charts, but external plugins do work.
+Netdata on macOS still has limited charts, but external plugins do work.
-You can either install netdata with [Homebrew](https://brew.sh/)
+You can either install Netdata with [Homebrew](https://brew.sh/)
```sh
brew install netdata
@@ -293,29 +340,29 @@ click `Install` in the software update popup window, then
# install required packages
brew install ossp-uuid autoconf automake pkg-config
-# download netdata
-git clone https://github.com/netdata/netdata.git --depth=1
+# download Netdata
+git clone https://github.com/netdata/netdata.git --depth=100
-# install netdata in /usr/local/netdata
+# install Netdata in /usr/local/netdata
cd netdata
sudo ./netdata-installer.sh --install /usr/local
```
-The installer will also install a startup plist to start netdata when your Mac boots.
+The installer will also install a startup plist to start Netdata when your Mac boots.
##### Alpine 3.x
-Execute these commands to install netdata in Alpine Linux 3.x:
+Execute these commands to install Netdata in Alpine Linux 3.x:
```
# install required packages
apk add alpine-sdk bash curl zlib-dev util-linux-dev libmnl-dev gcc make git autoconf automake pkgconfig python logrotate
-# if you plan to run node.js netdata plugins
+# if you plan to run node.js Netdata plugins
apk add nodejs
-# download netdata - the directory 'netdata' will be created
-git clone https://github.com/netdata/netdata.git --depth=1
+# download Netdata - the directory 'netdata' will be created
+git clone https://github.com/netdata/netdata.git --depth=100
cd netdata
@@ -323,11 +370,11 @@ cd netdata
./netdata-installer.sh
-# make netdata start at boot
+# make Netdata start at boot
echo -e "#!/usr/bin/env bash\n/usr/sbin/netdata" >/etc/local.d/netdata.start
chmod 755 /etc/local.d/netdata.start
-# make netdata stop at shutdown
+# make Netdata stop at shutdown
echo -e "#!/usr/bin/env bash\nkillall netdata" >/etc/local.d/netdata.stop
chmod 755 /etc/local.d/netdata.stop
@@ -337,17 +384,15 @@ rc-update add local
##### Synology
-The documentation previously recommended installing the Debian Chroot package from the Synology community package sources and then running netdata from within the chroot. This does not work, as the chroot environment does not have access to `/proc`, and therefore exposes very few metrics to netdata. Additionally, [this issue](https://github.com/SynoCommunity/spksrc/issues/2758), still open as of 2018/06/24, indicates that the Debian Chroot package is not suitable for DSM versions greater than version 5 and may corrupt system libraries and render the NAS unable to boot.
+The documentation previously recommended installing the Debian Chroot package from the Synology community package sources and then running Netdata from within the chroot. This does not work, as the chroot environment does not have access to `/proc`, and therefore exposes very few metrics to Netdata. Additionally, [this issue](https://github.com/SynoCommunity/spksrc/issues/2758), still open as of 2018/06/24, indicates that the Debian Chroot package is not suitable for DSM versions greater than version 5 and may corrupt system libraries and render the NAS unable to boot.
The good news is that the 64-bit static installer works fine if your NAS is one that uses the amd64 architecture. It will install the content into `/opt/netdata`, making future removal safe and simple.
-###### Additional Work
-
-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:
+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.
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 Security](../doc/netdata-security.md#netdata-security):
+3. Change ownership of the following directories, as defined in [Netdata Security](../../docs/netdata-security.md#security-design):
```
$ chown -R root:netdata /opt/netdata/usr/share/netdata
@@ -355,7 +400,7 @@ $ chown -R netdata:netdata /opt/netdata/var/lib/netdata /opt/netdata/var/cache/n
$ chown -R netdata:root /opt/netdata/var/log/netdata
```
-Additionally, as of 2018/06/24, the netdata installer doesn't recognize DSM as an operating system, so no init script is installed. You'll have to do this manually:
+Additionally, as of 2018/06/24, the Netdata installer doesn't recognize DSM as an operating system, so no init script is installed. You'll have to do this manually:
1. Add [this file](https://gist.github.com/oskapt/055d474d7bfef32c49469c1b53e8225f) as `/etc/rc.netdata`. Make it executable with `chmod 0755 /etc/rc.netdata`.
2. Edit `/etc/rc.local` and add a line calling `/etc/rc.netdata` to have it start on boot:
@@ -364,3 +409,5 @@ Additionally, as of 2018/06/24, the netdata installer doesn't recognize DSM as a
# Netdata startup
[ -x /etc/rc.netdata ] && /etc/rc.netdata start
```
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Finstaller%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/packaging/installer/UNINSTALL.md b/packaging/installer/UNINSTALL.md
new file mode 100644
index 000000000..511693b48
--- /dev/null
+++ b/packaging/installer/UNINSTALL.md
@@ -0,0 +1,22 @@
+# Uninstalling netdata
+
+Our self-contained uninstaller is able to remove netdata installations created with shell installer. It doesn't need any other netdata repository files to be run. All it needs is an .environment file, which is created during installation (with shell installer) and put in ${NETDATA_USER_CONFIG_DIR}/.environment (by default /etc/netdata/.environment). That file contains some parameters which are passed to our installer and which are needed during uninstallation process. Mainly two parameters are needed:
+```
+NETDATA_PREFIX
+NETDATA_ADDED_TO_GROUPS
+```
+
+A workflow for uninstallation looks like this:
+
+1. Find your .environment file
+2. If you cannot find that file and would like to uninstall netdata, then create new file with following content:
+```
+NETDATA_PREFIX="<installation prefix>" # put what you used as a parameter to shell installed `--install` flag. Otherwise it should be empty
+NETDATA_ADDED_TO_GROUPS="<additional groups>" # Additional groups for a user running netdata process
+```
+3. Download [netdata-uninstaller.sh](https://github.com/netdata/netdata/blob/master/packaging/installer/netdata-uninstaller.sh) and run it as follows: `netdata-uninstaller.sh --yes --env <path_to_environment_file>`. The default `path_to_environment_file` is `/etc/netdata`, it's the location of the file `.environment` that is used by the uninstaller.
+
+
+Note: This uninstallation method assumes previous installation with netdata-installer.sh or kickstart script. Currently using it when netdata was installed by a package manager can work or cause unexpected results.
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Finstaller%2FUNINSTALL&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/packaging/installer/UPDATE.md b/packaging/installer/UPDATE.md
new file mode 100644
index 000000000..7c0be8323
--- /dev/null
+++ b/packaging/installer/UPDATE.md
@@ -0,0 +1,55 @@
+# Updating netdata after its installation
+
+![image8](https://cloud.githubusercontent.com/assets/2662304/14253735/536f4580-fa95-11e5-9f7b-99112b31a5d7.gif)
+
+
+We suggest to keep your netdata updated. We are actively developing it and you should always update to the latest version.
+
+The update procedure depends on how you installed it:
+
+## You downloaded it from github using git
+
+### Manual update to get the latest git commit
+
+netdata versions older than `v1.12.0-rc2-52` had a `netdata-updater.sh` script in the root directory of the source code, which has now been deprecated. The manual process that works for all versions to get the latest commit in git is to use the `netdata-installer.sh`. The installer preserves your custom configuration and updates the the information of the installation in the `.environment` file under the user configuration directory.
+
+```sh
+# go to the git downloaded directory
+cd /path/to/git/downloaded/netdata
+
+# update your local copy
+git pull
+
+# run the netdata installer
+sudo ./netdata-installer.sh
+```
+
+_Netdata will be restarted with the new version._
+
+Keep in mind, netdata may now have new features, or certain old features may now behave differently. So pay some attention to it after updating.
+
+### Manual update to get the latest nightly build
+
+The `kickstart.sh` one-liner will do a one-time update to the latest nightly build, if executed as follows:
+```
+bash <(curl -Ss https://my-netdata.io/kickstart.sh --no-updates)
+```
+
+### Auto-update
+
+_Please, consider the risks of running an auto-update. Something can always go wrong. Keep an eye on your installation, and run a manual update if something ever fails._
+
+Calling the `netdata-installer.sh` with the `--auto-update` or `-u` option will create the `netdata-updater` script under
+either `/etc/cron.daily/`, or `/etc/periodic/daily/`. Whenever the `netdata-updater` is executed, it checks if a newer nightly build is available and then handles the download, installation and netdata restart.
+
+Note that after Jan 2019, the `kickstart.sh` one-liner `bash <(curl -Ss https://my-netdata.io/kickstart.sh)` calls the `netdata-installer.sh` with the auto-update option. So if you just run the one-liner without options once, your netdata will be kept auto-updated.
+
+
+## You downloaded a binary package
+
+If you installed it from a binary package, the best way is to **obtain a newer copy** from the source you got it in the first place.
+
+If a newer version of netdata is not available from the source you got it, we suggest to uninstall the version you have and follow the **[[Installation]]** instructions for installing a fresh version of netdata.
+
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Finstaller%2FUPDATE&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh
new file mode 100644
index 000000000..a2d7365ea
--- /dev/null
+++ b/packaging/installer/functions.sh
@@ -0,0 +1,797 @@
+# no shebang necessary - this is a library to be sourced
+# SPDX-License-Identifier: GPL-3.0-or-later
+# shellcheck disable=SC1091,SC1117,SC2002,SC2004,SC2034,SC2046,SC2059,SC2086,SC2129,SC2148,SC2154,SC2155,SC2162,SC2166,SC2181,SC2193
+
+# make sure we have a UID
+[ -z "${UID}" ] && UID="$(id -u)"
+
+# -----------------------------------------------------------------------------
+# checking the availability of commands
+
+which_cmd() {
+ # shellcheck disable=SC2230
+ which "${1}" 2>/dev/null || command -v "${1}" 2>/dev/null
+}
+
+check_cmd() {
+ which_cmd "${1}" >/dev/null 2>&1 && return 0
+ return 1
+}
+
+# -----------------------------------------------------------------------------
+
+setup_terminal() {
+ TPUT_RESET=""
+ TPUT_BLACK=""
+ TPUT_RED=""
+ TPUT_GREEN=""
+ TPUT_YELLOW=""
+ TPUT_BLUE=""
+ TPUT_PURPLE=""
+ TPUT_CYAN=""
+ TPUT_WHITE=""
+ TPUT_BGBLACK=""
+ TPUT_BGRED=""
+ TPUT_BGGREEN=""
+ TPUT_BGYELLOW=""
+ TPUT_BGBLUE=""
+ TPUT_BGPURPLE=""
+ TPUT_BGCYAN=""
+ TPUT_BGWHITE=""
+ TPUT_BOLD=""
+ TPUT_DIM=""
+ TPUT_UNDERLINED=""
+ TPUT_BLINK=""
+ TPUT_INVERTED=""
+ TPUT_STANDOUT=""
+ TPUT_BELL=""
+ TPUT_CLEAR=""
+
+ # Is stderr on the terminal? If not, then fail
+ test -t 2 || return 1
+
+ if check_cmd tput; then
+ if [ $(($(tput colors 2>/dev/null))) -ge 8 ]; then
+ # Enable colors
+ TPUT_RESET="$(tput sgr 0)"
+ TPUT_BLACK="$(tput setaf 0)"
+ TPUT_RED="$(tput setaf 1)"
+ TPUT_GREEN="$(tput setaf 2)"
+ TPUT_YELLOW="$(tput setaf 3)"
+ TPUT_BLUE="$(tput setaf 4)"
+ TPUT_PURPLE="$(tput setaf 5)"
+ TPUT_CYAN="$(tput setaf 6)"
+ TPUT_WHITE="$(tput setaf 7)"
+ TPUT_BGBLACK="$(tput setab 0)"
+ TPUT_BGRED="$(tput setab 1)"
+ TPUT_BGGREEN="$(tput setab 2)"
+ TPUT_BGYELLOW="$(tput setab 3)"
+ TPUT_BGBLUE="$(tput setab 4)"
+ TPUT_BGPURPLE="$(tput setab 5)"
+ TPUT_BGCYAN="$(tput setab 6)"
+ TPUT_BGWHITE="$(tput setab 7)"
+ TPUT_BOLD="$(tput bold)"
+ TPUT_DIM="$(tput dim)"
+ TPUT_UNDERLINED="$(tput smul)"
+ TPUT_BLINK="$(tput blink)"
+ TPUT_INVERTED="$(tput rev)"
+ TPUT_STANDOUT="$(tput smso)"
+ TPUT_BELL="$(tput bel)"
+ TPUT_CLEAR="$(tput clear)"
+ fi
+ fi
+
+ return 0
+}
+setup_terminal || echo >/dev/null
+
+progress() {
+ echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
+}
+
+# -----------------------------------------------------------------------------
+
+netdata_banner() {
+ local l1=" ^" \
+ l2=" |.-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-" \
+ l3=" | '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' " \
+ l4=" +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->" \
+ sp=" " \
+ netdata="netdata" start end msg="${*}" chartcolor="${TPUT_DIM}"
+
+ [ ${#msg} -lt ${#netdata} ] && msg="${msg}${sp:0:$((${#netdata} - ${#msg}))}"
+ [ ${#msg} -gt $((${#l2} - 20)) ] && msg="${msg:0:$((${#l2} - 23))}..."
+
+ start="$((${#l2} / 2 - 4))"
+ [ $((start + ${#msg} + 4)) -gt ${#l2} ] && start=$((${#l2} - ${#msg} - 4))
+ end=$((start + ${#msg} + 4))
+
+ echo >&2
+ echo >&2 "${chartcolor}${l1}${TPUT_RESET}"
+ echo >&2 "${chartcolor}${l2:0:start}${sp:0:2}${TPUT_RESET}${TPUT_BOLD}${TPUT_GREEN}${netdata}${TPUT_RESET}${chartcolor}${sp:0:$((end - start - 2 - ${#netdata}))}${l2:end:$((${#l2} - end))}${TPUT_RESET}"
+ echo >&2 "${chartcolor}${l3:0:start}${sp:0:2}${TPUT_RESET}${TPUT_BOLD}${TPUT_CYAN}${msg}${TPUT_RESET}${chartcolor}${sp:0:2}${l3:end:$((${#l2} - end))}${TPUT_RESET}"
+ echo >&2 "${chartcolor}${l4}${TPUT_RESET}"
+ echo >&2
+}
+
+# -----------------------------------------------------------------------------
+# portable service command
+
+service_cmd="$(which_cmd service)"
+rcservice_cmd="$(which_cmd rc-service)"
+systemctl_cmd="$(which_cmd systemctl)"
+service() {
+ local cmd="${1}" action="${2}"
+
+ if [ ! -z "${systemctl_cmd}" ]; then
+ run "${systemctl_cmd}" "${action}" "${cmd}"
+ return $?
+ elif [ ! -z "${service_cmd}" ]; then
+ run "${service_cmd}" "${cmd}" "${action}"
+ return $?
+ elif [ ! -z "${rcservice_cmd}" ]; then
+ run "${rcservice_cmd}" "${cmd}" "${action}"
+ return $?
+ fi
+ return 1
+}
+
+# -----------------------------------------------------------------------------
+# portable pidof
+
+pidof_cmd="$(which_cmd pidof)"
+pidof() {
+ if [ ! -z "${pidof_cmd}" ]; then
+ ${pidof_cmd} "${@}"
+ return $?
+ else
+ ps -acxo pid,comm |
+ sed "s/^ *//g" |
+ grep netdata |
+ cut -d ' ' -f 1
+ return $?
+ fi
+}
+
+# -----------------------------------------------------------------------------
+# portable delete recursively interactively
+
+portable_deletedir_recursively_interactively() {
+ if [ ! -z "$1" -a -d "$1" ]; then
+ if [ "$(uname -s)" = "Darwin" ]; then
+ echo >&2
+ read >&2 -p "Press ENTER to recursively delete directory '$1' > "
+ echo >&2 "Deleting directory '$1' ..."
+ run rm -R "$1"
+ else
+ echo >&2
+ echo >&2 "Deleting directory '$1' ..."
+ run rm -I -R "$1"
+ fi
+ else
+ echo "Directory '$1' does not exist."
+ fi
+}
+
+# -----------------------------------------------------------------------------
+
+export SYSTEM_CPUS=1
+portable_find_processors() {
+ if [ -f "/proc/cpuinfo" ]; then
+ # linux
+ SYSTEM_CPUS=$(grep -c ^processor /proc/cpuinfo)
+ else
+ # freebsd
+ SYSTEM_CPUS=$(sysctl hw.ncpu 2>/dev/null | grep ^hw.ncpu | cut -d ' ' -f 2)
+ fi
+ [ -z "${SYSTEM_CPUS}" -o $((SYSTEM_CPUS)) -lt 1 ] && SYSTEM_CPUS=1
+}
+portable_find_processors
+
+# -----------------------------------------------------------------------------
+
+run_ok() {
+ printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
+}
+
+run_failed() {
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
+}
+
+ESCAPED_PRINT_METHOD=
+printf "%q " test >/dev/null 2>&1
+[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq"
+escaped_print() {
+ if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then
+ printf "%q " "${@}"
+ else
+ printf "%s" "${*}"
+ fi
+ return 0
+}
+
+run_logfile="/dev/null"
+run() {
+ local user="${USER--}" dir="${PWD}" info info_console
+
+ if [ "${UID}" = "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 >>"${run_logfile}" "${info}"
+ escaped_print >>"${run_logfile}" "${@}"
+ printf >>"${run_logfile}" " ... "
+
+ printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
+ escaped_print >&2 "${@}"
+ printf >&2 "${TPUT_RESET}\n"
+
+ "${@}"
+
+ local ret=$?
+ if [ ${ret} -ne 0 ]; then
+ run_failed
+ printf >>"${run_logfile}" "FAILED with exit code ${ret}\n"
+ else
+ run_ok
+ printf >>"${run_logfile}" "OK\n"
+ fi
+
+ return ${ret}
+}
+
+getent_cmd="$(which_cmd getent)"
+portable_check_user_exists() {
+ local username="${1}" found=
+
+ if [ ! -z "${getent_cmd}" ]; then
+ "${getent_cmd}" passwd "${username}" >/dev/null 2>&1
+ return $?
+ fi
+
+ found="$(cut -d ':' -f 1 </etc/passwd | grep "^${username}$")"
+ [ "${found}" = "${username}" ] && return 0
+ return 1
+}
+
+portable_check_group_exists() {
+ local groupname="${1}" found=
+
+ if [ ! -z "${getent_cmd}" ]; then
+ "${getent_cmd}" group "${groupname}" >/dev/null 2>&1
+ return $?
+ fi
+
+ found="$(cut -d ':' -f 1 </etc/group | grep "^${groupname}$")"
+ [ "${found}" = "${groupname}" ] && return 0
+ return 1
+}
+
+portable_check_user_in_group() {
+ local username="${1}" groupname="${2}" users=
+
+ if [ ! -z "${getent_cmd}" ]; then
+ users="$(getent group "${groupname}" | cut -d ':' -f 4)"
+ else
+ users="$(grep "^${groupname}:" </etc/group | cut -d ':' -f 4)"
+ fi
+
+ [[ ",${users}," =~ ,${username}, ]] && return 0
+ return 1
+}
+
+portable_add_user() {
+ local username="${1}" homedir="${2}"
+
+ [ -z "${homedir}" ] && homedir="/tmp"
+
+ portable_check_user_exists "${username}"
+ [ $? -eq 0 ] && echo >&2 "User '${username}' already exists." && return 0
+
+ echo >&2 "Adding ${username} user account with home ${homedir} ..."
+
+ # shellcheck disable=SC2230
+ local nologin="$(which nologin 2>/dev/null || command -v nologin 2>/dev/null || echo '/bin/false')"
+
+ # Linux
+ if check_cmd useradd; then
+ run useradd -r -g "${username}" -c "${username}" -s "${nologin}" --no-create-home -d "${homedir}" "${username}" && return 0
+ fi
+
+ # FreeBSD
+ if check_cmd pw; then
+ run pw useradd "${username}" -d "${homedir}" -g "${username}" -s "${nologin}" && return 0
+ fi
+
+ # BusyBox
+ if check_cmd adduser; then
+ run adduser -h "${homedir}" -s "${nologin}" -D -G "${username}" "${username}" && return 0
+ fi
+
+ echo >&2 "Failed to add ${username} user account !"
+
+ return 1
+}
+
+portable_add_group() {
+ local groupname="${1}"
+
+ portable_check_group_exists "${groupname}"
+ [ $? -eq 0 ] && echo >&2 "Group '${groupname}' already exists." && return 0
+
+ echo >&2 "Adding ${groupname} user group ..."
+
+ # Linux
+ if check_cmd groupadd; then
+ run groupadd -r "${groupname}" && return 0
+ fi
+
+ # FreeBSD
+ if check_cmd pw; then
+ run pw groupadd "${groupname}" && return 0
+ fi
+
+ # BusyBox
+ if check_cmd addgroup; then
+ run addgroup "${groupname}" && return 0
+ fi
+
+ echo >&2 "Failed to add ${groupname} user group !"
+ return 1
+}
+
+portable_add_user_to_group() {
+ local groupname="${1}" username="${2}"
+
+ portable_check_group_exists "${groupname}"
+ [ $? -ne 0 ] && echo >&2 "Group '${groupname}' does not exist." && return 1
+
+ # find the user is already in the group
+ if portable_check_user_in_group "${username}" "${groupname}"; then
+ # username is already there
+ echo >&2 "User '${username}' is already in group '${groupname}'."
+ return 0
+ else
+ # username is not in group
+ echo >&2 "Adding ${username} user to the ${groupname} group ..."
+
+ # Linux
+ if check_cmd usermod; then
+ run usermod -a -G "${groupname}" "${username}" && return 0
+ fi
+
+ # FreeBSD
+ if check_cmd pw; then
+ run pw groupmod "${groupname}" -m "${username}" && return 0
+ fi
+
+ # BusyBox
+ if check_cmd addgroup; then
+ run addgroup "${username}" "${groupname}" && return 0
+ fi
+
+ echo >&2 "Failed to add user ${username} to group ${groupname} !"
+ return 1
+ fi
+}
+
+iscontainer() {
+ # man systemd-detect-virt
+ local cmd=$(which_cmd systemd-detect-virt)
+ if [ ! -z "${cmd}" -a -x "${cmd}" ]; then
+ "${cmd}" --container >/dev/null 2>&1 && return 0
+ fi
+
+ # /proc/1/sched exposes the host's pid of our init !
+ # http://stackoverflow.com/a/37016302
+ local pid=$(cat /proc/1/sched 2>/dev/null | head -n 1 | {
+ IFS='(),#:' read name pid th threads
+ echo $pid
+ })
+ if [ ! -z "${pid}" ]; then
+ pid=$(( pid + 0 ))
+ [ ${pid} -gt 1 ] && return 0
+ fi
+
+ # lxc sets environment variable 'container'
+ [ ! -z "${container}" ] && return 0
+
+ # docker creates /.dockerenv
+ # http://stackoverflow.com/a/25518345
+ [ -f "/.dockerenv" ] && return 0
+
+ # ubuntu and debian supply /bin/running-in-container
+ # https://www.apt-browse.org/browse/ubuntu/trusty/main/i386/upstart/1.12.1-0ubuntu4/file/bin/running-in-container
+ if [ -x "/bin/running-in-container" ]; then
+ "/bin/running-in-container" >/dev/null 2>&1 && return 0
+ fi
+
+ return 1
+}
+
+issystemd() {
+ local pids p myns ns systemctl
+
+ # if the directory /lib/systemd/system OR /usr/lib/systemd/system (SLES 12.x) does not exit, it is not systemd
+ [ ! -d /lib/systemd/system -a ! -d /usr/lib/systemd/system ] && return 1
+
+ # if there is no systemctl command, it is not systemd
+ # shellcheck disable=SC2230
+ systemctl=$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)
+ [ -z "${systemctl}" -o ! -x "${systemctl}" ] && return 1
+
+ # if pid 1 is systemd, it is systemd
+ [ "$(basename $(readlink /proc/1/exe) 2>/dev/null)" = "systemd" ] && return 0
+
+ # if systemd is not running, it is not systemd
+ pids=$(pidof systemd 2>/dev/null)
+ [ -z "${pids}" ] && return 1
+
+ # check if the running systemd processes are not in our namespace
+ myns="$(readlink /proc/self/ns/pid 2>/dev/null)"
+ for p in ${pids}; do
+ ns="$(readlink /proc/${p}/ns/pid 2>/dev/null)"
+
+ # if pid of systemd is in our namespace, it is systemd
+ [ ! -z "${myns}" ] && [ "${myns}" = "${ns}" ] && return 0
+ done
+
+ # else, it is not systemd
+ return 1
+}
+
+install_non_systemd_init() {
+ [ "${UID}" != 0 ] && return 1
+
+ local key="unknown"
+ if [ -f /etc/os-release ]; then
+ source /etc/os-release || return 1
+ key="${ID}-${VERSION_ID}"
+
+ elif [ -f /etc/redhat-release ]; then
+ key=$(</etc/redhat-release)
+ fi
+
+ if [ -d /etc/init.d -a ! -f /etc/init.d/netdata ]; then
+ if [[ ${key} =~ ^(gentoo|alpine).* ]]; then
+ echo >&2 "Installing OpenRC init file..."
+ run cp system/netdata-openrc /etc/init.d/netdata &&
+ run chmod 755 /etc/init.d/netdata &&
+ run rc-update add netdata default &&
+ return 0
+
+ elif [ "${key}" = "debian-7" \
+ -o "${key}" = "ubuntu-12.04" \
+ -o "${key}" = "ubuntu-14.04" \
+ ]; then
+ echo >&2 "Installing LSB init file..."
+ run cp system/netdata-lsb /etc/init.d/netdata &&
+ run chmod 755 /etc/init.d/netdata &&
+ run update-rc.d netdata defaults &&
+ run update-rc.d netdata enable &&
+ return 0
+ elif [[ ${key} =~ ^(amzn-201[5678]|ol|CentOS release 6|Red Hat Enterprise Linux Server release 6|Scientific Linux CERN SLC release 6|CloudLinux Server release 6).* ]]; then
+ echo >&2 "Installing init.d file..."
+ run cp system/netdata-init-d /etc/init.d/netdata &&
+ run chmod 755 /etc/init.d/netdata &&
+ run chkconfig netdata on &&
+ return 0
+ else
+ echo >&2 "I don't know what init file to install on system '${key}'. Open a github issue to help us fix it."
+ return 1
+ fi
+ elif [ -f /etc/init.d/netdata ]; then
+ echo >&2 "file '/etc/init.d/netdata' already exists."
+ return 0
+ else
+ echo >&2 "I don't know what init file to install on system '${key}'. Open a github issue to help us fix it."
+ fi
+
+ return 1
+}
+
+NETDATA_START_CMD="netdata"
+NETDATA_STOP_CMD="killall netdata"
+
+install_netdata_service() {
+ local uname="$(uname 2>/dev/null)"
+
+ if [ "${UID}" -eq 0 ]; then
+ if [ "${uname}" = "Darwin" ]; then
+
+ if [ -f "/Library/LaunchDaemons/com.github.netdata.plist" ]; then
+ echo >&2 "file '/Library/LaunchDaemons/com.github.netdata.plist' already exists."
+ return 0
+ else
+ echo >&2 "Installing MacOS X plist file..."
+ run cp system/netdata.plist /Library/LaunchDaemons/com.github.netdata.plist &&
+ run launchctl load /Library/LaunchDaemons/com.github.netdata.plist &&
+ return 0
+ fi
+
+ elif [ "${uname}" = "FreeBSD" ]; then
+
+ run cp system/netdata-freebsd /etc/rc.d/netdata &&
+ NETDATA_START_CMD="service netdata start" &&
+ NETDATA_STOP_CMD="service netdata stop" &&
+ return 0
+
+ elif issystemd; then
+ # systemd is running on this system
+ NETDATA_START_CMD="systemctl start netdata"
+ NETDATA_STOP_CMD="systemctl stop netdata"
+
+ SYSTEMD_DIRECTORY=""
+
+ if [ -d "/lib/systemd/system" ]; then
+ SYSTEMD_DIRECTORY="/lib/systemd/system"
+ elif [ -d "/usr/lib/systemd/system" ]; then
+ SYSTEMD_DIRECTORY="/usr/lib/systemd/system"
+ fi
+
+ if [ "${SYSTEMD_DIRECTORY}x" != "x" ]; then
+ echo >&2 "Installing systemd service..."
+ run cp system/netdata.service "${SYSTEMD_DIRECTORY}/netdata.service" &&
+ run systemctl daemon-reload &&
+ run systemctl enable netdata &&
+ return 0
+ else
+ echo >&2 "no systemd directory; cannot install netdata.service"
+ fi
+ else
+ install_non_systemd_init
+ local ret=$?
+
+ if [ ${ret} -eq 0 ]; then
+ if [ ! -z "${service_cmd}" ]; then
+ NETDATA_START_CMD="service netdata start"
+ NETDATA_STOP_CMD="service netdata stop"
+ elif [ ! -z "${rcservice_cmd}" ]; then
+ NETDATA_START_CMD="rc-service netdata start"
+ NETDATA_STOP_CMD="rc-service netdata stop"
+ fi
+ fi
+
+ return ${ret}
+ fi
+ fi
+
+ return 1
+}
+
+# -----------------------------------------------------------------------------
+# stop netdata
+
+pidisnetdata() {
+ if [ -d /proc/self ]; then
+ [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
+ [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
+ return 1
+ fi
+ return 0
+}
+
+stop_netdata_on_pid() {
+ local pid="${1}" ret=0 count=0
+
+ pidisnetdata ${pid} || return 0
+
+ printf >&2 "Stopping netdata on pid ${pid} ..."
+ while [ ! -z "$pid" -a ${ret} -eq 0 ]; do
+ if [ ${count} -gt 45 ]; then
+ echo >&2 "Cannot stop the running netdata on pid ${pid}."
+ return 1
+ fi
+
+ count=$((count + 1))
+
+ run kill ${pid} 2>/dev/null
+ ret=$?
+
+ test ${ret} -eq 0 && printf >&2 "." && sleep 2
+ done
+
+ echo >&2
+ if [ ${ret} -eq 0 ]; then
+ echo >&2 "SORRY! CANNOT STOP netdata ON PID ${pid} !"
+ return 1
+ fi
+
+ echo >&2 "netdata on pid ${pid} stopped."
+ return 0
+}
+
+netdata_pids() {
+ local p myns ns
+
+ myns="$(readlink /proc/self/ns/pid 2>/dev/null)"
+
+ # echo >&2 "Stopping a (possibly) running netdata (namespace '${myns}')..."
+
+ for p in \
+ $(cat /var/run/netdata.pid 2>/dev/null) \
+ $(cat /var/run/netdata/netdata.pid 2>/dev/null) \
+ $(pidof netdata 2>/dev/null); do
+ ns="$(readlink /proc/${p}/ns/pid 2>/dev/null)"
+
+ if [ -z "${myns}" -o -z "${ns}" -o "${myns}" = "${ns}" ]; then
+ pidisnetdata ${p} && echo "${p}"
+ fi
+ done
+}
+
+stop_all_netdata() {
+ local p
+ for p in $(netdata_pids); do
+ stop_netdata_on_pid ${p}
+ done
+}
+
+# -----------------------------------------------------------------------------
+# restart netdata
+
+restart_netdata() {
+ local netdata="${1}"
+ shift
+
+ local started=0
+
+ progress "Start netdata"
+
+ if [ "${UID}" -eq 0 ]; then
+ service netdata stop
+ stop_all_netdata
+ service netdata restart && started=1
+
+ if [ ${started} -eq 1 -a -z "$(netdata_pids)" ]; then
+ echo >&2 "Ooops! it seems netdata is not started."
+ started=0
+ fi
+
+ if [ ${started} -eq 0 ]; then
+ service netdata start && started=1
+ fi
+ fi
+
+ if [ ${started} -eq 1 -a -z "$(netdata_pids)" ]; then
+ echo >&2 "Hm... it seems netdata is still not started."
+ started=0
+ fi
+
+ if [ ${started} -eq 0 ]; then
+ # still not started...
+
+ run stop_all_netdata
+ run "${netdata}" "${@}"
+ return $?
+ fi
+
+ return 0
+}
+
+# -----------------------------------------------------------------------------
+# install netdata logrotate
+
+install_netdata_logrotate() {
+ if [ ${UID} -eq 0 ]; then
+ if [ -d /etc/logrotate.d ]; then
+ if [ ! -f /etc/logrotate.d/netdata ]; then
+ run cp system/netdata.logrotate /etc/logrotate.d/netdata
+ fi
+
+ if [ -f /etc/logrotate.d/netdata ]; then
+ run chmod 644 /etc/logrotate.d/netdata
+ fi
+
+ return 0
+ fi
+ fi
+
+ return 1
+}
+
+# -----------------------------------------------------------------------------
+# download netdata.conf
+
+fix_netdata_conf() {
+ local owner="${1}"
+
+ if [ "${UID}" -eq 0 ]; then
+ run chown "${owner}" "${filename}"
+ fi
+ run chmod 0664 "${filename}"
+}
+
+generate_netdata_conf() {
+ local owner="${1}" filename="${2}" url="${3}"
+
+ if [ ! -s "${filename}" ]; then
+ cat >"${filename}" <<EOFCONF
+# netdata can generate its own config.
+# Get it with:
+#
+# wget -O ${filename} "${url}"
+#
+# or
+#
+# curl -s -o ${filename} "${url}"
+#
+EOFCONF
+ fix_netdata_conf "${owner}"
+ fi
+}
+
+download_netdata_conf() {
+ local owner="${1}" filename="${2}" url="${3}"
+
+ if [ ! -s "${filename}" ]; then
+ echo >&2
+ echo >&2 "-------------------------------------------------------------------------------"
+ echo >&2
+ echo >&2 "Downloading default configuration from netdata..."
+ sleep 5
+
+ # remove a possibly obsolete download
+ [ -f "${filename}.new" ] && rm "${filename}.new"
+
+ # disable a proxy to get data from the local netdata
+ export http_proxy=
+ export https_proxy=
+
+ # try curl
+ run curl -s -o "${filename}.new" "${url}"
+ ret=$?
+
+ if [ ${ret} -ne 0 -o ! -s "${filename}.new" ]; then
+ # try wget
+ run wget -O "${filename}.new" "${url}"
+ ret=$?
+ fi
+
+ if [ ${ret} -eq 0 -a -s "${filename}.new" ]; then
+ run mv "${filename}.new" "${filename}"
+ run_ok "New configuration saved for you to edit at ${filename}"
+ else
+ [ -f "${filename}.new" ] && rm "${filename}.new"
+ run_failed "Cannnot download configuration from netdata daemon using url '${url}'"
+
+ generate_netdata_conf "${owner}" "${filename}" "${url}"
+ fi
+
+ fix_netdata_conf "${owner}"
+ fi
+}
+
+# -----------------------------------------------------------------------------
+# add netdata user and group
+
+NETDATA_WANTED_GROUPS="docker nginx varnish haproxy adm nsd proxy squid ceph nobody"
+NETDATA_ADDED_TO_GROUPS=""
+add_netdata_user_and_group() {
+ local homedir="${1}" g
+
+ if [ ${UID} -eq 0 ]; then
+ portable_add_group netdata || return 1
+ portable_add_user netdata "${homedir}" || return 1
+
+ for g in ${NETDATA_WANTED_GROUPS}; do
+ portable_add_user_to_group ${g} netdata && NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} ${g}"
+ done
+
+ [ ~netdata = / ] && cat <<USERMOD
+
+The netdata user has its home directory set to /
+You may want to change it, using this command:
+
+# usermod -d "${homedir}" netdata
+
+USERMOD
+ return 0
+ fi
+
+ return 1
+}
diff --git a/kickstart-static64.sh b/packaging/installer/kickstart-static64.sh
index 1fe360345..cd13c4190 100755
--- a/kickstart-static64.sh
+++ b/packaging/installer/kickstart-static64.sh
@@ -9,7 +9,7 @@ umask 022
[ -z "${UID}" ] && export UID="$(id -u)"
# ---------------------------------------------------------------------------------------------------------------------
-# library functions copied from installer/functions.sh
+# library functions copied from packaging/installer/functions.sh
which_cmd() {
# shellcheck disable=SC2230
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
new file mode 100755
index 000000000..2a5c874da
--- /dev/null
+++ b/packaging/installer/kickstart.sh
@@ -0,0 +1,272 @@
+#!/usr/bin/env sh
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Run me with:
+#
+# bash <(curl -Ss https://my-netdata.io/kickstart.sh)
+#
+# or (to install all netdata dependencies):
+#
+# bash <(curl -Ss https://my-netdata.io/kickstart.sh) all
+#
+# Other options:
+# --dont-wait do not prompt for user input
+# --non-interactive do not prompt for user input
+# --no-updates do not install script for daily updates
+#
+# This script will:
+#
+# 1. install all netdata compilation dependencies
+# using the package manager of the system
+#
+# 2. download netdata nightly package to temporary directory
+#
+# 3. install netdata
+
+# shellcheck disable=SC2039,SC2059,SC2086
+
+# External files
+PACKAGES_SCRIPT="https://raw.githubusercontent.com/netdata/netdata-demo-site/master/install-required-packages.sh"
+NIGHTLY_PACKAGE_TARBALL="https://storage.googleapis.com/netdata-nightlies/netdata-latest.tar.gz"
+NIGHTLY_PACKAGE_CHECKSUM="https://storage.googleapis.com/netdata-nightlies/sha256sums.txt"
+
+# ---------------------------------------------------------------------------------------------------------------------
+# library functions copied from packaging/installer/functions.sh
+
+setup_terminal() {
+ TPUT_RESET=""
+ TPUT_YELLOW=""
+ 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_YELLOW="$(tput setaf 3)"
+ 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
+
+ return 0
+}
+
+progress() {
+ echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
+}
+
+escaped_print() {
+ if printf "%q " test >/dev/null 2>&1; then
+ printf "%q " "${@}"
+ else
+ printf "%s" "${*}"
+ fi
+ return 0
+}
+
+run() {
+ local dir="${PWD}" info_console
+
+ if [ "${UID}" = "0" ]; then
+ info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# "
+ else
+ info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ "
+ fi
+
+ escaped_print "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" "${@}" "${TPUT_RESET}\n" >&2
+
+ "${@}"
+
+ local ret=$?
+ if [ ${ret} -ne 0 ]; then
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
+ else
+ printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
+ fi
+
+ return ${ret}
+}
+
+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."
+ else
+ read -r -p "Press ENTER to attempt netdata installation > "
+ progress "OK, let's give it a try..."
+ fi
+}
+
+fatal() {
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
+ exit 1
+}
+
+download() {
+ url="${1}"
+ dest="${2}"
+ if command -v wget >/dev/null 2>&1; then
+ run wget -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
+ elif command -v curl >/dev/null 2>&1; then
+ run curl "${url}" >"${dest}" || fatal "Cannot download ${url}"
+ else
+ fatal "I need curl or wget to proceed, but neither is available on this system."
+ fi
+}
+
+detect_bash4() {
+ bash="${1}"
+ if [ -z "${BASH_VERSION}" ]; then
+ # we don't run under bash
+ if [ -n "${bash}" ] && [ -x "${bash}" ]; then
+ # shellcheck disable=SC2016
+ BASH_MAJOR_VERSION=$(${bash} -c 'echo "${BASH_VERSINFO[0]}"')
+ fi
+ else
+ # we run under bash
+ BASH_MAJOR_VERSION="${BASH_VERSINFO[0]}"
+ fi
+
+ if [ -z "${BASH_MAJOR_VERSION}" ]; then
+ 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}"
+ return 1
+ fi
+ return 0
+}
+
+umask 022
+
+sudo=""
+[ -z "${UID}" ] && UID="$(id -u)"
+[ "${UID}" -ne "0" ] && sudo="sudo"
+export PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
+
+setup_terminal || echo >/dev/null
+
+# ---------------------------------------------------------------------------------------------------------------------
+# try to update using autoupdater in the first place
+
+updater=""
+[ -x /etc/periodic/daily/netdata-updater ] && updater=/etc/periodic/daily/netdata-updater
+[ -x /etc/cron.daily/netdata-updater ] && updater=/etc/cron.daily/netdata-updater
+if [ -L "${updater}" ]; then
+ # remove old updater (symlink)
+ run "${sudo}" rm -f "${updater}"
+ updater=""
+fi
+if [ -n "${updater}" ]; then
+ # attempt to run the updater, to respect any compilation settings already in place
+ progress "Re-installing netdata..."
+ run "${sudo}" "${updater}" -f || fatal "Failed to forcefully update netdata"
+ exit 0
+fi
+
+# ---------------------------------------------------------------------------------------------------------------------
+# install required system packages
+
+INTERACTIVE=1
+PACKAGES_INSTALLER_OPTIONS="netdata"
+NETDATA_INSTALLER_OPTIONS=""
+NETDATA_UPDATES="--auto-update"
+while [ -n "${1}" ]; do
+ if [ "${1}" = "all" ]; then
+ PACKAGES_INSTALLER_OPTIONS="netdata-all"
+ shift 1
+ elif [ "${1}" = "--dont-wait" ] || [ "${1}" = "--non-interactive" ]; then
+ INTERACTIVE=0
+ shift 1
+ elif [ "${1}" = "--no-updates" ]; then
+ # echo >&2 "netdata will not auto-update"
+ NETDATA_UPDATES=
+ shift 1
+ else
+ break
+ fi
+done
+
+if [ "${INTERACTIVE}" = "0" ]; then
+ PACKAGES_INSTALLER_OPTIONS="--dont-wait --non-interactive ${PACKAGES_INSTALLER_OPTIONS}"
+ NETDATA_INSTALLER_OPTIONS="--dont-wait"
+fi
+
+# ---------------------------------------------------------------------------------------------------------------------
+# detect system parameters and install dependencies
+
+SYSTEM="$(uname -s)"
+OS="$(uname -o)"
+MACHINE="$(uname -m)"
+
+cat <<EOF
+System : ${SYSTEM}
+Operating System : ${OS}
+Machine : ${MACHINE}
+BASH major version: ${BASH_MAJOR_VERSION}
+EOF
+
+# Check if tmp is mounted as noexec
+if grep -Eq '^[^ ]+ /tmp [^ ]+ ([^ ]*,)?noexec[, ]' /proc/mounts; then
+ pattern="/opt/netdata-kickstart-XXXXXX"
+else
+ pattern="/tmp/netdata-kickstart-XXXXXX"
+fi
+
+tmpdir="$(mktemp -d $pattern)"
+cd "${tmpdir}" || :
+
+if [ "${OS}" != "GNU/Linux" ] && [ "${SYSTEM}" != "Linux" ]; then
+ warning "Cannot detect the packages to be installed on a ${SYSTEM} - ${OS} system."
+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 "Downloading 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..."
+ run ${sudo} "${bash}" "${tmpdir}/install-required-packages.sh" ${PACKAGES_INSTALLER_OPTIONS}
+ if [ $? -ne 0 ] ; then
+ warning "It failed to install all the required packages, but installation might still be possible."
+ fi
+ fi
+
+ fi
+fi
+
+# ---------------------------------------------------------------------------------------------------------------------
+# download netdata nightly package
+
+download "${NIGHTLY_PACKAGE_CHECKSUM}" "${tmpdir}/sha256sum.txt"
+download "${NIGHTLY_PACKAGE_TARBALL}" "${tmpdir}/netdata-latest.tar.gz"
+if ! grep netdata-latest.tar.gz sha256sum.txt | sha256sum --check - >/dev/null 2>&1; then
+ failed "Tarball checksum validation failed. Stopping netdata installation and leaving tarball in ${tmpdir}"
+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"
+
+# ---------------------------------------------------------------------------------------------------------------------
+# install netdata from source
+
+if [ -x netdata-installer.sh ]; then
+ progress "Installing netdata..."
+ run ${sudo} ./netdata-installer.sh ${NETDATA_UPDATES} ${NETDATA_INSTALLER_OPTIONS} "${@}" || fatal "netdata-installer.sh exited with error"
+ rm -rf "${tmpdir}" >/dev/null 2>&1
+else
+ fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh). Leaving all files in ${tmpdir}"
+fi
diff --git a/packaging/installer/netdata-uninstaller.sh b/packaging/installer/netdata-uninstaller.sh
new file mode 100755
index 000000000..96dd62906
--- /dev/null
+++ b/packaging/installer/netdata-uninstaller.sh
@@ -0,0 +1,169 @@
+#!/usr/bin/env bash
+#shellcheck disable=SC2181
+
+# this script will uninstall netdata
+
+# Variables needed by script and taken from '.environment' file:
+# - NETDATA_PREFIX
+# - NETDATA_ADDED_TO_GROUPS
+
+usage="$(basename "$0") [-h] [-f ] -- program to calculate the answer to life, the universe and everything
+
+where:
+ -e, --env path to environment file (defauls to '/etc/netdata/.environment'
+ -f, --force force uninstallation and do not ask any questions
+ -h show this help text
+ -y, --yes flag needs to be set to proceed with uninstallation"
+
+FILE_REMOVAL_STATUS=0
+ENVIRONMENT_FILE="/etc/netdata/.environment"
+INTERACTIVITY="-i"
+YES=0
+while :; do
+ case "$1" in
+ -h | --help)
+ echo "$usage" >&2
+ exit 1
+ ;;
+ -f | --force)
+ INTERACTIVITY="-f"
+ shift
+ ;;
+ -y | --yes)
+ YES=1
+ shift
+ ;;
+ -e | --env)
+ ENVIRONMENT_FILE="$2"
+ shift 2
+ ;;
+ -*)
+ echo "$usage" >&2
+ exit 1
+ ;;
+ *) break ;;
+ esac
+done
+
+if [ "$YES" != "1" ]; then
+ echo "This script will REMOVE netdata from your system."
+ echo "Run it again with --yes to do it."
+ exit 1
+fi
+
+if [[ $EUID -ne 0 ]]; then
+ echo "This script SHOULD be run as root or otherwise it won't delete all installed components."
+ key="n"
+ read -r -s -n 1 -p "Do you want to continue as non-root user [y/n] ? " key
+ if [ "$key" != "y" ] && [ "$key" != "Y" ]; then
+ exit 1
+ fi
+fi
+
+function quit_msg() {
+ echo
+ if [ "$FILE_REMOVAL_STATUS" -eq 0 ]; then
+ echo "Something went wrong :("
+ else
+ echo "Netdata files were successfully removed from your system"
+ fi
+}
+
+function user_input() {
+ TEXT="$1"
+ if [ "${INTERACTIVITY}" == "-i" ]; then
+ read -r -p "$TEXT" >&2
+ fi
+}
+
+function rm_file() {
+ FILE="$1"
+ if [ -f "${FILE}" ]; then
+ rm -v ${INTERACTIVITY} "${FILE}"
+ fi
+}
+
+function rm_dir() {
+ DIR="$1"
+ if [ -n "$DIR" ] && [ -d "$DIR" ]; then
+ user_input "Press ENTER to recursively delete directory '$DIR' > "
+ rm -v -f -R "${DIR}"
+ fi
+}
+
+netdata_pids() {
+ local p myns ns
+ myns="$(readlink /proc/self/ns/pid 2>/dev/null)"
+ for p in \
+ $(cat /var/run/netdata.pid 2>/dev/null) \
+ $(cat /var/run/netdata/netdata.pid 2>/dev/null) \
+ $(pidof netdata 2>/dev/null); do
+
+ ns="$(readlink "/proc/${p}/ns/pid" 2>/dev/null)"
+ #shellcheck disable=SC2002
+ if [ -z "${myns}" ] || [ -z "${ns}" ] || [ "${myns}" = "${ns}" ]; then
+ name="$(cat "/proc/${p}/stat" 2>/dev/null | cut -d '(' -f 2 | cut -d ')' -f 1)"
+ if [ "${name}" = "netdata" ]; then
+ echo "${p}"
+ fi
+ fi
+ done
+}
+
+trap quit_msg EXIT
+
+#shellcheck source=/dev/null
+source "${ENVIRONMENT_FILE}" || exit 1
+
+#### STOP NETDATA
+echo "Stopping a possibly running netdata..."
+for p in $(netdata_pids); do
+ i=0
+ while kill "${p}" 2>/dev/null; do
+ if [ "$i" -gt 30 ]; then
+ echo "Forcefully stopping netdata with pid ${p}"
+ kill -9 "${p}"
+ sleep 2
+ break
+ fi
+ sleep 1
+ i=$((i + 1))
+ done
+done
+sleep 2
+
+#### REMOVE NETDATA FILES
+rm_file /etc/logrotate.d/netdata
+rm_file /etc/systemd/system/netdata.service
+rm_file /lib/systemd/system/netdata.service
+rm_file /usr/lib/systemd/system/netdata.service
+rm_file /etc/init.d/netdata
+rm_file /etc/periodic/daily/netdata-updater
+rm_file /etc/cron.daily/netdata-updater
+
+if [ -n "${NETDATA_PREFIX}" ] && [ -d "${NETDATA_PREFIX}" ]; then
+ rm_dir "${NETDATA_PREFIX}"
+else
+ rm_file "/usr/sbin/netdata"
+ rm_dir "/usr/share/netdata"
+ rm_dir "/usr/libexec/netdata"
+ rm_dir "/var/lib/netdata"
+ rm_dir "/var/cache/netdata"
+ rm_dir "/var/log/netdata"
+ rm_dir "/etc/netdata"
+fi
+
+FILE_REMOVAL_STATUS=1
+
+#### REMOVE NETDATA USER & GROUP
+if [ -n "$NETDATA_ADDED_TO_GROUPS" ]; then
+ user_input "Press ENTER to delete 'netdata' from following groups: '$NETDATA_ADDED_TO_GROUPS' > "
+ for group in $NETDATA_ADDED_TO_GROUPS; do
+ gpasswd -d netdata "${group}"
+ done
+fi
+
+user_input "Press ENTER to delete 'netdata' system user > "
+userdel -f netdata || :
+user_input "Press ENTER to delete 'netdata' system group > "
+groupdel -f netdata || :
diff --git a/packaging/installer/netdata-updater.sh b/packaging/installer/netdata-updater.sh
new file mode 100644
index 000000000..96f7c1270
--- /dev/null
+++ b/packaging/installer/netdata-updater.sh
@@ -0,0 +1,115 @@
+#!/usr/bin/env bash
+#shellcheck disable=SC2164
+
+# this script will uninstall netdata
+
+# Variables needed by script:
+# - PATH
+# - CFLAGS
+# - NETDATA_CONFIGURE_OPTIONS
+# - REINSTALL_COMMAND
+# - NETDATA_TARBALL_URL
+# - NETDATA_TARBALL_CHECKSUM_URL
+# - NETDATA_TARBALL_CHECKSUM
+
+
+# Usually stored in /etc/netdata/.environment
+: "${ENVIRONMENT_FILE:=THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT}"
+
+# shellcheck source=/dev/null
+source "${ENVIRONMENT_FILE}" || exit 1
+
+if [ "${INSTALL_UID}" != "$(id -u)" ]; then
+ echo >&2 "You are running this script as user with uid $(id -u). We recommend to run this script as root (user with uid 0)"
+ exit 1
+fi
+
+# signal netdata to start saving its database
+# this is handy if your database is big
+pids=$(pidof netdata)
+do_not_start=
+if [ -n "${pids}" ]; then
+ #shellcheck disable=SC2086
+ kill -USR1 ${pids}
+else
+ # netdata is currently not running, so do not start it after updating
+ do_not_start="--dont-start-it"
+fi
+
+tmp=
+if [ -t 2 ]; then
+ # we are running on a terminal
+ # open fd 3 and send it to stderr
+ exec 3>&2
+else
+ # we are headless
+ # create a temporary file for the log
+ tmp=$(mktemp /tmp/netdata-updater.log.XXXXXX)
+ # open fd 3 and send it to tmp
+ exec 3>"${tmp}"
+fi
+
+info() {
+ echo >&3 "$(date) : INFO: " "${@}"
+}
+
+error() {
+ echo >&3 "$(date) : ERROR: " "${@}"
+}
+
+# this is what we will do if it fails (head-less only)
+failed() {
+ error "FAILED TO UPDATE NETDATA : ${1}"
+
+ if [ -n "${tmp}" ]; then
+ cat >&2 "${tmp}"
+ rm "${tmp}"
+ fi
+ exit 1
+}
+
+update() {
+ [ -z "${tmp}" ] && info "Running on a terminal - (this script also supports running headless from crontab)"
+
+ # Check if tmp is mounted as noexec
+ if grep -Eq '^[^ ]+ /tmp [^ ]+ ([^ ]*,)?noexec[, ]' /proc/mounts; then
+ pattern="/opt/netdata-updater-XXXXXX"
+ else
+ pattern="/tmp/netdata-updater-XXXXXX"
+ fi
+
+ dir=$(mktemp -d "$pattern")
+
+ cd "$dir"
+
+ wget "${NETDATA_TARBALL_CHECKSUM_URL}" -O sha256sum.txt >&3 2>&3
+ if grep "${NETDATA_TARBALL_CHECKSUM}" sha256sum.txt >&3 2>&3; then
+ info "Newest version is already installed"
+ exit 0
+ fi
+
+ wget "${NETDATA_TARBALL_URL}" -O netdata-latest.tar.gz >&3 2>&3
+ if ! grep netdata-latest.tar.gz sha256sum.txt | sha256sum --check - >&3 2>&3; then
+ failed "Tarball checksum validation failed. Stopping netdata upgrade and leaving tarball in ${dir}"
+ fi
+ NEW_CHECKSUM="$(sha256sum netdata-latest.tar.gz 2>/dev/null| cut -d' ' -f1)"
+ tar -xf netdata-latest.tar.gz >&3 2>&3
+ rm netdata-latest.tar.gz >&3 2>&3
+ cd netdata-*
+
+ info "Re-installing netdata..."
+ ${REINSTALL_COMMAND} --dont-wait ${do_not_start} >&3 2>&3 || failed "FAILED TO COMPILE/INSTALL NETDATA"
+ sed -i '/NETDATA_TARBALL/d' "${ENVIRONMENT_FILE}"
+ cat <<EOF >>"${ENVIRONMENT_FILE}"
+NETDATA_TARBALL_URL="$NETDATA_TARBALL_URL"
+NETDATA_TARBALL_CHECKSUM_URL="$NETDATA_TARBALL_CHECKSUM_URL"
+NETDATA_TARBALL_CHECKSUM="$NEW_CHECKSUM"
+EOF
+
+ rm -rf "${dir}" >&3 2>&3
+ [ -n "${tmp}" ] && rm "${tmp}" && tmp=
+ return 0
+}
+
+# the installer updates this script - so we run and exit in a single line
+update && exit 0
diff --git a/packaging/maintainers/README.md b/packaging/maintainers/README.md
new file mode 100644
index 000000000..9fb36e771
--- /dev/null
+++ b/packaging/maintainers/README.md
@@ -0,0 +1,75 @@
+# Package Maintainers
+
+This page tracks the package maintainers for netdata, for various operating systems and versions.
+
+> Feel free to update it, so that it reflects the current status.
+
+
+---
+
+## Official Linux Distributions
+
+| Linux Distribution | Netdata Version | Maintainer | Related URL |
+| :-: | :-: | :-: | :-- |
+| Arch Linux | Release | @svenstaro | [netdata @ Arch Linux](https://www.archlinux.org/packages/community/x86_64/netdata/) |
+| Arch Linux AUR | Git | @sanskritfritz | [netdata @ AUR](https://aur.archlinux.org/packages/netdata-git/) |
+| Gentoo Linux | Release + Git | @candrews | [netdata @ gentoo](https://github.com/gentoo/gentoo/tree/master/net-analyzer/netdata) |
+| Debian | Release | @lhw @FedericoCeratto | [netdata @ debian](http://salsa.debian.org/debian/netdata) |
+| Slackware | Release | @willysr | [netdata @ slackbuilds](https://slackbuilds.org/repository/14.2/system/netdata/) |
+| Ubuntu | | | |
+| Red Hat / Fedora / Centos | | | |
+| SUSE SLE / openSUSE Tumbleweed & Leap | | | [netdata @ SUSE OpenBuildService](https://software.opensuse.org/package/netdata) |
+
+---
+## FreeBSD
+
+| System | Initial PR | Core Developer | Package Maintainer
+|:-:|:-:|:-:|:-:|
+FreeBSD|#1321|@vlvkobal|@mmokhi
+
+---
+## MacOS
+
+| System | URL | Core Developer | Package Maintainer
+|:-:|:-:|:-:|:-:|
+MacOS Homebrew Formula|[link](https://github.com/Homebrew/homebrew-core/blob/master/Formula/netdata.rb)|@vlvkobal|@rickard-von-essen
+
+---
+## Unofficial Linux Packages
+
+| Linux Distribution | Netdata Version | Maintainer | Related URL |
+| :-: | :-: | :-: | :-- |
+| Ubuntu | Release | @gslin | [netdata @ gslin ppa](https://launchpad.net/~gslin/+archive/ubuntu/netdata) https://github.com/netdata/netdata/issues/69#issuecomment-217458543 |
+
+---
+## Embedded Linux
+
+| Embedded Linux | Netdata Version | Maintainer | Related URL |
+| :-: | :-: | :-: | :-- |
+| ASUSTOR NAS | ? | William Lin | https://www.asustor.com/apps/app_detail?id=532 |
+| OpenWRT | Release | @nitroshift | [openwrt package](https://github.com/openwrt/packages/tree/master/admin/netdata) |
+| ReadyNAS | Release | @NAStools | https://github.com/nastools/netdata |
+| QNAP | Release | QNAP_Stephane | https://forum.qnap.com/viewtopic.php?t=121518 |
+| DietPi | Release | @Fourdee | https://github.com/Fourdee/DietPi |
+
+---
+## Linux Containers
+
+| Containers | Netdata Version | Maintainer | Related URL |
+| :-: | :-: | :-: | :-- |
+| Docker | Git | @titpetric | https://github.com/titpetric/netdata |
+
+---
+## Automation Systems
+
+| Automation Systems | Netdata Version | Maintainer | Related URL |
+| :-: | :-: | :-: | :-- |
+| Ansible | git | @jffz | https://galaxy.ansible.com/jffz/netdata/ |
+| Chef | ? | @sergiopena | https://github.com/sergiopena/netdata-cookbook |
+
+---
+## Packages summary from repology.org
+
+[![Packaging status](https://repology.org/badge/vertical-allrepos/netdata.svg)](https://repology.org/metapackage/netdata/versions)
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fpackaging%2Fmaintainers%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/packaging/makeself/README.md b/packaging/makeself/README.md
new file mode 100644
index 000000000..eb4c380b1
--- /dev/null
+++ b/packaging/makeself/README.md
@@ -0,0 +1,48 @@
+# netdata static binary build
+
+To build the static binary 64-bit distribution package, run:
+
+```bash
+$ cd /path/to/netdata.git
+$ ./packaging/makeself/build-x86_64-static.sh
+```
+
+The program will:
+
+1. setup a new docker container with Alpine Linux
+2. install the required alpine packages (the build environment, needed libraries, etc)
+3. download and compile third party apps that are packaged with netdata (`bash`, `curl`, etc)
+4. compile netdata
+
+Once finished, a file named `netdata-vX.X.X-gGITHASH-x86_64-DATE-TIME.run` will be created in the current directory. This is the netdata binary package that can be run to install netdata on any other computer.
+
+---
+
+## building binaries with debug info
+
+To build netdata binaries with debugging / tracing information in them, use:
+
+```bash
+$ cd /path/to/netdata.git
+$ ./packaging/makeself/build-x86_64-static.sh debug
+```
+
+These binaries are not optimized (they are a bit slower), they have certain features disables (like log flood protection), other features enables (like `debug flags`) and are not stripped (the binary files are bigger, since they now include source code tracing information).
+
+#### debugging netdata binaries
+
+Once you have installed a binary package with debugging info, you will need to install `valgrind` and run this command to start netdata:
+
+```bash
+PATH="/opt/netdata/bin:${PATH}" valgrind --undef-value-errors=no /opt/netdata/bin/srv/netdata -D
+```
+
+The above command, will run netdata under `valgrind`. While netdata runs under `valgrind` it will be 10x slower and use a lot more memory.
+
+If netdata crashes, `valgrind` will print a stack trace of the issue. Open a github issue to let us know.
+
+To stop netdata while it runs under `valgrind`, press Control-C on the console.
+
+> If you omit the parameter `--undef-value-errors=no` to valgrind, you will get hundreds of errors about conditional jumps that depend on uninitialized values. This is normal. Valgrind has heuristics to prevent it from printing such errors for system libraries, but for the static netdata binary, all the required libraries are built into netdata. So, valgrind cannot appply its heuristics and prints them.
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fmakeself%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()
diff --git a/makeself/build-x86_64-static.sh b/packaging/makeself/build-x86_64-static.sh
index b0902512c..69ddf2bf5 100755
--- a/makeself/build-x86_64-static.sh
+++ b/packaging/makeself/build-x86_64-static.sh
@@ -23,7 +23,7 @@ then
# (also inside the container)
#
run sudo docker run -v $(pwd):/usr/src/netdata.git:rw alpine:3.7 \
- /bin/sh /usr/src/netdata.git/makeself/install-alpine-packages.sh
+ /bin/sh /usr/src/netdata.git/packaging/makeself/install-alpine-packages.sh
# save the changes made permanently
id=$(sudo docker ps -l -q)
@@ -34,7 +34,7 @@ fi
run sudo 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/makeself/build.sh "${@}"
+ /bin/sh /usr/src/netdata.git/packaging/makeself/build.sh "${@}"
if [ "${USER}" ]
then
diff --git a/makeself/build.sh b/packaging/makeself/build.sh
index e8c1c9ddc..e5804c523 100755
--- a/makeself/build.sh
+++ b/packaging/makeself/build.sh
@@ -31,7 +31,7 @@ cd $(dirname "$0") || exit 1
# if we don't run inside the netdata repo
# download it and run from it
-if [ ! -f ../netdata-installer.sh ]
+if [ ! -f ../../netdata-installer.sh ]
then
git clone https://github.com/netdata/netdata.git netdata.git || exit 1
cd netdata.git/makeself || exit 1
diff --git a/makeself/functions.sh b/packaging/makeself/functions.sh
index 10b324deb..6c68e5907 100755
--- a/makeself/functions.sh
+++ b/packaging/makeself/functions.sh
@@ -6,9 +6,9 @@
# allow running the jobs by hand
[ -z "${NETDATA_BUILD_WITH_DEBUG}" ] && export NETDATA_BUILD_WITH_DEBUG=0
[ -z "${NETDATA_INSTALL_PATH}" ] && export NETDATA_INSTALL_PATH="${1-/opt/netdata}"
-[ -z "${NETDATA_MAKESELF_PATH}" ] && export NETDATA_MAKESELF_PATH="$(dirname "${0}")/.."
+[ -z "${NETDATA_MAKESELF_PATH}" ] && export NETDATA_MAKESELF_PATH="$(dirname "${0}")/../.."
[ "${NETDATA_MAKESELF_PATH:0:1}" != "/" ] && export NETDATA_MAKESELF_PATH="$(pwd)/${NETDATA_MAKESELF_PATH}"
-[ -z "${NETDATA_SOURCE_PATH}" ] && export NETDATA_SOURCE_PATH="${NETDATA_MAKESELF_PATH}/.."
+[ -z "${NETDATA_SOURCE_PATH}" ] && export NETDATA_SOURCE_PATH="${NETDATA_MAKESELF_PATH}/../.."
export NULL=
# make sure the path does not end with /
@@ -35,7 +35,7 @@ fetch() {
then
run wget -O "${NETDATA_MAKESELF_PATH}/tmp/${tar}" "${url}"
fi
-
+
if [ ! -d "${NETDATA_MAKESELF_PATH}/tmp/${dir}" ]
then
cd "${NETDATA_MAKESELF_PATH}/tmp"
@@ -49,7 +49,7 @@ fetch() {
# -----------------------------------------------------------------------------
# load the functions of the netdata-installer.sh
-. "${NETDATA_SOURCE_PATH}/installer/functions.sh"
+. "${NETDATA_SOURCE_PATH}/packaging/installer/functions.sh"
# -----------------------------------------------------------------------------
diff --git a/makeself/install-alpine-packages.sh b/packaging/makeself/install-alpine-packages.sh
index 695be4d4f..695be4d4f 100755
--- a/makeself/install-alpine-packages.sh
+++ b/packaging/makeself/install-alpine-packages.sh
diff --git a/makeself/install-or-update.sh b/packaging/makeself/install-or-update.sh
index bfcbe720a..bfcbe720a 100755
--- a/makeself/install-or-update.sh
+++ b/packaging/makeself/install-or-update.sh
diff --git a/makeself/jobs/10-prepare-destination.install.sh b/packaging/makeself/jobs/10-prepare-destination.install.sh
index 019732636..06dc82f29 100755
--- a/makeself/jobs/10-prepare-destination.install.sh
+++ b/packaging/makeself/jobs/10-prepare-destination.install.sh
@@ -14,4 +14,3 @@ run cd "${NETDATA_INSTALL_PATH}/usr"
run ln -s ../bin bin
run ln -s ../sbin sbin
run ln -s . local
-
diff --git a/makeself/jobs/50-bash-4.4.18.install.sh b/packaging/makeself/jobs/50-bash-4.4.18.install.sh
index 000765825..3bdf3e751 100755
--- a/makeself/jobs/50-bash-4.4.18.install.sh
+++ b/packaging/makeself/jobs/50-bash-4.4.18.install.sh
@@ -35,7 +35,7 @@ run ./configure \
# --enable-prompt-string-decoding \
# --enable-readline \
# --enable-select \
-
+
run make clean
run make -j${SYSTEM_CPUS}
diff --git a/makeself/jobs/50-curl-7.60.0.install.sh b/packaging/makeself/jobs/50-curl-7.60.0.install.sh
index 2b5c8f139..2b5c8f139 100755
--- a/makeself/jobs/50-curl-7.60.0.install.sh
+++ b/packaging/makeself/jobs/50-curl-7.60.0.install.sh
diff --git a/makeself/jobs/50-fping-4.0.install.sh b/packaging/makeself/jobs/50-fping-4.0.install.sh
index 7928f1aa4..7928f1aa4 100755
--- a/makeself/jobs/50-fping-4.0.install.sh
+++ b/packaging/makeself/jobs/50-fping-4.0.install.sh
diff --git a/makeself/jobs/70-netdata-git.install.sh b/packaging/makeself/jobs/70-netdata-git.install.sh
index 71ea0f63a..71ea0f63a 100755
--- a/makeself/jobs/70-netdata-git.install.sh
+++ b/packaging/makeself/jobs/70-netdata-git.install.sh
diff --git a/makeself/jobs/99-makeself.install.sh b/packaging/makeself/jobs/99-makeself.install.sh
index 0e0d5c9da..182c0b57e 100755
--- a/makeself/jobs/99-makeself.install.sh
+++ b/packaging/makeself/jobs/99-makeself.install.sh
@@ -8,44 +8,25 @@ run cd "${NETDATA_SOURCE_PATH}" || exit 1
# -----------------------------------------------------------------------------
# find the netdata version
-NOWNER="unknown"
-ORIGIN="$(git config --get remote.origin.url || echo "unknown")"
-if [[ "${ORIGIN}" =~ ^git@github.com:.*/netdata.*$ ]]
- then
- NOWNER="${ORIGIN/git@github.com:/}"
- NOWNER="$( echo ${NOWNER} | cut -d '/' -f 1 )"
-
-elif [[ "${ORIGIN}" =~ ^https://github.com/.*/netdata.*$ ]]
- then
- NOWNER="${ORIGIN/https:\/\/github.com\//}"
- NOWNER="$( echo ${NOWNER} | cut -d '/' -f 1 )"
+VERSION="$(git describe --always 2>/dev/null)"
+if [ -z "${VERSION}" ]; then
+ VERSION=$(cat packaging/version)
fi
-# make sure it does not have any slashes in it
-NOWNER="${NOWNER//\//_}"
-
-if [ "${NOWNER}" = "netdata" ]
- then
- NOWNER=
-else
- NOWNER="-${NOWNER}"
+if [ "${VERSION}" == "" ]; then
+ echo >&2 "Cannot find version number. Create makeself executable from source code with git tree structure."
+ exit 1
fi
-VERSION="$(git describe || echo "undefined")"
-[ -z "${VERSION}" ] && VERSION="undefined"
-
-FILE_VERSION="${VERSION}-$(uname -m)-$(date +"%Y%m%d-%H%M%S")${NOWNER}"
-
-
# -----------------------------------------------------------------------------
# copy the files needed by makeself installation
run mkdir -p "${NETDATA_INSTALL_PATH}/system"
run cp \
- makeself/post-installer.sh \
- makeself/install-or-update.sh \
- installer/functions.sh \
+ packaging/makeself/post-installer.sh \
+ packaging/makeself/install-or-update.sh \
+ packaging/installer/functions.sh \
configs.signatures \
system/netdata-init-d \
system/netdata-lsb \
@@ -84,7 +65,7 @@ run rm "${NETDATA_INSTALL_PATH}/sbin" \
# -----------------------------------------------------------------------------
# create the makeself archive
-run sed "s|NETDATA_VERSION|${FILE_VERSION}|g" <"${NETDATA_MAKESELF_PATH}/makeself.lsm" >"${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
+run sed "s|NETDATA_VERSION|${VERSION}|g" <"${NETDATA_MAKESELF_PATH}/makeself.lsm" >"${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
run "${NETDATA_MAKESELF_PATH}/makeself.sh" \
--gzip \
@@ -107,11 +88,12 @@ run rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
# -----------------------------------------------------------------------------
# copy it to the netdata build dir
-FILE="netdata-${FILE_VERSION}.gz.run"
+FILE="netdata-${VERSION}.gz.run"
-run cp "${NETDATA_INSTALL_PATH}.gz.run" "${FILE}"
-echo >&2 "Self-extracting installer copied to '${FILE}'"
+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 "${FILE}" netdata-latest.gz.run
-echo >&2 "Self-extracting installer linked to 'netdata-latest.gz.run'"
+run ln -s "artifacts/${FILE}" netdata-latest.gz.run
+
+echo >&2 "Self-extracting installer moved to 'artifacts/${FILE}'"
diff --git a/makeself/makeself-header.sh b/packaging/makeself/makeself-header.sh
index 19c1c3f99..d77e1717c 100755
--- a/makeself/makeself-header.sh
+++ b/packaging/makeself/makeself-header.sh
@@ -35,7 +35,7 @@ elif test -x /usr/ucb/echo; then
else
print_cmd="echo"
fi
-
+
if test -d /usr/xpg4/bin; then
PATH=/usr/xpg4/bin:\$PATH
export PATH
@@ -388,7 +388,7 @@ fi
if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then
echo "Administrative privileges required for this archive (use su or sudo)" >&2
- exit 1
+ exit 1
fi
if test x"\$copy" \!= xphase2; then
diff --git a/makeself/makeself-help-header.txt b/packaging/makeself/makeself-help-header.txt
index 6e9e96237..bf482c465 100644
--- a/makeself/makeself-help-header.txt
+++ b/packaging/makeself/makeself-help-header.txt
@@ -1,7 +1,7 @@
^
- |.-. .-. .-. .-. . netdata
- | '-' '-' '-' '-' real-time performance monitoring, done right!
+ |.-. .-. .-. .-. . netdata
+ | '-' '-' '-' '-' real-time performance monitoring, done right!
+----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->
(C) Copyright 2017, Costa Tsaousis
@@ -32,7 +32,7 @@
- /etc/init.d/netdata will be created
-
+
This package can also update a netdata installation that has been
created with another version of it.
@@ -42,5 +42,3 @@
netdata re-distributes a lot of open source software components.
Check its full license at:
https://github.com/netdata/netdata/blob/master/LICENSE.md
-
-
diff --git a/makeself/makeself-license.txt b/packaging/makeself/makeself-license.txt
index 6e9e96237..bf482c465 100644
--- a/makeself/makeself-license.txt
+++ b/packaging/makeself/makeself-license.txt
@@ -1,7 +1,7 @@
^
- |.-. .-. .-. .-. . netdata
- | '-' '-' '-' '-' real-time performance monitoring, done right!
+ |.-. .-. .-. .-. . netdata
+ | '-' '-' '-' '-' real-time performance monitoring, done right!
+----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->
(C) Copyright 2017, Costa Tsaousis
@@ -32,7 +32,7 @@
- /etc/init.d/netdata will be created
-
+
This package can also update a netdata installation that has been
created with another version of it.
@@ -42,5 +42,3 @@
netdata re-distributes a lot of open source software components.
Check its full license at:
https://github.com/netdata/netdata/blob/master/LICENSE.md
-
-
diff --git a/makeself/makeself.lsm b/packaging/makeself/makeself.lsm
index 6bd4703db..6bd4703db 100644
--- a/makeself/makeself.lsm
+++ b/packaging/makeself/makeself.lsm
diff --git a/makeself/makeself.sh b/packaging/makeself/makeself.sh
index ee89df9a4..f3cb69976 100755
--- a/makeself/makeself.sh
+++ b/packaging/makeself/makeself.sh
@@ -21,13 +21,13 @@
# support for non-temporary archives. Ideas thanks to Francois Petitjean
# - 1.3 : More patches from Bjarni R. Einarsson and Francois Petitjean:
# Support for no compression (--nocomp), script is no longer mandatory,
-# automatic launch in an xterm, optional verbose output, and -target
+# automatic launch in an xterm, optional verbose output, and -target
# archive option to indicate where to extract the files.
# - 1.4 : Improved UNIX compatibility (Francois Petitjean)
# Automatic integrity checking, support of LSM files (Francois Petitjean)
# - 1.5 : Many bugfixes. Optionally disable xterm spawning.
# - 1.5.1 : More bugfixes, added archive options -list and -check.
-# - 1.5.2 : Cosmetic changes to inform the user of what's going on with big
+# - 1.5.2 : Cosmetic changes to inform the user of what's going on with big
# archives (Quake III demo)
# - 1.5.3 : Check for validity of the DISPLAY variable before launching an xterm.
# More verbosity in xterms and check for embedded command's return value.
@@ -204,9 +204,9 @@ do
shift
;;
--pigz)
- COMPRESS=pigz
- shift
- ;;
+ COMPRESS=pigz
+ shift
+ ;;
--xz)
COMPRESS=xz
shift
@@ -434,7 +434,7 @@ gzip)
GZIP_CMD="gzip -c$COMPRESS_LEVEL"
GUNZIP_CMD="gzip -cd"
;;
-pigz)
+pigz)
GZIP_CMD="pigz -$COMPRESS_LEVEL"
GUNZIP_CMD="gzip -cd"
;;
@@ -497,7 +497,7 @@ if test -f "$HEADER"; then
SKIP=`expr $SKIP`
rm -f "$tmpfile"
if test "$QUIET" = "n";then
- echo Header is $SKIP lines long >&2
+ echo Header is $SKIP lines long >&2
fi
archname="$oldarchname"
@@ -506,7 +506,7 @@ else
exit 1
fi
-if test "$QUIET" = "n";then
+if test "$QUIET" = "n";then
echo
fi
@@ -598,7 +598,7 @@ if test "$APPEND" = y; then
chmod +x "$archname"
rm -f "$archname".bak
if test "$QUIET" = "n";then
- echo Self-extractable archive \"$archname\" successfully updated.
+ echo Self-extractable archive \"$archname\" successfully updated.
fi
else
filesizes="$fsize"
@@ -610,12 +610,12 @@ else
# Append the compressed tar data after the stub
if test "$QUIET" = "n";then
- echo
+ echo
fi
cat "$tmpfile" >> "$archname"
chmod +x "$archname"
if test "$QUIET" = "n";then
- echo Self-extractable archive \"$archname\" successfully created.
+ echo Self-extractable archive \"$archname\" successfully created.
fi
fi
rm -f "$tmpfile"
diff --git a/makeself/post-installer.sh b/packaging/makeself/post-installer.sh
index 38cc41ef7..38cc41ef7 100755
--- a/makeself/post-installer.sh
+++ b/packaging/makeself/post-installer.sh
diff --git a/makeself/run-all-jobs.sh b/packaging/makeself/run-all-jobs.sh
index 7a35fe648..f7507c2d2 100755
--- a/makeself/run-all-jobs.sh
+++ b/packaging/makeself/run-all-jobs.sh
@@ -21,7 +21,7 @@ if [ "${NETDATA_MAKESELF_PATH:0:1}" != "/" ]
fi
# netdata source directory
-export NETDATA_SOURCE_PATH="${NETDATA_MAKESELF_PATH}/.."
+export NETDATA_SOURCE_PATH="${NETDATA_MAKESELF_PATH}/../.."
# make sure ${NULL} is empty
export NULL=
diff --git a/packaging/version b/packaging/version
new file mode 100644
index 000000000..a5effa303
--- /dev/null
+++ b/packaging/version
@@ -0,0 +1 @@
+v1.12.0