running Subversion's svnserve on a Debian system

Subversion [1] is a free version control software. You can manage textfile / sourcecode versions on multiple machines with it and much, much more. This howto shows how to setup the included svnserve to allow remote LAN access to the repositories on a Debian machine. Please note that if you want to access these over the internet using the Apache webserver is probably way more secure than the simplistic svnserve !



foreword[top]

This tutorial is based on a linux system (a Debian specifically). Svnserve is a small, leightweight server to allow remote access to a Subversion repository.

installation[top]

The installation under Debian :

$ apt-get update
$ apt-get install subversion

Next we need an unpriviliged user to actually own our repositories and the svnserve process - I use the user "svn" who is a member of the group "src" and has no shell access.
Of course the directory that will keep our repositories needs to be owned by our new user :

$ chown -R svn:src /mnt/repos

Unfortuantely there is no init script for svnserve included - the following is a very basic init script for it:

#!/bin/sh
#
# start/stop subversion daemon

test -f /usr/bin/svnserve || exit 0

OPTIONS="-d -T -r /mnt/repos"

case "$1" in
 start)
  echo -n "Starting subversion daemon:"
  echo -n " svnserve"
  start-stop-daemon --start --quiet --oknodo --chuid svn:src --exec /usr/bin/svnserve -- $OPTIONS
  echo "."
  ;;

 stop)
  echo -n "Stopping subversion daemon:"
  echo -n " svnserve"
  start-stop-daemon --stop --quiet --oknodo --exec /usr/bin/svnserve
  echo "."
  ;;

 reload)
  ;;

 force-reload)
  $0 restart
  ;;

 restart)
  $0 stop
  $0 start
  ;;

 *)
  echo "Usage: /etc/init.d/subversion (start|stop|reload|restart)"
  exit 1
  ;;

esac

exit 0

"OPTIONS" define the parameters svnserve ist started with (notice the path to the repositories). Start-stop-daemon does all of the other work for us. Simply copy the script text, save it to a local file (e.g. subversion), adjust the options, copy it and tell the system to start it automatically :

$ cp subversion /etc/init.d/
$ cd /etc/init.d
$ update-rc.d subversion defaults

Svnserve will now automatically start/stop on the default runlevels.

usefull[top]

On my Windows box I use TortoiseSVN [2] ... TortoiseSVN uses the explorers context menue to enable access to the Subversion commands.

links[top]

  1. Subversion Homepage [http://subversion.tigris.org]
  2. TortoiseSVN Homepage [http://www.tortoisesvn.org]

Changelog[top]