diff options
Diffstat (limited to 'netdata-installer.sh')
-rwxr-xr-x | netdata-installer.sh | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/netdata-installer.sh b/netdata-installer.sh index 941cf13f..94745a29 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -79,7 +79,7 @@ _cannot_use_tmpdir() { if [ -z "${TMPDIR}" ] || _cannot_use_tmpdir "${TMPDIR}"; then if _cannot_use_tmpdir /tmp; then if _cannot_use_tmpdir "${PWD}"; then - fatal "UUnable to find a usable temporary directory. Please set \$TMPDIR to a path that is both writable and allows execution of files and try again." I0000 + fatal "Unable to find a usable temporary directory. Please set \$TMPDIR to a path that is both writable and allows execution of files and try again." I0000 else TMPDIR="${PWD}" fi @@ -747,14 +747,11 @@ detect_libc() { echo >&2 " Detected musl" libc="musl" else - ls_path=$(command -v ls) - if [ -n "${ls_path}" ] ; then - cmd=$(ldd "$ls_path" | grep -w libc | cut -d" " -f 3) + cmd=$(ldd /bin/sh | grep -w libc | cut -d" " -f 3) if bash -c "${cmd}" 2>&1 | grep -q -i "GNU C Library"; then echo >&2 " Detected GLIBC" libc="glibc" fi - fi fi if [ -z "$libc" ]; then @@ -937,6 +934,34 @@ if [ "$have_autotools" ]; then fi fi +# function to extract values from the config file +config_option() { + section="${1}" + key="${2}" + value="${3}" + + if [ -x "${NETDATA_PREFIX}/usr/sbin/netdata" ] && [ -r "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]; then + "${NETDATA_PREFIX}/usr/sbin/netdata" \ + -c "${NETDATA_PREFIX}/etc/netdata/netdata.conf" \ + -W get "${section}" "${key}" "${value}" || + echo "${value}" + else + echo "${value}" + fi +} + +# the user netdata will run as +if [ "$(id -u)" = "0" ]; then + NETDATA_USER="$(config_option "global" "run as user" "netdata")" + ROOT_USER="root" +else + NETDATA_USER="${USER}" + ROOT_USER="${USER}" +fi +NETDATA_GROUP="$(id -g -n "${NETDATA_USER}")" +[ -z "${NETDATA_GROUP}" ] && NETDATA_GROUP="${NETDATA_USER}" +echo >&2 "Netdata user and group set to: ${NETDATA_USER}/${NETDATA_GROUP}" + # shellcheck disable=SC2086 if ! run ./configure \ --prefix="${NETDATA_PREFIX}/usr" \ @@ -946,7 +971,7 @@ if ! run ./configure \ --libdir="${NETDATA_PREFIX}/usr/lib" \ --with-zlib \ --with-math \ - --with-user=netdata \ + --with-user="${NETDATA_USER}" \ ${NETDATA_CONFIGURE_OPTIONS} \ CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"; then fatal "Failed to configure Netdata sources." I000A @@ -1080,34 +1105,6 @@ progress "Read installation options from netdata.conf" [ ! -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ] && touch "${NETDATA_PREFIX}/etc/netdata/netdata.conf" -# function to extract values from the config file -config_option() { - section="${1}" - key="${2}" - value="${3}" - - if [ -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]; then - "${NETDATA_PREFIX}/usr/sbin/netdata" \ - -c "${NETDATA_PREFIX}/etc/netdata/netdata.conf" \ - -W get "${section}" "${key}" "${value}" || - echo "${value}" - else - echo "${value}" - fi -} - -# the user netdata will run as -if [ "$(id -u)" = "0" ]; then - NETDATA_USER="$(config_option "global" "run as user" "netdata")" - ROOT_USER="root" -else - NETDATA_USER="${USER}" - ROOT_USER="${USER}" -fi -NETDATA_GROUP="$(id -g -n "${NETDATA_USER}")" -[ -z "${NETDATA_GROUP}" ] && NETDATA_GROUP="${NETDATA_USER}" -echo >&2 "Netdata user and group is finally set to: ${NETDATA_USER}/${NETDATA_GROUP}" - # port defport=19999 NETDATA_PORT="$(config_option "web" "default port" ${defport})" @@ -1444,7 +1441,7 @@ install_go() { fi run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin" if command -v setcap 1>/dev/null 2>&1; then - run setcap cap_net_admin+epi "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin" + run setcap "cap_net_admin+epi cap_net_raw=eip" "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/go.d.plugin" fi rm -rf "${tmp}" |