diff options
Diffstat (limited to 'web')
| -rwxr-xr-x | web/init-cgit | 34 | 
1 files changed, 34 insertions, 0 deletions
| diff --git a/web/init-cgit b/web/init-cgit new file mode 100755 index 0000000..8e730c1 --- /dev/null +++ b/web/init-cgit @@ -0,0 +1,34 @@ +#!/bin/sh +# init-cgit: initialize a repo on cgit.  +# Requires ssh access to the git user. +# To do, run this in the directory of the repo you would like to init on cgit. +# It will add a remote `cgit` pointing to `git@example.com:/srv/git/repo.git. +# $1 = name of repo - I guess we could get this from the cwd maybe?. +# $2 = description to override repo/description with. + +if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then  +	echo "init-cgit NAME DESCRIPTION" +	echo "Example:" +	echo '    init-cgit dotfiles "All of my dotfiles."' +	exit 0 +fi + + +GIT_USER="git" +SRV_GIT_PATH="/srv/git" + +if [ -z "$BARE_WEBSITE_URL" ] ; then  +	echo "BARE_WEBSITE_URL must be set" +	exit 1 +fi + +# First, create bare repo on remote. +ssh "$GIT_USER@$BARE_WEBSITE_URL" "cd; git init --bare $1" + +if [ ! -z "$2" ] ; then +	ssh "$GIT_USER@$BARE_WEBSITE_URL" "cd; echo \"$2\" > $1/description" +fi + +# Now create `cgit` remote in local repo. +git remote add cgit "$GIT_USER@$BARE_WEBSITE_URL:$SRV_GIT_PATH/$1" +git push cgit master | 
