aboutsummaryrefslogtreecommitdiffstats
path: root/roles/jails/22_forge/files/git-shell-commands/mirror-to
diff options
context:
space:
mode:
authorJan Sydänviita <jan@sydanviita.fi>2026-08-19 16:39:03 +0300
committerJan Sydänviita <jan@sydanviita.fi>2026-08-19 16:39:03 +0300
commita8d027dc7c6312969fa91165e0e99676f23eb6e4 (patch)
tree260c25bf0e8be5941a1cd04ab61b4bf3f2b86afd /roles/jails/22_forge/files/git-shell-commands/mirror-to
parent1e972c95802d85dea539b4081272413b10e93a82 (diff)
Improve forge
Diffstat (limited to 'roles/jails/22_forge/files/git-shell-commands/mirror-to')
-rw-r--r--roles/jails/22_forge/files/git-shell-commands/mirror-to39
1 files changed, 39 insertions, 0 deletions
diff --git a/roles/jails/22_forge/files/git-shell-commands/mirror-to b/roles/jails/22_forge/files/git-shell-commands/mirror-to
new file mode 100644
index 0000000..d161283
--- /dev/null
+++ b/roles/jails/22_forge/files/git-shell-commands/mirror-to
@@ -0,0 +1,39 @@
+#!/bin/sh
+# mirror-to [REPO_NAME] [GIT_URL]
+# Configures a repo to be mirrored hourly to a remote git URL.
+# Example: mirror-to myrepo git@example.com:user/myrepo.git
+if [ -z "$1" ]; then
+ echo "Usage: mirror-to [REPO_NAME] [GIT_URL]"
+ echo " mirror-to [REPO_NAME] - remove mirror"
+ echo "Example: mirror-to myrepo git@example.com:user/myrepo.git"
+ exit 1
+fi
+if [ ! -d "$1.git" ]; then
+ echo "Repository $1 does not exist"
+ exit 1
+fi
+
+REPO="$1"
+REMOTE="$2"
+REPO_PATH="$HOME/$REPO.git"
+
+cd "$REPO_PATH" || exit 1
+
+if [ -z "$REMOTE" ]; then
+ if git remote get-url mirror-to >/dev/null 2>&1; then
+ git remote remove mirror-to
+ echo "Removed mirror for $REPO"
+ else
+ echo "No mirror configured for $REPO"
+ fi
+ exit 0
+fi
+
+if git remote get-url mirror-to >/dev/null 2>&1; then
+ git remote set-url mirror-to "$REMOTE"
+else
+ git remote add mirror-to "$REMOTE"
+fi
+
+echo "Configured $REPO to mirror to $REMOTE"
+echo "Mirrors run hourly. Logs: /var/log/git-mirrors.log"