From d1b61f32b14e5930c1bbb60616e11908216fb0ee Mon Sep 17 00:00:00 2001 From: aminnairi <18418459+aminnairi@users.noreply.github.com> Date: Sun, 7 Jan 2024 12:18:10 +0100 Subject: [PATCH] added git installation verification in the main script --- main.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main.sh b/main.sh index 4bb12f2..18b1c6a 100755 --- a/main.sh +++ b/main.sh @@ -14,8 +14,9 @@ ERROR_BECAUSE_NOT_ARCH_LINUX=2 ERROR_BECAUSE_TOO_MUCH_ARGUMENTS_PROVDED=3 ERROR_BECAUSE_ANSIBLE_INSTALLATION_FAILED=4 ERRROR_BECAUSE_FUZZY_FILE_FINDER_INSTALLATION_FAILED=5 -ERROR_BECAUSE_GIT_PULL_FAILED=6 -ERROR_BECAUSE_PLAYBOOK_PATH_DOES_NOT_EXIST=7 +ERROR_BECAUSE_GIT_INSTALLATION_FAILED=6 +ERROR_BECAUSE_GIT_PULL_FAILED=7 +ERROR_BECAUSE_PLAYBOOK_PATH_DOES_NOT_EXIST=8 if [[ "$(id -u)" -eq 0 ]] then @@ -55,6 +56,17 @@ then fi fi +if [[ ! -x "$(command -v git)" ]] +then + echo "Git not found, installing..." + + if [[ ! "$(sudo pacman -Syy --noconfirm git)" ]] + then + echo "Installation of git failed." + exit $ERROR_BECAUSE_GIT_INSTALLATION_FAILED + fi +fi + if [[ $# -gt 1 ]] then echo "Too much arguments provided."