diff --git a/install.sh b/install.sh index 9624b6ec..7a82f15a 100755 --- a/install.sh +++ b/install.sh @@ -45,10 +45,27 @@ execute() { hash_sha256_verify "${tmp_dir}/${TARBALL}" "${tmp_dir}/${CHECKSUM}" (cd "${tmp_dir}" && untar "${TARBALL}") - install -d "${BINDIR}" - install "${tmp_dir}/${NAME}/${BINARY}" "${BINDIR}/" + + # we check if the directory we plan to store the binary in is actually writable by + # the current user. If not , we request for sudo permissions + # this is done by -w in the if condition + # -w - write + # -r - read + # -x - execution + # -x is avoided here since the assumption is that the user will install + # the binary in a directory already in the PATH env var + if [ -w "$BINDIR" ]; then + install -d "${BINDIR}" + install "${tmp_dir}/${NAME}/${BINARY}" "${BINDIR}/" + else + echo "Elevated permissions required to install the binary" + sudo install -d "${BINDIR}" + sudo install "${tmp_dir}/${NAME}/${BINARY}" "${BINDIR}/" + fi + echo "$PREFIX: installed as ${BINDIR}/${BINARY}" } + is_supported_platform() { platform=$1 found=1