#!/usr/bin/env bash# reload the user profile[-f/etc/profile]&&./etc/profile
exportPATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"# fix PKG_CHECK_MODULES errorif[-d/usr/share/aclocal]thenACLOCAL_PATH=${ACLOCAL_PATH-/usr/share/aclocal}exportACLOCAL_PATH
fiLC_ALL=C
umask022# you can set CFLAGS before running installerCFLAGS="${CFLAGS--O3}"# keep a log of this commandprintf"\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")"service="$(whichservice2>/dev/null||command-vservice2>/dev/null)"systemctl="$(whichsystemctl2>/dev/null||command-vsystemctl2>/dev/null)"
service(){localcmd="${1}"action="${2}"if[!-z"${service}"]thenrun"${service}""${cmd}""${action}"return$?elif[!-z"${systemctl}"]thenrun"${systemctl}""${action}""${cmd}"return$?fireturn1}ME="$0"DONOTSTART=0DONOTWAIT=0NETDATA_PREFIX=LIBS_ARE_HERE=0
usage(){cat<<USAGE${ME} <installer options>Valid <installer options> are: --install /PATH/TO/INSTALL If your 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. --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 -O3If you need to pass different CFLAGS, use something like this: CFLAGS="<gcc options>" ${ME} <installer options>For the installer to complete successfully, you will needthese 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 nodejsUSAGE}md5sum="$(whichmd5sum2>/dev/null||command-vmd5sum2>/dev/null)"
get_git_config_signatures(){localxsfilemd5
[!-d"conf.d"]&&echo>&2"Wrong directory."&&return1[-z"${md5sum}"-o!-x"${md5sum}"]&&echo>&2