diff options
| author | 2024-08-25 20:08:46 +0100 | |
|---|---|---|
| committer | 2024-08-25 23:14:45 +0100 | |
| commit | 3717b85aa128c3e61c19e001ea8684ce8c8d9607 (patch) | |
| tree | 9239f4f2a99d4fa2d366e8b6b9017d12feeb38b0 | |
| parent | Add dependency on NGINX to git-mirrors role for handlers (diff) | |
Add script for updating mirrors in a cronjob
| -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 | 
