#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
# shellcheck disable=SC1090,SC1091,SC1117,SC2002,SC2034,SC2044,SC2046,SC2086,SC2129,SC2162,SC2166,SC2181
export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
uniquepath() {
local path=""
while read; do
if [[ ! ${path} =~ (^|:)"${REPLY}"(:|$) ]]; then
[ ! -z "${path}" ] && path="${path}:"
path="${path}${REPLY}"
fi
done < <(echo "${PATH}" | tr ":" "\n")
[ ! -z "${path}" ] && [[ ${PATH} =~ /bin ]] && [[ ${PATH} =~ /sbin ]] && export PATH="${path}"
}
uniquepath
netdata_source_dir="$(pwd)"
installer_dir="$(dirname "${0}")"
if [ "${netdata_source_dir}" != "${installer_dir}" -a "${installer_dir}" != "." ]; then
echo >&2 "Warning: you are currently in '${netdata_source_dir}' but the installer is in '${installer_dir}'."
fi
# -----------------------------------------------------------------------------
# reload the user profile
[ -f /etc/profile ] && . /etc/profile
# make sure /etc/profile does not change our current directory
cd "${netdata_source_dir}" || exit 1
# -----------------------------------------------------------------------------
# load the required functions
if [ -f "${installer_dir}/packaging/installer/functions.sh" ]; then
source "${installer_dir}/packaging/installer/functions.sh" || exit 1
else
source "${netdata_source_dir}/packaging/installer/functions.sh" || exit 1
fi
# make sure we save all commands we run
run_logfile="netdata-installer.log"
# -----------------------------------------------------------------------------
# fix PKG_CHECK_MODULES error
if [ -d /usr/share/aclocal ]; then
ACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}
export ACLOCAL_PATH
fi
export LC_ALL=C
umask 002
# Be nice on production environments
renice 19 $$ >/dev/null 2>/dev/null
# you can set CFLAGS before running installer
CFLAGS="${CFLAGS--O2}"
[ "z${CFLAGS}" = "z-O3" ] && CFLAGS="-O2"
# keep a log of this command
printf "\n# " >>netdata-installer.log
date >>netdata-installer.log
printf 'CFLAGS="%s" ' "${CFLAGS}" >>netdata-installer.log
printf "%q " "$0" "${@}" >>netdata-installer.log
printf "\n" >>netdata-installer.log
REINSTALL_PWD="${PWD}"
REINSTALL_COMMAND="$(
printf "%q " "$0" "${@}"
printf "\n"
)"
# remove options that shown not be inherited by netdata-updater.sh
REINSTALL_COMMAND="${REINSTALL_COMMAND// --dont-wait/}"
REINSTALL_COMMAND="${REINSTALL_COMMAND// --dont-start-it/}"
[ "${REINSTALL_COMMAND:0:1}" != "." -a "${REINSTALL_COMMAND:0:1}" != "/" -a -f "./${0}" ] && REINSTALL_COMMAND="./${REINSTALL_COMMAND}"
# shellcheck disable=SC2230
setcap="$(which setcap 2>/dev/null || command -v setcap 2>/dev/null)"
ME="$0"
DONOTSTART=0
DONOTWAIT=0
AUTOUPDATE=0
NETDATA_PREFIX=
LIBS_ARE_HERE=0
NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS-}"
usage() {
netdata_banner "installer command line options"
cat <<USAGE
${ME} <installer options>
Valid <installer options> are:
--install /PATH/TO/INSTALL
If you give: --install /opt
netdata will be installed in /opt/netdata
--dont-start-it
Do not (re)start netdata.
Just install it.
--dont-wait
Do not wait for the user to press ENTER.
Start immediately building it.
--auto-update | -u
Install netdata-updater to cron,
to update netdata automatically once per day
(can only be done for installations from git)
--enable-plugin-freeipmi
--disable-plugin-freeipmi
Enable/disable the FreeIPMI plugin.
Default: enable it when libipmimonitoring is available.
--enable-plugin-nfacct
--disable-plugin-nfacct
Enable/disable the nfacct plugin.
Default: enable it when libmnl and libnetfilter_acct are available.
--enable-lto
--disable-lto
Enable/disable Link-Time-Optimization
Default: enabled
--disable-x86-sse
Disable SSE instructions
Default: enabled
--zlib-is-really-here
--libs-are-really-here
If you get errors about missing zlib,
or libuuid but you know it is available,
you have a broken pkg-config.
Use this option to allow it continue
without checking pkg-config.
Netdata will by default be compiled with gcc optimization -O2
If you need to pass different CFLAGS, use something like this:
CFLAGS="<gcc options>" ${ME} <installer options>
For the installer to complete successfully, you will need
these packages installed:
gcc make autoconf automake pkg-config zlib1g-dev (or zlib-devel)
uuid-dev (or libuuid-devel)
For the plugins, you will at least need:
curl, bash v4+, python v2 or v3, node.js
USAGE
}
while [ ! -z "${1}" ]; do
if [ "$1" = "--install" ]; then
NETDATA_PREFIX="${2}/netdata"
shift 2
elif [ "$1" = "--zlib-is-really-here" -o "