#!/bin/bash


REPOS=(
    "https://cloud.o-forge.io/core/oc-aggregator.git"
    "https://cloud.o-forge.io/core/oc-auth.git"
    "https://cloud.o-forge.io/core/oc-catalog.git"
    "https://cloud.o-forge.io/core/oc-datacenter.git"
    "https://cloud.o-forge.io/core/oc-discovery.git"
    "https://cloud.o-forge.io/core/oc-front.git"
    "https://cloud.o-forge.io/core/oc-discovery.git"
    "https://cloud.o-forge.io/core/oc-monitord.git"
    "https://cloud.o-forge.io/core/oc-peer.git"
    "https://cloud.o-forge.io/core/oc-shared.git"
    "https://cloud.o-forge.io/core/oc-scheduler.git"
    "https://cloud.o-forge.io/core/oc-schedulerd.git"
    "https://cloud.o-forge.io/core/oc-workflow.git"
    "https://cloud.o-forge.io/core/oc-workspace.git"
)

# Function to clone repositories
clone_repo() {
    local repo_url="$1"
    local repo_name=$(basename "$repo_url" .git)

    echo "Processing repository: $repo_name"

    if [ -d "$repo_name" ]; then
        echo "Repository '$repo_name' already exists. Pulling latest changes..."
        cd "$repo_name" && git pull && cd ..
    else
        echo "Cloning repository: $repo_name"
        git clone "$repo_url"
        if [ $? -ne 0 ]; then
            echo "Error cloning $repo_url"
            exit 1
        fi
    fi
}

# Iterate through each repository in the list
for repo in "${REPOS[@]}"; do
    clone_repo "$repo"
done

echo "All repositories processed successfully."



