X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netdata.git;a=blobdiff_plain;f=netdata-installer.sh;h=6b672a242e8ad5c04d45a1dfa832e496860e1e33;hp=680772c7ec489b2333ad117217f648aacd3f2fda;hb=HEAD;hpb=f266bab3d154e9e082403b89ea60d0fe35fe4096 diff --git a/netdata-installer.sh b/netdata-installer.sh index 680772c7..6b672a24 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -49,7 +49,7 @@ umask 002 # Be nice on production environments renice 19 $$ >/dev/null 2>/dev/null -processors=$(grep ^processor /dev/null | wc -l) +processors=$(cat /proc/cpuinfo 2>/dev/null | grep ^processor | wc -l) [ $(( processors )) -lt 1 ] && processors=1 # you can set CFLAGS before running installer @@ -99,8 +99,22 @@ Valid are: Start immediately building it. --enable-plugin-freeipmi + --disable-plugin-freeipmi - Enable the FreeIPMI plugin. + Enable/disable the FreeIPMI plugin. + Default: enable it when libipmimonitoring is available. + + --enable-plugin-nfacct + --disable-plugin-nfacct + + Enable/disable the nfacct plugin. + Default: enable it when libmnl and libnetfilter_acct are available. + + --enable-lto + --disable-lto + + Enable/disable Link-Time-Optimization + Default: enabled --zlib-is-really-here --libs-are-really-here @@ -129,7 +143,7 @@ For the plugins, you will at least need: USAGE } -md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null)" +md5sum="$(which md5sum 2>/dev/null || command -v md5sum 2>/dev/null || command -v md5 2>/dev/null)" get_git_config_signatures() { local x s file md5 @@ -145,7 +159,7 @@ get_git_config_signatures() { for c in $(git log --follow "conf.d/${x}" | grep ^commit | cut -d ' ' -f 2) do git checkout ${c} "conf.d/${x}" || continue - s="$(cat "conf.d/${x}" | md5sum | cut -d ' ' -f 1)" + s="$(cat "conf.d/${x}" | ${md5sum} | cut -d ' ' -f 1)" echo >>configs.signatures.tmp "${s}:${x}" echo " ${s}" done @@ -193,6 +207,26 @@ do then NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --enable-plugin-freeipmi" shift 1 + elif [ "$1" = "--disable-plugin-freeipmi" ] + then + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --disable-plugin-freeipmi" + shift 1 + elif [ "$1" = "--enable-plugin-nfacct" ] + then + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --enable-plugin-nfacct" + shift 1 + elif [ "$1" = "--disable-plugin-nfacct" ] + then + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --disable-plugin-nfacct" + shift 1 + elif [ "$1" = "--enable-lto" ] + then + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --enable-lto" + shift 1 + elif [ "$1" = "--disable-lto" ] + then + NETDATA_CONFIGURE_OPTIONS="${NETDATA_CONFIGURE_OPTIONS} --disable-lto" + shift 1 elif [ "$1" = "--help" -o "$1" = "-h" ] then usage @@ -487,6 +521,24 @@ then fi fi +config_signature_matches() { + local md5="${1}" file="${2}" + + if [ "${BASH_VERSINFO[0]}" -ge "4" ] + then + [ "${configs_signatures[${md5}]}" = "${file}" ] && return 0 + return 1 + fi + + if [ -f "configs.signatures" ] + then + grep "\['${md5}'\]='${file}'" "configs.signatures" >/dev/null + return $? + fi + + return 1 +} + # backup user configurations installer_backup_suffix="${PID}.${RANDOM}" for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f) @@ -514,19 +566,13 @@ do cp "conf.d/${f}" "${x}.orig" fi - if [ "${BASH_VERSINFO[0]}" -ge "4" ] - then - if [ "${configs_signatures[${md5}]}" = "${f}" ] + if config_signature_matches "${md5}" "${f}" then - # it is a stock version - don't keep it - echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' is stock version." - else - # edited by user - keep it - echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED} has been edited by user${TPUT_RESET}. Keeping it." - run cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}" - fi + # it is a stock version - don't keep it + echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' is stock version." else - echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RET}cannot be checked for custom edits${TPUT_RESET}. Keeping it." + # edited by user - keep it + echo >&2 "File '${TPUT_CYAN}${x}${TPUT_RESET}' ${TPUT_RED} has been edited by user${TPUT_RESET}. Keeping it." run cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}" fi fi @@ -571,6 +617,7 @@ NETDATA_ADDED_TO_NGINX=0 NETDATA_ADDED_TO_VARNISH=0 NETDATA_ADDED_TO_HAPROXY=0 NETDATA_ADDED_TO_ADM=0 +NETDATA_ADDED_TO_NSD=0 if [ ${UID} -eq 0 ] then portable_add_group netdata @@ -580,6 +627,7 @@ if [ ${UID} -eq 0 ] portable_add_user_to_group varnish netdata && NETDATA_ADDED_TO_VARNISH=1 portable_add_user_to_group haproxy netdata && NETDATA_ADDED_TO_HAPROXY=1 portable_add_user_to_group adm netdata && NETDATA_ADDED_TO_ADM=1 + portable_add_user_to_group nsd netdata && NETDATA_ADDED_TO_NSD=1 run_ok else run_failed "The installer does not run as root." @@ -714,7 +762,13 @@ run chmod 755 "${NETDATA_LOG_DIR}" if [ ${UID} -eq 0 ] then - run chown "${NETDATA_USER}:root" "${NETDATA_LOG_DIR}" + # find the admin group + admin_group= + test -z "${admin_group}" && getent group root >/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}" + + run chown "${NETDATA_USER}:${admin_group}" "${NETDATA_LOG_DIR}" run chown -R root "${NETDATA_PREFIX}/usr/libexec/netdata" run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \; run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0644 {} \; @@ -1226,6 +1280,15 @@ if [ $? -eq 0 -a "${NETDATA_ADDED_TO_ADM}" = "1" ] echo " gpasswd -d netdata adm" fi +getent group nsd > /dev/null +if [ $? -eq 0 -a "${NETDATA_ADDED_TO_NSD}" = "1" ] + then + echo + echo "You may also want to remove the netdata user from the nsd group" + echo "by running:" + echo " gpasswd -d netdata nsd" +fi + UNINSTALL chmod 750 netdata-uninstaller.sh @@ -1291,7 +1354,7 @@ if [ -t 2 ] else # we are headless # create a temporary file for the log - tmp=\$(mktemp /tmp/netdata-updater-log-XXXXXX.log) + tmp=\$(mktemp /tmp/netdata-updater.log.XXXXXX) # open fd 3 and send it to tmp exec 3>\${tmp} fi @@ -1371,11 +1434,19 @@ REINSTALL echo >&2 echo >&2 "${TPUT_DIM}${TPUT_BOLD}netdata-updater.sh${TPUT_RESET}${TPUT_DIM} can work from cron. It will trigger an email from cron" echo >&2 "only if it fails (it does not print anything if it can update netdata).${TPUT_RESET}" - if [ "${UID}" -eq 0 -a -d "/etc/cron.daily" -a ! -f "/etc/cron.daily/netdata-updater.sh" ] - then - echo >&2 "${TPUT_DIM}Run this to automatically check and install netdata updates once per day:${TPUT_RESET}" - echo >&2 - echo >&2 "${TPUT_YELLOW}${TPUT_BOLD}ln -s ${PWD}/netdata-updater.sh /etc/cron.daily/netdata-updater.sh${TPUT_RESET}" + if [ "${UID}" -eq "0" ] + then + if [ -d "/etc/cron.daily" -a ! -f "/etc/cron.daily/netdata-updater.sh" ] + then + echo >&2 "${TPUT_DIM}Run this to automatically check and install netdata updates once per day:${TPUT_RESET}" + echo >&2 + echo >&2 "${TPUT_YELLOW}${TPUT_BOLD}ln -s ${PWD}/netdata-updater.sh /etc/cron.daily/netdata-updater.sh${TPUT_RESET}" + elif [ -d "/etc/periodic/daily" -a ! -f "/etc/periodic/daily/netdata-updater" ] + then + echo >&2 "${TPUT_DIM}Run this to automatically check and install netdata updates once per day:${TPUT_RESET}" + echo >&2 + echo >&2 "${TPUT_YELLOW}${TPUT_BOLD}ln -s ${PWD}/netdata-updater.sh /etc/periodic/daily/netdata-updater${TPUT_RESET}" + fi fi elif [ -f "netdata-updater.sh" ] then