Subversion server, installing

From NAS-Central Buffalo - The Linkstation Wiki
Jump to: navigation, search

This article describes setting up a simple Subversion server for your LAN using svnserve. You can choose more advanced configurations if you prefer (see http://svnbook.red-bean.com/ for more information).

1. First let's install Subversion. Use the command:

apt-get install subversion

2. You may like to install these too:

apt-get install subversion-tools db4.4-util patch xml-core

3. Create your repository. I like to use a directory that contains multiple repositories, one for each project; svnserve is quite happy to serve all of them. For example,

mkdir /home/svnrepos
svnadmin create /home/svnrepos/project1

4. Create /etc/init.d/svnserve as follows:

#! /bin/sh -e
#### BEGIN INIT INFO
# Provides:          synserve
# Required-Start:    $syslog $time $local_fs $remote_fs
# Required-Stop:     $syslog $time $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: Subversion repository server
# Description:       Debian init script for the Subversion repository server
### END INIT INFO
#
# Author:       Rick Beton
#
set -e

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/bin/svnserve
REPOS=/home/svnrepos

test -x $DAEMON || exit 0

. /lib/lsb/init-functions

case "$1" in
    start)
        log_daemon_msg "Starting Subversion server" "svnserve"
        $DAEMON -d -r $REPOS
        log_end_msg $?
    ;;
    stop)
        log_daemon_msg "Stopping Subversion server" "svnserve"
        killproc $DAEMON
        log_end_msg $?
    ;;
    force-reload|restart)
        $0 stop
        $0 start
    ;;
    *)
        echo "Usage: /etc/init.d/svnserve {start|stop|restart|force-reload}"
        exit 1
    ;;
esac

exit 0

5. Set your server to start at the correct runlevels. I did this by creating symbolic links to /etc/init.d/svnserve: I created /etc/rc1.d/K92svnserve, /etc/rc2.d/S92svnserve, /etc/rc3.d/S92svnserve, /etc/rc4.d/S92svnserve, /etc/rc5.d/S92svnserve.

Alternatively (on Ubuntu, at least), the following will start svnserve at runlevel 2, and stop it on runlevels 0 1 6:

update-rc.d svnserve start 92 2 . stop 92 0 1 6 .
Call for help!
Bar.png
Can someone confirm that 'update-rc.d' works on Debian as well as Ubuntu?