#!/bin/bash # git-push-public # # Push changes from local git repositories marked as public, via the # git-daemon-export-ok flag, to the public server. LOCALBASE=/var/lib/git PUBLICBASE=/var/cache/git PUBLICSERVER=oss.titaniummirror.com push_repo() { local repo=$1 if ! ssh $PUBLICSERVER test -d $PUBLICBASE/$repo ; then # Repo does not exist on public server, so create it 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 rsync -a $repo/description $PUBLICSERVER:$PUBLICBASE/$repo/description } ## 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 elif [ ! -d "$repo" ]; then echo "-- notfound $repo" else echo "-- skipping private $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