]> arthur.barton.de Git - netdata.git/blobdiff - netdata-installer.sh
Merge pull request #1744 from l2isbad/web_log_plugin
[netdata.git] / netdata-installer.sh
index fa69de196d1076dd2a48551639685b4431e334a4..606b6c7650bc9164dd454d96c915ede12c73badb 100755 (executable)
@@ -1,9 +1,20 @@
 #!/usr/bin/env bash
 
+export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+
+netdata_source_dir="$(pwd)"
+installer_dir="$(dirname "${0}")"
+
+if [ "${netdata_source_dir}" != "${installer_dir}" -a "${installer_dir}" != "." ]
+    then
+    echo >&2 "Warninng: you are currently in '${netdata_source_dir}' but the installer is in '${installer_dir}'."
+fi
+
 # reload the user profile
 [ -f /etc/profile ] && . /etc/profile
 
-export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
+# make sure /etc/profile does not change our current directory
+cd "${netdata_source_dir}" || exit 1
 
 # fix PKG_CHECK_MODULES error
 if [ -d /usr/share/aclocal ]
@@ -18,7 +29,7 @@ umask 002
 # Be nice on production environments
 renice 19 $$ >/dev/null 2>/dev/null
 
-processors=$(cat /proc/cpuinfo  | grep ^processor | wc -l)
+processors=$(grep ^processor </proc/cpuinfo 2>/dev/null | wc -l)
 [ $(( processors )) -lt 1 ] && processors=1
 
 # you can set CFLAGS before running installer
@@ -58,6 +69,7 @@ banner() {
     echo >&2
 }
 
+setcap="$(which setcap 2>/dev/null || command -v setcap 2>/dev/null)"
 service="$(which service 2>/dev/null || command -v service 2>/dev/null)"
 systemctl="$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)"
 service() {
@@ -382,7 +394,7 @@ run() {
 
     printf >&2 "\n"
     printf >&2 ":-----------------------------------------------------------------------------\n"
-    printf >&2 "Running command:\n"
+    printf >&2 "Running command (in $(pwd)):\n"
     printf >&2 "\n"
     printf >&2 "%q " "${@}"
     printf >&2 "\n"
@@ -695,6 +707,7 @@ NETDATA_ADDED_TO_DOCKER=0
 NETDATA_ADDED_TO_NGINX=0
 NETDATA_ADDED_TO_VARNISH=0
 NETDATA_ADDED_TO_HAPROXY=0
+NETDATA_ADDED_TO_ADM=0
 if [ ${UID} -eq 0 ]
     then
     portable_add_group netdata
@@ -703,6 +716,7 @@ if [ ${UID} -eq 0 ]
     portable_add_user_to_group nginx  netdata && NETDATA_ADDED_TO_NGINX=1
     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
 
     if [ -d /etc/logrotate.d -a ! -f /etc/logrotate.d/netdata ]
         then
@@ -842,8 +856,11 @@ if [ ${UID} -eq 0 ]
     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 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
@@ -1366,6 +1383,15 @@ if [ $? -eq 0 -a "${NETDATA_ADDED_TO_HAPROXY}" = "1" ]
     echo "   gpasswd -d netdata haproxy"
 fi
 
+getent group adm > /dev/null
+if [ $? -eq 0 -a "${NETDATA_ADDED_TO_ADM}" = "1" ]
+    then
+    echo
+    echo "You may also want to remove the netdata user from the adm group"
+    echo "by running:"
+    echo "   gpasswd -d netdata adm"
+fi
+
 
 UNINSTALL
 chmod 750 netdata-uninstaller.sh