diff --git a/installer.sh b/installer.sh index 8f8ccffc4f..6be2ebc745 100755 --- a/installer.sh +++ b/installer.sh @@ -16,7 +16,7 @@ LATEST_VERSION="${LATEST_VERSION##*v}" PLATFORM="${PLATFORM:-}" TMP_DIR=$(mktemp -d) -OUT_DIR="${OUT_DIR:-/usr/local/bin}" +OUT_DIR="${OUT_DIR:-$HOME/.metatype/bin}" VERSION="${VERSION:-$LATEST_VERSION}" MACHINE=$(uname -m) @@ -102,24 +102,59 @@ Set the OUT_DIR environment variable to change the installation directory: $ curl -fsSL $INSTALLER_URL | OUT_DIR=. bash EOF + if [ ! -d "${OUT_DIR}" ]; then + mkdir -p "$OUT_DIR" + fi + if [ -w "${OUT_DIR}" ]; then read -p "Press enter to continue (or cancel with Ctrl+C):" mv "$TMP_DIR/$EXE" "$OUT_DIR" else - printf "Sudo is required to run \"sudo mv %s %s\":\n" "$TMP_DIR/$EXE" "$OUT_DIR" - sudo mv "$TMP_DIR/$EXE" "$OUT_DIR" + echo "$OUT_DIR is not writable." + exit 1 fi fi rm -r "$TMP_DIR" -OUT_DIR=$(realpath $OUT_DIR) -if [[ ":$PATH:" != *":$OUT_DIR:"* ]]; then - cat <> "$SHELL_CONFIG" + printf "Path added to %s\nRun 'source %s' to apply changes." "$SHELL_CONFIG" "$SHELL_CONFIG" + else + cat <