From b773ed768eb1c9a09b83db010cf27fbcccacad2e Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Sat, 4 Feb 2017 02:22:59 +0200 Subject: [PATCH] make sure /etc/profile does not change the working directory; fixes #1715 --- autogen.sh | 1 - netdata-installer.sh | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) 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" -- 2.39.2