pantz.org banner
Quick Subversion setup
Posted on 01-18-2010 21:05:59 UTC | Updated on 01-18-2010 21:19:08 UTC
Section: /software/subversion/ | Permanent Link

This a quick and dirty setup of the Subversion version control system on CentOS 5. This setup will use the built in Subversion daemon as opposed to the popular Apache mod_svn module where check in's and check out's are done through http. For more information on Subversion please visit their website linked above or the fantastic free book Version control with Subversion.

Install and run Subversion on CentOS 5

This install is done on CentOS Linux 5. These steps should work on almost any Linux distro. It assumes you can install packages with yum from a repository somewhere. It will also let the svn daemon run on it's default port of 3690. Make sure your firewalls are open if you need to get to it remotely. Also, repo is short for Subversion repository.

Login to the machine as root or sudo to root (sudo su -).

Install subversion with yum.

yum install subversion

Make a user and group called svn to run the server as.

adduser -M svn -s /sbin/nologin

Make a directory to store the svn repositories. I'm going to use /disk01/svn in this example.

mkdir -p /disk01/svn

Optional step: Sync a remote svn repository if you have one. If not just move on to the next step.

rsync -av --timeout=30 --delete --rsh="ssh -c arcfour -l root" remotehost:/disk01/svn/ /disk01/svn/

If you did not copy other repos from elsewhere or just want to make another/new one do the following. Put in your repo name where the word repo is.

svnadmin create /disk01/svn/repo

Give the svn user permission to everything in the dir before starting.

chown -R svn: /disk01/svn

Let's start the svn deamon as the svn user. All repos are assumed to be in dir /disk01/svn.

su -m svn -c 'svnserve -d -r /disk01/svn'

That should have started the svnserv daemon. Check your process list (ps -aux |grep svnsrve). If everything worked put that line in the /etc/rc.local file so it will start on start up.

Repository Configuration

The configuration for each repo is in the file svnserve.conf in each repo's conf dir. It sets the access type allowed to the repo. repo is the name of the repo you want to change the config for.

Edit the file /disk01/svn/repo/conf/svnserve.conf.

The following file is an example of a simple but effective setup. Everyone has anon read access. Only people that have authorized can write. Authorization is done through the repo passwd file using built in authorization (this is discussed next).

[general]
anon-access=read
auth-access=write
password-db=passwd

Save the file. You don't need to restart the daemon for it to take effect.

Adding Users and Authorization

To add a user to svn you will add them to the Subversion passwd file. This is located in the repo's conf dir. repo is the name of the repo you want to change the password for.

Edit the file /disk01/svn/repo/conf/passwd

The following file is the format of the passwd file. It is just plain text. The format very important. Even a wrong space can mess it up. Make sure there are no spaces between user=password. One user=password per line. Add as many as you want.

[users]
user1=password1
user2=password2

Save the file. You don't need to restart the daemon for it to take effect.

Subversion commands

Here are some simple commands to test your new repo or possibly ones you copied over from another machine.

Copy a subversion repo directory

svn co svn://hostname/reponame/trunk

List the files in a repo

svn list svn://hostname/reponame/trunk/scripts

Get info on file in repo

svn info svn://hostname/reponame/trunk/scripts/filename

Repo update emails

If you want an email update when a repo gets updated you can put this script in the repo's hooks dir. This script will run on each commit. Put the following shell script code into the file /disk01/svn/reponame/hooks/post-commit. Where reponame is the repo you want the emails for. You may have to rename the file in the hooks dir to post-commit as there is usually a default one or you can just make a new one.

REPOS="$1"
REV="$2"

REPOS_BASE=${REPOS##*/}
EMAIL_LIST="email1@hostname.org email2@hostname.org email3@hostname.org"

svn log --verbose -r $REV svn://hostname/${REPOS_BASE} | mail -s "Commit notice for repository ${REPOS_BASE}" ${EMAIL_LIST}

Reddit!

Related stories


RSS Feed RSS feed logo

About


3com

3ware

alsa

alsactl

alsamixer

amd

android

apache

areca

arm

ati

auditd

awk

badblocks

bash

bind

bios

bonnie

cable

carp

cat5

cdrom

cellphone

centos

chart

chrome

chromebook

cifs

cisco

cloudera

comcast

commands

comodo

compiz-fusion

corsair

cpufreq

cpufrequtils

cpuspeed

cron

crontab

crossover

cu

cups

cvs

database

dbus

dd

dd_rescue

ddclient

debian

decimal

dhclient

dhcp

diagnostic

diskexplorer

disks

dkim

dns

dos

dovecot

drac

dsniff

dvdauthor

e-mail

echo

editor

emerald

ethernet

expect

ext3

ext4

fat32

fedora

fetchmail

fiber

filesystems

firefox

firewall

flac

flexlm

floppy

flowtools

fonts

format

freebsd

ftp

gdm

gmail

gnome

google

greasemonkey

greylisting

growisofs

grub

hacking

hadoop

harddrive

hba

hex

hfsc

html

html5

http

https

hulu

idl

ie

ilo

intel

ios

iperf

ipmi

iptables

ipv6

irix

javascript

kde

kernel

kickstart

kmail

kprinter

krecord

kubuntu

kvm

lame

ldap

linux

logfile

lp

lpq

lpr

maradns

matlab

memory

mencoder

mhdd

mkinitrd

mkisofs

moinmoin

motherboard

mouse

movemail

mplayer

multitail

mutt

myodbc

mysql

mythtv

nagios

nameserver

netflix

netflow

nginx

nic

ntfs

ntp

nvidia

odbc

openbsd

openntpd

openoffice

openssh

openssl

openvpn

opteron

parted

partimage

patch

perl

pf

pfflowd

pfsync

photorec

php

pop3

pop3s

ports

postfix

power

procmail

proftpd

proxy

pulseaudio

putty

pxe

python

qemu

r-studio

raid

recovery

redhat

router

rpc

rsync

ruby

saltstack

samba

schedule

screen

scsi

seagate

seatools

sed

sendmail

sgi

shell

siw

smtp

snort

solaris

soundcard

sox

spam

spamd

spf

spotify

sql

sqlite

squid

srs

ssh

ssh.com

ssl

su

subnet

subversion

sudo

sun

supermicro

switches

symbols

syslinux

syslog

systemd

systemrescuecd

t1

tcpip

tcpwrappers

telnet

terminal

testdisk

tftp

thttpd

thunderbird

timezone

ting

tls

tools

tr

trac

tuning

tunnel

ubuntu

unbound

vi

vpn

wget

wiki

windows

windowsxp

wireless

wpa_supplicant

x

xauth

xfree86

xfs

xinearama

xmms

youtube

zdump

zeromq

zic

zlib