I finally got around to setting up Git [1] & [2] and Subversion for my personal development environment. I also installed the GitPlugin for Trac so I’d have a choice of either SCM tool from within Trac so that I can use either SCM. I wanted to make sure that all my urls were consistent so I spent a good deal of time mapping this all out and making sure that these urls would be handled correctly by apache using mod_rewrite and proxying, since my git and subversion servers are behind my firewall.
Repo viewers
I was interested in having the top urls, svn.lamolabs.org and git.lamolabs.org taking you directly to a repository viewer. For Git I chose gitweb, while for Subversion I chose webSVN. So here are the links to the 2 web repo viewers.
- Repo #1, Git – git.lamolabs.org
- Repo #2, Subversion – svn.lamolabs.org
For gitweb I added the following to /etc/gitweb.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # my overrides $projectroot = '/proj/lamolabs.org/scm/git'; $site_name = "Lamolabs.org's git trees."; $projects_list_description_width = 55; #$home_link_str = "/proj/lamolabs.org/scm/git"; $home_link_str = "/scm/git"; $feature{'snapshot'}{'default'} = ['zip', 'tgz']; $feature{'snapshot'}{'override'} = 1; @git_base_url_list = ( "http://www.lamolabs.org/scm/git", "git://git.lamolabs.org/scm/git" ); # Don't Change the variables below $my_uri = "/"; $home_link = '/'; @stylesheets = ("/mygitweb.css"); $favicon = "/git-favicon.png"; $logo = "/git-logo.png"; |
For webSVN I copied the file distconfig.php to config.php and modified it. This file was buried down in webSVN’s include sub-directory. There are a ton of notes in the file config.php which explain how to customize it, so I’m not going to cover that here.
svn:// and git:// urls
Once I got these setup I next wanted to focus on making sure that the repos were also accessible using the svn:// and git:// protocols. This required actually setting up git-daemon and svnserve. These were both just rpm installs but I did have to tweak them a bit to get them serving the urls just the way I wanted.
Ironically neither RPM provided a stop/start script so I put ones together myself by hand.
Here’s /etc/init.d/svnserve
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #!/bin/bash # Control script for the Subversion daemon # # chkconfig: 2345 89 40 # description: Subversion daemon # # processname: svnserve source /etc/rc.d/init.d/functions [ -x /usr/bin/svnserve ] || exit 1 ### Default variables SYSCONFIG="/etc/sysconfig/subversion" ### Read configuration [ -r "$SYSCONFIG" ] && source "$SYSCONFIG" RETVAL=0 prog="svnserve" desc="Subversion daemon" start() { echo -n $"Starting $desc ($prog): " daemon $prog -d $OPTIONS RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog echo } stop() { echo -n $"Shutting down $desc ($prog): " killproc $prog RETVAL=$? [ $RETVAL -eq 0 ] && success || failure echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) stop start RETVAL=$? ;; condrestart) [ -e /var/lock/subsys/$prog ] && restart RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|condrestart}" RETVAL=1 esac exit $RETVAL |
And here’s /etc/init.d/git-daemon
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #!/bin/sh # # Startup/shutdown script for Git Daemon # # Linux chkconfig stuff: # # chkconfig: 345 56 10 # description: Startup/shutdown script for Git Daemon # . /etc/init.d/functions DAEMON=git-daemon ARGS='--base-path=/proj/lamolabs.org --detach --user=apache --group=apache --export-all --verbose' prog=git-daemon start () { echo -n $"Starting $prog: " # start daemon daemon $DAEMON $ARGS RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/git-daemon return $RETVAL } stop () { # stop daemon echo -n $"Stopping $prog: " killproc $DAEMON RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/git-daemon } restart() { stop start } case $1 in start) start ;; stop) stop ;; restart) restart ;; status) status $DAEMON RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|status}" exit 3 esac exit $RETVAL |
Additionally, for subversion I opted to create a sysconfig file, /etc/sysconfig/subversion, to handle the extra options that get passed to svnserve.
1 2 3 4 5 6 7 | # Configuration file for the Subversion service # # To pass additional options (for instace, -r root of directory to server) to # the svnserve binary at startup, set OPTIONS here. # #OPTIONS= OPTIONS="--threads --root /proj/lamolabs.org" |
I then added these stanzas to /etc/ssh/ssh_config on my firewall box to handle incoming ssh connections and direct them to the appropriate backend server.
1 2 3 4 5 | Host svn.lamolabs.org
ProxyCommand ssh -q -a svn.bubba.net nc -q0 %h %p
Host git.lamolabs.org
ProxyCommand ssh -q -a git.bubba.net nc -q0 %h %p |
The final product of all this is the following urls to push/pull content from by SCM repos.
subversion
- http://www.lamolabs.org/scm/svn/ + project path
- http://svn.lamolabs.org/scm/svn/ + project path
- svn://svn.lamolabs.org/scm/svn/ + project path
git
- http://www.lamolabs.org/scm/git/ + project path
- http://git.lamolabs.org/scm/git/ + project path
- http://git.lamolabs.org/ + project path
- git://git.lamolabs.org/scm/git/ + project path
Testing it all out
I wanted to make sure that the setup was working so I put together 2 scripts to exercise all these options out.
subversion: test_svn.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # external rm -fr apache_matrix svn co http://www.lamolabs.org/scm/svn/apache_matrix rm -fr apache_matrix svn co http://svn.lamolabs.org/scm/svn/apache_matrix rm -fr apache_matrix svn co svn://svn.lamolabs.org/scm/svn/apache_matrix rm -fr apache_matrix # internal rm -fr apache_matrix svn co http://kang.bubba.net/scm/svn/apache_matrix rm -fr apache_matrix svn co http://svn.bubba.net/scm/svn/apache_matrix rm -fr apache_matrix svn co svn://svn.bubba.net/scm/svn/apache_matrix rm -fr apache_matrix |
git: test_git.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #!/bin/sh # external rm -fr bashpodder git clone http://www.lamolabs.org/scm/git/bashpodder.git rm -fr bashpodder git clone http://git.lamolabs.org/scm/git/bashpodder.git rm -fr bashpodder git clone http://git.lamolabs.org/bashpodder.git rm -fr bashpodder git clone git://git.lamolabs.org/scm/git/bashpodder.git rm -fr bashpodder # internal rm -fr bashpodder git clone http://kang.bubba.net/scm/git/bashpodder.git rm -fr bashpodder git clone http://git.bubba.net/scm/git/bashpodder.git rm -fr bashpodder git clone http://git.bubba.net/bashpodder.git rm -fr bashpodder git clone git://git.bubba.net/scm/git/bashpodder.git rm -fr bashpodder |
BAM!!! All is right with the world.



Hey. Thanks for posting your git-daemon file; I shamelessly reused it on my site
Cheers.
Glad it helped someone out. Nice to be able to give something back!