#!/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}/installer/functions.sh" ]
then
source "${installer_dir}/installer/functions.sh" || exit 1
else
source "${netdata_source_dir}/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=