From: Costa Tsaousis (ktsaou) Date: Sat, 4 Feb 2017 00:22:59 +0000 (+0200) Subject: make sure /etc/profile does not change the working directory; fixes #1715 X-Git-Tag: ab-debian_0.20170204.01-0ab1~1^2^2 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netdata.git;a=commitdiff_plain;h=b773ed768eb1c9a09b83db010cf27fbcccacad2e make sure /etc/profile does not change the working directory; fixes #1715 --- diff --git a/autogen.sh b/autogen.sh index 291fe481..38e2ed15 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,3 +1,2 @@ #!/usr/bin/env sh - autoreconf -ivf diff --git a/netdata-installer.sh b/netdata-installer.sh index fa69de19..9b080cae 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 &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"