diff options
| author | Jan Sydänviita <jan@sydanviita.fi> | 2026-08-19 16:39:03 +0300 |
|---|---|---|
| committer | Jan Sydänviita <jan@sydanviita.fi> | 2026-08-19 16:39:03 +0300 |
| commit | a8d027dc7c6312969fa91165e0e99676f23eb6e4 (patch) | |
| tree | 260c25bf0e8be5941a1cd04ab61b4bf3f2b86afd /roles/jails/22_forge/files/git-mirrors.sh | |
| parent | 1e972c95802d85dea539b4081272413b10e93a82 (diff) | |
Improve forge
Diffstat (limited to 'roles/jails/22_forge/files/git-mirrors.sh')
| -rw-r--r-- | roles/jails/22_forge/files/git-mirrors.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/roles/jails/22_forge/files/git-mirrors.sh b/roles/jails/22_forge/files/git-mirrors.sh new file mode 100644 index 0000000..c96a000 --- /dev/null +++ b/roles/jails/22_forge/files/git-mirrors.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# Run hourly via cron. Mirrors all repos that have a 'mirror' remote configured. + +REPOS_DIR="/home/git" +LOG="/var/log/git-mirrors.log" +export GIT_SSH_COMMAND="ssh -i /home/git/.ssh/forge_deploy -o IdentitiesOnly=yes" + +echo "$(date) Starting mirror run" >> "$LOG" + +for repo in "$REPOS_DIR"/*.git; do + [ -d "$repo" ] || continue + name="$(basename "$repo" .git)" + + remote=$(git -C "$repo" remote get-url mirror-to 2>/dev/null) || continue + + echo "$(date) Mirroring $name -> $remote" >> "$LOG" + if git -C "$repo" push --mirror mirror-to >> "$LOG" 2>&1; then + echo "$(date) OK $name" >> "$LOG" + else + echo "$(date) FAILED $name" >> "$LOG" + fi +done + +echo "$(date) Mirror run complete" >> "$LOG" |
