From d4dd00f58a502c9ca4b63e36ce6bc7a9945dc63c Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Tue, 27 Mar 2018 22:28:21 +0100 Subject: New upstream version 1.10.0+dfsg --- netdata-installer.sh | 209 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 145 insertions(+), 64 deletions(-) (limited to 'netdata-installer.sh') diff --git a/netdata-installer.sh b/netdata-installer.sh index 356eb4e4f..e433cc189 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -1,6 +1,20 @@ #!/usr/bin/env bash 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}")" @@ -49,9 +63,6 @@ umask 002 # Be nice on production environments renice 19 $$ >/dev/null 2>/dev/null -processors=$(grep -c ^processor /proc/cpuinfo) -[ $(( processors )) -lt 1 ] && processors=1 - # you can set CFLAGS before running installer CFLAGS="${CFLAGS--O2}" [ "z${CFLAGS}" = "z-O3" ] && CFLAGS="-O2" @@ -219,27 +230,27 @@ do shift 1 elif [ "$1" = "--enable-plugin-freeipmi" ] then - NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --enable-plugin-freeipmi" + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-plugin-freeipmi/} --enable-plugin-freeipmi" shift 1 elif [ "$1" = "--disable-plugin-freeipmi" ] then - NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --disable-plugin-freeipmi" + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-plugin-freeipmi/} --disable-plugin-freeipmi" shift 1 elif [ "$1" = "--enable-plugin-nfacct" ] then - NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --enable-plugin-nfacct" + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-plugin-nfacct/} --enable-plugin-nfacct" shift 1 elif [ "$1" = "--disable-plugin-nfacct" ] then - NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --disable-plugin-nfacct" + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-plugin-nfacct/} --disable-plugin-nfacct" shift 1 elif [ "$1" = "--enable-lto" ] then - NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --enable-lto" + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--enable-lto/} --enable-lto" shift 1 elif [ "$1" = "--disable-lto" ] then - NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --disable-lto" + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS//--disable-lto/} --disable-lto" shift 1 elif [ "$1" = "--help" -o "$1" = "-h" ] then @@ -258,6 +269,9 @@ do fi done +# replace multiple spaces with a single space +NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS// / }" + netdata_banner "real-time performance monitoring, done right!" cat </dev/null 2>&1 && admin_group="root" test -z "${admin_group}" && getent group daemon >/dev/null 2>&1 && admin_group="daemon" - test -z "${admin_group}" && admin_group="${NETDATA_USER}" + test -z "${admin_group}" && admin_group="${NETDATA_GROUP}" run chown "${NETDATA_USER}:${admin_group}" "${NETDATA_LOG_DIR}" run chown -R root "${NETDATA_PREFIX}/usr/libexec/netdata" @@ -752,47 +798,59 @@ if [ ${UID} -eq 0 ] run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.plugin -exec chmod 0755 {} \; run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.sh -exec chmod 0755 {} \; - setcap_ret=1 - if ! iscontainer - then - if [ ! -z "${setcap}" ] + if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" ] + then + setcap_ret=1 + if ! iscontainer then - run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" - setcap_ret=$? + if [ ! -z "${setcap}" ] + then + run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" + run chmod 0750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" + run setcap cap_dac_read_search,cap_sys_ptrace+ep "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" + setcap_ret=$? + fi + + if [ ${setcap_ret} -eq 0 ] + then + # if we managed to setcap + # but we fail to execute apps.plugin + # trigger setuid to root + "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" -t >/dev/null 2>&1 + setcap_ret=$? + fi fi - if [ ${setcap_ret} -eq 0 ] + if [ ${setcap_ret} -ne 0 ] then - # if we managed to setcap - # but we fail to execute apps.plugin - # trigger setuid to root - "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" -t >/dev/null 2>&1 - setcap_ret=$? + # fix apps.plugin to be setuid to root + run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" + run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" fi fi - if [ ${setcap_ret} -ne 0 ] + if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" ] then - # fix apps.plugin to be setuid to root - run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" - run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin" + run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" + run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" fi - if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" ] + if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" ] then - run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" - run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/freeipmi.plugin" + run chown root:${NETDATA_GROUP} "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" + run chmod 4750 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" fi - if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" ] + if [ -f "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh" ] then - run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" - run chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network" + run chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh" + run chmod 0550 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/cgroup-network-helper.sh" fi else - run chown "${NETDATA_USER}:${NETDATA_USER}" "${NETDATA_LOG_DIR}" - run chown -R "${NETDATA_USER}:${NETDATA_USER}" "${NETDATA_PREFIX}/usr/libexec/netdata" + # non-privileged user installation + run chown "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_LOG_DIR}" + run chown -R "${NETDATA_USER}:${NETDATA_GROUP}" "${NETDATA_PREFIX}/usr/libexec/netdata" run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0755 {} \; run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \; fi @@ -839,11 +897,13 @@ else download_netdata_conf "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" "http://localhost:${NETDATA_PORT}/netdata.conf" fi -# ----------------------------------------------------------------------------- -progress "Check KSM (kernel memory deduper)" +if [ "$(uname)" = "Linux" ] +then + # ------------------------------------------------------------------------- + progress "Check KSM (kernel memory deduper)" -ksm_is_available_but_disabled() { - cat < /dev/null +if [ $? -eq 0 -a "${NETDATA_ADDED_TO_CEPH}" = "1" ] + then + echo + echo "You may also want to remove the netdata user from the squid group" + echo "by running:" + echo " gpasswd -d netdata ceph" +fi + UNINSTALL chmod 750 netdata-uninstaller.sh @@ -1162,7 +1236,14 @@ cd "${REINSTALL_PWD}" || exit 1 # signal netdata to start saving its database # this is handy if your database is big pids=\$(pidof netdata) -[ ! -z "\${pids}" ] && kill -USR1 \${pids} +do_not_start= +if [ ! -z "\${pids}" ] + then + kill -USR1 \${pids} +else + # netdata is currently not running, so do not start it after updating + do_not_start="--dont-start-it" +fi tmp= if [ -t 2 ] @@ -1233,7 +1314,7 @@ update() { emptyline info "Re-installing netdata..." - ${REINSTALL_COMMAND} --dont-wait >&3 2>&3 || failed "FAILED TO COMPILE/INSTALL NETDATA" + ${REINSTALL_COMMAND} --dont-wait \${do_not_start} >&3 2>&3 || failed "FAILED TO COMPILE/INSTALL NETDATA" [ ! -z "\${tmp}" ] && rm "\${tmp}" && tmp= return 0 -- cgit v1.2.3