]> arthur.barton.de Git - netdata.git/commitdiff
make sure /etc/profile does not change the working directory; fixes #1715
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 4 Feb 2017 00:22:59 +0000 (02:22 +0200)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 4 Feb 2017 00:22:59 +0000 (02:22 +0200)
autogen.sh
netdata-installer.sh

index 291fe48167c30250593f5cc03ac1fafd354e651c..38e2ed1597fa8bf86e3f7caa6623e24c930c3748 100755 (executable)
@@ -1,3 +1,2 @@
 #!/usr/bin/env sh
-
 autoreconf -ivf
index fa69de196d1076dd2a48551639685b4431e334a4..9b080caed1d641ca43d26c39714e16ec2217662a 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 | wc -l)
 [ $(( processors )) -lt 1 ] && processors=1
 
 # you can set CFLAGS before running installer
@@ -382,7 +393,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"