From 3f88830bac6eb586f46d53f8975dac090828c059 Mon Sep 17 00:00:00 2001 From: Amr Gharbeia Date: Thu, 16 Apr 2026 12:40:44 -0400 Subject: [PATCH] feat: Make bootstrapper resilient to existing directories --- opencortex.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/opencortex.sh b/opencortex.sh index 9252b6d..9a309e2 100755 --- a/opencortex.sh +++ b/opencortex.sh @@ -24,12 +24,23 @@ bootstrap_opencortex() { TARGET_DIR=${TARGET_DIR:-opencortex} if [ -d "$TARGET_DIR" ]; then - echo -e "${RED}✗ Error: Directory '$TARGET_DIR' already exists.${NC}" - exit 1 + if [ -d "$TARGET_DIR/.git" ]; then + echo -e "${YELLOW}! Directory '$TARGET_DIR' already contains a repository. Using it...${NC}" + else + echo -e "${RED}✗ Error: Directory '$TARGET_DIR' exists and is NOT a repository.${NC}" + read -p "Choose a different name or 'WIPE' to delete it: " NEW_INPUT + if [[ "$NEW_INPUT" == "WIPE" ]]; then + rm -rf "$TARGET_DIR" + else + TARGET_DIR=${NEW_INPUT:-opencortex-2} + fi + fi fi - echo -e "${BLUE}Cloning repository into $TARGET_DIR...${NC}" - git clone http://10.10.10.201:3001/amr/opencortex.git "$TARGET_DIR" + if [ ! -d "$TARGET_DIR" ]; then + echo -e "${BLUE}Cloning repository into $TARGET_DIR...${NC}" + git clone http://10.10.10.201:3001/amr/opencortex.git "$TARGET_DIR" + fi cd "$TARGET_DIR" git submodule update --init --recursive