diff options
author | Diego Jornada <djornada@outlook.com> | 2020-02-12 23:13:21 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-12 21:13:21 -0500 |
commit | b1bc2a04a4679659c69b35b8f24ea161b5d828fa (patch) | |
tree | 20dee82804c5ccf542d5ee04f1a733bb056067e9 /install | |
parent | 0312c7b91e2ada97f5975dbcc1f35cab2d0238fe (diff) |
feat(installer): Ask for permission escalation during installation, if needed (#914)
Diffstat (limited to 'install')
-rwxr-xr-x | install/install.sh | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/install/install.sh b/install/install.sh index 298a3da1b..bc190fda6 100755 --- a/install/install.sh +++ b/install/install.sh @@ -82,6 +82,24 @@ fetch() { fi } +install() { + local sudo + local msg + if [ -w "$BIN_DIR" ]; then + sudo="" + msg="Installing Starship, please wait…" + else + warn "Escalated permission are required to install to ${BIN_DIR}" + sudo -v || (error "Aborting installation (Please provide root password)";exit 1) + sudo="sudo" + msg="Installing Starship as root, please wait…" + fi + info "$msg" + fetch "${URL}" \ + | ${sudo} tar xzf${VERBOSE} - \ + -C "${BIN_DIR}" +} + # Currently supporting: # - win (Git Bash) # - darwin @@ -238,13 +256,9 @@ info "Tarball URL: ${UNDERLINE}${BLUE}${URL}${NO_COLOR}" check_bin_dir "${BIN_DIR}" confirm "Install Starship ${GREEN}latest${NO_COLOR} to ${BOLD}${GREEN}${BIN_DIR}${NO_COLOR}?" -info "Installing Starship, please wait…" - -fetch "${URL}" \ - | tar xzf${VERBOSE} - \ - -C "${BIN_DIR}" - +install complete "Starship installed" + echo info "Please follow the steps for your shell to complete the installation: |