From 763c3107789c85b8caeb0a923fba3c64388f87ff Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 7 Oct 2016 16:33:43 -0700 Subject: [PATCH] Use `git` to determine if directory is repository. Flip logic of `getGitFiles` to make sense. --- automated install/basic-install.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index f12a0483..c4485d4a 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -646,29 +646,32 @@ getGitFiles() { echo ":::" echo "::: Checking for existing base files..." if is_repo ${piholeFilesDir}; then - make_repo ${piholeFilesDir} ${piholeGitUrl} - else update_repo ${piholeFilesDir} + else + make_repo ${piholeFilesDir} ${piholeGitUrl} fi echo ":::" echo "::: Checking for existing web interface..." if is_repo ${webInterfaceDir}; then - make_repo ${webInterfaceDir} ${webInterfaceGitUrl} - else update_repo ${webInterfaceDir} + else + make_repo ${webInterfaceDir} ${webInterfaceGitUrl} fi } is_repo() { # If the directory does not have a .git folder it is not a repo echo -n "::: Checking $1 is a repo..." - if [ -d "$1/.git" ]; then - echo " OK!" - return 1 + cd "$1" + # returns 0 if in git repo, non-zero if not in a repo + git status > /dev/null & spinner $! + if [[ "$?" -eq 0 ]]; then + echo " repository found!" + return 0 fi - echo " not found!!" - return 0 + echo " repository not found!!" + return 1 } make_repo() {