make sure /etc/profile does not change the working directory; fixes #1715
Costa Tsaousis (ktsaou) committed
Feb 4, 2017 at 02:22 UTC
b773ed768eb1c9a09b83db010cf27fbcccacad2e
2 files changed
+14
-4
autogen.sh
-1
@@ -1,3 +1,2 @@
1
#!/usr/bin/env sh
2
-
2
autoreconf -ivf
netdata-installer.sh
+14
-3
@@ -1,9 +1,20 @@
1
#!/usr/bin/env bash
2
3
+export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
4
+
5
+netdata_source_dir="$(pwd)"
6
+installer_dir="$(dirname "${0}")"
7
+
8
+if [ "${netdata_source_dir}" != "${installer_dir}" -a "${installer_dir}" != "." ]
9
+ then
10
+ echo >&2 "Warninng: you are currently in '${netdata_source_dir}' but the installer is in '${installer_dir}'."
11
+fi
12
+
13
# reload the user profile
14
[ -f /etc/profile ] && . /etc/profile
15
6
-export PATH="${PATH}:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
16
+# make sure /etc/profile does not change our current directory
17
+cd "${netdata_source_dir}" || exit 1
18
19
# fix PKG_CHECK_MODULES error
20
if [ -d /usr/share/aclocal ]
@@ -18,7 +29,7 @@ umask 002
29
# Be nice on production environments
30
renice 19 $$ >/dev/null 2>/dev/null
31
21
-processors=$(cat /proc/cpuinfo | grep ^processor | wc -l)
32
+processors=$(grep ^processor </proc/cpuinfo | wc -l)
33
[ $(( processors )) -lt 1 ] && processors=1
34
35
# you can set CFLAGS before running installer
@@ -382,7 +393,7 @@ run() {
393
394
printf >&2 "\n"
395
printf >&2 ":-----------------------------------------------------------------------------\n"
385
- printf >&2 "Running command:\n"
396
+ printf >&2 "Running command (in $(pwd)):\n"
397
printf >&2 "\n"
398
printf >&2 "%q " "${@}"
399
printf >&2 "\n"