diff options
| -rw-r--r-- | ansible/roles/git-mirrors/templates/update-mirrors.sh.j2 | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/ansible/roles/git-mirrors/templates/update-mirrors.sh.j2 b/ansible/roles/git-mirrors/templates/update-mirrors.sh.j2 new file mode 100644 index 0000000..52831b6 --- /dev/null +++ b/ansible/roles/git-mirrors/templates/update-mirrors.sh.j2 @@ -0,0 +1,19 @@ +#!/usr/bin/env sh + +set -u + +# Base location of all mirrors +MIRRORS_BASE_DIR="/srv/git-mirrors/mirrored" + +# Locate repositories knowing that there will be a HEAD file inside them +FOUND_REPOS=$(find "$MIRRORS_BASE_DIR" -name "HEAD" | xargs dirname) + +for repo in $FOUND_REPOS; do +    cd "$repo"; +    echo "Updating $repo mirror..." +    if ! git fetch -q; then +        echo "Error: Failed to update repository $repo" +        exit 1 +    fi +    echo "Updated repository." +done | 
