upon better thinking this really is a separate matter, take out of git-mirror altogether
[infrastructure.git] / scripts / git-slave.sh
diff --git a/scripts/git-slave.sh b/scripts/git-slave.sh
new file mode 100755 (executable)
index 0000000..470044f
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+####################
+# manage a set of simpler (than git-miror.sh does), pull-only repos
+# the idea here is, we need to keep a local read-only mirror
+# of some repositories
+#
+# e.g. /git-slave/tophat.git on onelab.eu which is a mirror of
+# git.top-hat.info/tophat.git that can't easily be exposed as a git feed
+#
+# instead of hacking git-mirror.sh script that is already scary, 
+# I preferred to keep this separate
+#
+# so the overall layout is as follows
+# * manually created the local mirror by running
+#   cd /git-slave
+#   git clone --mirror ssh://tophat@git.top-hat.info/tophat.git
+#   which creates a *bare* repo /git-slave/tophat.git
+# * create a symlink for git-daemon and for gitweb
+#   cd /git
+#   ln -s /git-slave/tophat.git
+# Being a symlink this won't be considered by the main purpose of git-mirror.sh 
+
+# Typical usage in cron
+# */3 * * * * /root/bin/git-slave.sh -q /git-slave/*.git
+
+function slave_repo () {
+    git_slave=$1; shift
+    cd $git_slave
+    git fetch -q
+}
+
+for slave_dir in "$@"; do slave_repo $slave_dir; done