From: Thierry Parmentelat Date: Thu, 25 Apr 2013 16:01:51 +0000 (+0200) Subject: upon better thinking this really is a separate matter, take out of git-mirror altogether X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=1c6bda0c92fb0b715fe782856b6e688eb2ec2edb;p=infrastructure.git upon better thinking this really is a separate matter, take out of git-mirror altogether --- diff --git a/scripts/git-mirror.sh b/scripts/git-mirror.sh index c692fa6..3f05125 100755 --- a/scripts/git-mirror.sh +++ b/scripts/git-mirror.sh @@ -202,40 +202,10 @@ function mirror_repo () { touch ${REPO_DIR}/MIRRORED.stamp } -#################### -# hook to simpler, 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 this script that is already scary, -# I preferred to keep these simpler -# -# 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 - -function slave_repo () { - git_slave=$1; shift - cd $git_slave - for subdir in *; do - [ -d $subdir/.git ] && (cd $subdir ; git fetch -q ) - done -} - function usage () { echo "Usage $COMMAND [options] REPONAME*" echo " [-a admin-mails] : provide space-separated admins emails" echo " [-r remote-git-url] : e.g. -r git://git.onelab.eu/" - echo " [-s slave-area] : git-update.sh in all subdirs of slave-area that have one" - echo " typically /git-slave on the onelab side for e.g. tophat" echo " [-q] quiet mode for running under cron" echo " [-v] verbose mode" echo " [-f] force mode, runs even if the lock file is present" @@ -243,14 +213,10 @@ function usage () { exit 1 } -# set this as a default - won't harm anyone -SLAVE_GITDIR=/git-slave - while getopts "a:r:s:qvfh" opt; do case $opt in a) ADMINS=$OPTARG ;; r) REMOTE_GIT=$OPTARG ;; - s) SLAVE_GITDIR=$OPTARG ;; q) QUIET=true ;; v) VERBOSE=true ;; f) FORCE=true ;; @@ -284,5 +250,4 @@ trap failure INT # if force is set we leave the lock file as is [ -z "$FORCE" ] && date > $LOCKFILE for gitrepo in "$@"; do mirror_repo $gitrepo ; done -if [ -d "$SLAVE_GITDIR" ] ; then slave_repo $SLAVE_GITDIR ; fi [ -z "$FORCE" ] && rm -f $LOCKFILE diff --git a/scripts/git-slave.sh b/scripts/git-slave.sh new file mode 100755 index 0000000..470044f --- /dev/null +++ b/scripts/git-slave.sh @@ -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