]> arthur.barton.de Git - netdata.git/blobdiff - netdata-installer.sh
diskstats: Ensure collecting right space metrics
[netdata.git] / netdata-installer.sh
index 3b094d44201f2591d20d859e26f622e17a73e015..42ab0e15600c3e34f44d2b0068722f45deb718ee 100755 (executable)
@@ -27,7 +27,7 @@ ME="$0"
 DONOTSTART=0
 DONOTWAIT=0
 NETDATA_PREFIX=
-ZLIB_IS_HERE=0
+LIBS_ARE_HERE=0
 
 usage() {
        cat <<-USAGE
@@ -52,9 +52,10 @@ usage() {
                        Start immediately building it.
 
           --zlib-is-really-here
+          --libs-are-really-here
 
                        If you get errors about missing zlib,
-                       but you know it is available,
+                       or libuuid but you know it is available,
                        you have a broken pkg-config.
                        Use this option to allow it continue
                        without checking pkg-config.
@@ -67,7 +68,8 @@ usage() {
        For the installer to complete successfully, you will need
        these packages installed:
 
-          gcc make autoconf automake pkg-config zlib1g-dev uuid-dev
+          gcc make autoconf automake pkg-config zlib1g-dev (or zlib-devel)
+          uuid-dev (or libuuid-devel)
 
        For the plugins, you will at least need:
 
@@ -82,9 +84,9 @@ do
                then
                NETDATA_PREFIX="${2}/netdata"
                shift 2
-       elif [ "$1" = "--zlib-is-really-here" ]
+       elif [ "$1" = "--zlib-is-really-here" -o "$1" = "--libs-are-really-here" ]
                then
-               ZLIB_IS_HERE=1
+               LIBS_ARE_HERE=1
                shift 1
        elif [ "$1" = "--dont-start-it" ]
                then
@@ -247,12 +249,15 @@ build_error() {
 
        You many need to check these:
 
-       1. The package uuid-dev has to be installed.
+       1. The package uuid-dev (or libuuid-devel) has to be installed.
 
-       2. The package zlib1g-dev has to be installed.
+          If your system cannot find libuuid, although it is installed
+          run me with the option:  --libs-are-really-here
 
-          If your system cannot find ZLIB, although it is installed
-          run me with the option:  --zlib-is-really-here
+       2. The package zlib1g-dev (or zlib-devel) has to be installed.
+
+          If your system cannot find zlib, although it is installed
+          run me with the option:  --libs-are-really-here
 
        3. You need basic build tools installed, like:
 
@@ -295,12 +300,14 @@ run() {
        return ${ret}
 }
 
-if [ ${ZLIB_IS_HERE} -eq 1 ]
+if [ ${LIBS_ARE_HERE} -eq 1 ]
        then
        shift
-       echo >&2 "ok, assuming zlib is really installed."
+       echo >&2 "ok, assuming libs are really installed."
        export ZLIB_CFLAGS=" "
        export ZLIB_LIBS="-lz"
+       export UUID_CFLAGS=" "
+       export UUID_LIBS="-luuid"
 fi
 
 trap build_error EXIT
@@ -330,11 +337,16 @@ echo >&2 "Compiling netdata ..."
 run make || exit 1
 
 # backup user configurations
+installer_backup_suffix="${PID}.${RANDOM}"
 for x in apps_groups.conf charts.d.conf
 do
        if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}" ]
                then
-               cp -p "${NETDATA_PREFIX}/etc/netdata/${x}" "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup"
+               cp -p "${NETDATA_PREFIX}/etc/netdata/${x}" "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup.${installer_backup_suffix}"
+
+       elif [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup.${installer_backup_suffix}" ]
+               then
+               rm -f "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup.${installer_backup_suffix}"
        fi
 done
 
@@ -344,9 +356,9 @@ run make install || exit 1
 # restore user configurations
 for x in apps_groups.conf charts.d.conf
 do
-       if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup" ]
+       if [ -f "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup.${installer_backup_suffix}" ]
                then
-               cp -p "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup" "${NETDATA_PREFIX}/etc/netdata/${x}"
+               cp -p "${NETDATA_PREFIX}/etc/netdata/${x}.installer_backup.${installer_backup_suffix}" "${NETDATA_PREFIX}/etc/netdata/${x}"
        fi
 done
 
@@ -384,6 +396,12 @@ if [ ${UID} -eq 0 ]
                # let the uninstall script know
                NETDATA_ADDED_TO_DOCKER=1
        fi
+
+       if [ -d /etc/logrotate.d -a ! -f /etc/logrotate.d/netdata ]
+               then
+               echo >&2 "Adding netdata logrotate configuration ..."
+               run cp system/netdata.logrotate /etc/logrotate.d/netdata
+       fi
 fi
 
 
@@ -441,6 +459,7 @@ if [ ! -d "${NETDATA_RUN_DIR}" ]
        mkdir -p "${NETDATA_RUN_DIR}" || exit 1
 fi
 
+echo >&2
 echo >&2 "Fixing directories (user: ${NETDATA_USER})..."
 for x in "${NETDATA_WEB_DIR}" "${NETDATA_CONF_DIR}" "${NETDATA_CACHE_DIR}" "${NETDATA_LOG_DIR}" "${NETDATA_LIB_DIR}"
 do
@@ -557,6 +576,7 @@ if [ $? -ne 0 ]
 else
        echo >&2 "OK. NetData Started!"
 fi
+echo >&2
 
 
 # -----------------------------------------------------------------------------
@@ -564,6 +584,9 @@ fi
 
 if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
        then
+       echo >&2
+       echo >&2 "-------------------------------------------------------------------------------"
+       echo >&2
        echo >&2 "Downloading default configuration from netdata..."
        sleep 5
 
@@ -695,8 +718,6 @@ if [ "${UID}" -ne 0 ]
                sudo chown root "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
                sudo chmod 4755 "${NETDATA_PREFIX}/usr/libexec/netdata/plugins.d/apps.plugin"
 
-       These commands allow apps.plugin to run as root.
-
        apps.plugin is performing a hard-coded function of data collection for all
        running processes. It cannot be instructed from the netdata daemon to perform
        any task, so it is pretty safe to do this.
@@ -755,6 +776,12 @@ cat >netdata-uninstaller.sh <<-UNINSTALL
                deletedir "${NETDATA_PREFIX}/var/log/netdata"
        fi
 
+       if [ -f /etc/logrotate.d/netdata ]
+               then
+               echo "Deleting /etc/logrotate.d/netdata ..."
+               rm -i /etc/logrotate.d/netdata
+       fi
+
        getent passwd netdata > /dev/null
        if [ $? -eq 0 ]
                then
@@ -817,10 +844,5 @@ cat <<-END
 
        Enjoy!
 
-                                        Give netdata a Github Star, at:
-
-                                https://github.com/firehol/netdata/wiki
-
-
 END
 echo >&2 "Uninstall script generated: ./netdata-uninstaller.sh"