#!/usr/bin/env bash# SPDX-License-Identifier: GPL-3.0-or-later# shellcheck disable=SC2046,SC2086,SC2166exportPATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
uniquepath(){localpath=""whileread-r;doif[[!${path}=~(^|:)"${REPLY}"(:|$)]];then[-n"${path}"]&&path="${path}:"path="${path}${REPLY}"fidone<<(echo"${PATH}"|tr":""\\n")[-n"${path}"]&&[[${PATH}=~/bin]]&&[[${PATH}=~/sbin]]&&exportPATH="${path}"}
uniquepath
PROGRAM="$0"NETDATA_SOURCE_DIR="$(pwd)"INSTALLER_DIR="$(dirname"${PROGRAM}")"if["${NETDATA_SOURCE_DIR}"!="${INSTALLER_DIR}"]&&["${INSTALLER_DIR}"!="."];thenecho>&2"Warning: you are currently in '${NETDATA_SOURCE_DIR}' but the installer is in '${INSTALLER_DIR}'."fi# -----------------------------------------------------------------------------# reload the user profile# shellcheck source=/dev/null[-f/etc/profile]&&./etc/profile
# make sure /etc/profile does not change our current directorycd"${NETDATA_SOURCE_DIR}"||exit1# -----------------------------------------------------------------------------# load the required functionsif[-f"${INSTALLER_DIR}/packaging/installer/functions.sh"];then# shellcheck source=packaging/installer/functions.shsource"${INSTALLER_DIR}/packaging/installer/functions.sh"||exit1else# shellcheck source=packaging/installer/functions.shsource"${NETDATA_SOURCE_DIR}/packaging/installer/functions.sh"||exit1fi
download_go(){url="${1}"dest="${2}"ifcommand-vcurl>/dev/null2>&1;thenruncurl-sSL--connect-timeout10--retry3"${url}">"${dest}"elifcommand-vwget>/dev/null2>&1;thenrunwget-T15-O-"${url}">"${dest}"elseecho>&2echo>&2"Downloading go.d plugin from '${url}' failed because of missing mandatory packages."echo>&2"Either add packages or disable it by issuing '--disable-go' in the installer"echo>&2run_failed"I need curl or wget to proceed, but neither is available on this system."fi}# make sure we save all commands we runrun_logfile="net