From 5cac960f324de482b40d87adfe1c03cc62464b05 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sun, 16 Apr 2023 02:30:45 -0500 Subject: [PATCH] Better --- common/bin/dotfiles-init | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/common/bin/dotfiles-init b/common/bin/dotfiles-init index 5c8b035..f1771ec 100755 --- a/common/bin/dotfiles-init +++ b/common/bin/dotfiles-init @@ -13,8 +13,19 @@ dfp="$(realpath "$(dirname "$0")"/../..)" if [[ ! -d "$dfp/.git" ]]; then echo "Not running from inside the dotfiles git repo, so we need to download it first!" # each os needs instructions to install git, then we can clone the repo and proceed - if head /etc/os-release --lines 1 | grep 'Arch Linux' > /dev/null 2>&1; then - sudo pacman -Sy --needed git + if ! command -v git; then + if head /etc/os-release --lines 1 | grep 'Arch Linux' > /dev/null 2>&1; then + if [[ "$EUID" -ne 0 ]]; then + if ! command -v sudo; then + echo "Error: No sudo command available to try and install 'git'" + exit 1 + else + sudo pacman -Sy --needed git + fi + else + pacman -Sy --needed git + fi + fi fi git clone https://git.lyte.dev/lytedev/dotfiles.git "$dfp" fi