diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-02-04 02:22:59 +0200 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-02-04 02:22:59 +0200 |
commit | b773ed768eb1c9a09b83db010cf27fbcccacad2e (patch) | |
tree | 6adfff624e9a14c78035fe31f1909c455322e6d9 /netdata-installer.sh | |
parent | 32043a285ad7c59a9cd679b496fa5961284c443b (diff) |
make sure /etc/profile does not change the working directory; fixes #1715
Diffstat (limited to 'netdata-installer.sh')
-rwxr-xr-x | netdata-installer.sh | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/netdata-installer.sh b/netdata-installer.sh index fa69de196d..9b080caed1 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -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" |