aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/git-mirrors/templates/update-mirrors.sh.j2
blob: 721ec679824c460122b8a6532f7b3bca6dcef0d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env sh

set -u

# Base location of all mirrors
MIRRORS_BASE_DIR="{{ git_mirrors_base_dir }}/mirrored"

# Locate repositories knowing that there will be a HEAD file inside them
FOUND_REPOS=$(find "$MIRRORS_BASE_DIR" -name "HEAD" -print0 | xargs -0 dirname)

for repo in $FOUND_REPOS; do
    cd "$repo";
    echo "Updating $repo mirror..."
    if ! nice git fetch -q --prune; then
        echo "Error: Failed to update repository $repo"
        exit 1
    fi
    echo "Updated repository."

    cd -
done