f37 -> f39
[infrastructure.git] / scripts / git-slave.sh
1 #!/bin/sh
2
3 ####################
4 # manage a set of simpler (than git-miror.sh does), pull-only repos
5 # the idea here is, we need to keep a local read-only mirror
6 # of some repositories
7 #
8 # e.g. /git-slave/tophat.git on onelab.eu which is a mirror of
9 # git.top-hat.info/tophat.git that can't easily be exposed as a git feed
10 #
11 # instead of hacking git-mirror.sh script that is already scary, 
12 # I preferred to keep this separate
13 #
14 # so the overall layout is as follows
15 # * manually created the local mirror by running
16 #   cd /git-slave
17 #   git clone --mirror ssh://tophat@git.top-hat.info/tophat.git
18 #   which creates a *bare* repo /git-slave/tophat.git
19 # * create a symlink for git-daemon and for gitweb
20 #   cd /git
21 #   ln -s /git-slave/tophat.git
22 # Being a symlink this won't be considered by the main purpose of git-mirror.sh 
23
24 # Typical usage in cron
25 # */3 * * * * /root/bin/git-slave.sh -q /git-slave/*.git
26
27 # you might wish to tweak the repo's config, in particular the remote section
28 # so as to define the proper mappings for your needs
29 # e.g. from git.onelab.eu:/git-slave/rvm-rpm.git
30 #[remote "origin"]
31 #       url = https://github.com/cdwertmann/rvm-rpm.git
32 #       fetch = refs/heads/*:refs/heads/*
33
34 COMMAND=$(basename $0)
35
36 function slave_repo () {
37     git_slave=$1; shift
38     cd $git_slave
39     git fetch --all --tags -q || echo "$COMMAND failed in repo $git_slave"
40 }
41
42 for slave_dir in "$@"; do slave_repo $slave_dir; done