LOCALBASE=/var/lib/git
PUBLICBASE=/var/cache/git
-PUBLICSERVER="$1"
-[ -z "$PUBLICSERVER" ] && PUBLICSERVER=oss.titaniummirror.com
+PUBLICSERVER=oss.titaniummirror.com
+
+push_repo()
+{
+ local repo=$1
-echo "Updating git repos on server $PUBLICSERVER"
-cd $LOCALBASE
-for path in $(find . -name git-daemon-export-ok); do
- repo="${path/\/git-daemon-export-ok/}"
- repo="${repo/.\//}"
- echo "Repository $repo"
if ! ssh $PUBLICSERVER test -d $PUBLICBASE/$repo ; then
# Repo does not exist on public server, so create it
- echo "Creating repository $repo on remote"
+ echo "-- creating $repo"
ssh $PUBLICSERVER git --git-dir=$PUBLICBASE/$repo init --bare
ssh $PUBLICSERVER touch $PUBLICBASE/$repo/git-daemon-export-ok
scp $repo/description $PUBLICSERVER:$PUBLICBASE/$repo/
ssh $PUBLICSERVER "echo \"git://$PUBLICSERVER/$repo\" \
> $PUBLICBASE/$repo/cloneurl"
fi
+ echo "-- syncing $repo"
git --git-dir=$repo push --mirror $PUBLICSERVER:$PUBLICBASE/$repo
-done
+}
+
+## MAIN ##
+
+if [ "$1" = "-s" -a -n "$2" ]; then
+ PUBLICSERVER="$2"
+ shift; shift
+fi
+repos="$*"
+
+echo "-- server $PUBLICSERVER"
+cd $LOCALBASE
+if [ -n "$repos" ]; then
+ for repo in $repos; do
+ if [ -f "$repo/git-daemon-export-ok" ]; then
+ repo="${repo/\/git-daemon-export-ok/}"
+ repo="${repo/.\//}"
+ push_repo $repo
+ else
+ echo "-- skipping private repo $repo"
+ fi
+ done
+else
+ for path in $(find . -name git-daemon-export-ok); do
+ repo="${path/\/git-daemon-export-ok/}"
+ repo="${repo/.\//}"
+ push_repo $repo
+ done
+fi