diff options
Diffstat (limited to 'netdata-installer.sh')
-rwxr-xr-x | netdata-installer.sh | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/netdata-installer.sh b/netdata-installer.sh index bc2e1cbe0b..c40d03473e 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -42,6 +42,43 @@ fi cd "${NETDATA_SOURCE_DIR}" || exit 1 # ----------------------------------------------------------------------------- +# figure out an appropriate temporary directory +_cannot_use_tmpdir() { + local testfile ret + testfile="$(TMPDIR="${1}" mktemp -q -t netdata-test.XXXXXXXXXX)" + ret=0 + + if [ -z "${testfile}" ] ; then + return "${ret}" + fi + + if /bin/echo -e '#!/bin/sh\necho SUCCESS\n' > "${testfile}" ; then + if chmod +x "${testfile}" ; then + if [ "$("${testfile}")" = "SUCCESS" ] ; then + ret=1 + fi + fi + fi + + rm -f "${testfile}" + return "${ret}" +} + +if [ -z "${TMPDIR}" ] || _cannot_use_tmpdir "${TMPDIR}" ; then + if _cannot_use_tmpdir /tmp ; then + if _cannot_use_tmpdir "${PWD}" ; then + echo >&2 + echo >&2 "Unable to find a usable temprorary directory. Please set \$TMPDIR to a path that is both writable and allows execution of files and try again." + exit 1 + else + TMPDIR="${PWD}" + fi + else + TMPDIR="/tmp" + fi +fi + +# ----------------------------------------------------------------------------- # set up handling for deferred error messages NETDATA_DEFERRED_ERRORS="" @@ -324,6 +361,10 @@ cat << BANNER1 You are about to build and install netdata to your system. + The build process will use ${TPUT_CYAN}${TMPDIR}${TPUT_RESET} for + any temporary files. You can override this by setting \$TMPDIR to a + writable directory where you can execute files. + It will be installed at these locations: - the daemon at ${TPUT_CYAN}${NETDATA_PREFIX}/usr/sbin/netdata${TPUT_RESET} |