Skip to content. | Skip to navigation

Personal tools
Log in
Sections
You are here: Home How To OS X Admin SVN Daemon

Setup SVN Daemon / Subversion Daemon

Step by step instructions for setting up an svn daemon / subversion daemon on OS X.

 

Build SVN

It is easist to use fink, although fink lags behind new OS X distributions. Either way, unless you wisely resist the compulsive urge to upgrade OS X, you are going to wrestle with building subversion. Best is to stay about 6 to 9 months behind the latest-greatest major OS X version and just use fink.

fink install svn

 

Create the SVN User

For a stock OS X install, the user with UniqueID 101 should not exist. If you have done some serious administrating on your OS X box, you may want to check that user 101 doesn't exist:

id 101

If you get back, "id: 101: no such user", then you can use 101, otherwise try another number below 500 in the following instructions.

Create the svn user named "svnuser". Do it by the command line for greater control. This also has the benefit of being remote-friendly.

sudo dscl . -create /Users/svnuser
sudo dscl . -create /Users/svnuser RealName SVN User
sudo dscl . -create /Users/svnuser UserShell /dev/null
sudo dscl . -create /Users/svnuser PrimaryGroupID 1
sudo dscl . -create /Users/svnuser UniqueID 101
sudo dscl . -create /Users/svnuser NFSHomeDirectory /var/svnuser

To hide the svnuser account from the login window, execute this command at the Terminal:

sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add svnuser

 

Create the Home Directory for SVN

In principle, the svnuser does not need a home directory, but I like to have one extra level of directory structure for organization.

sudo mkdir /var/svnuser
sudo chown svnuser:daemon /var/svnuser

 

Create the Repository

If this is your first repository, you need to make it de novo.

See the next section if you already have a repository, but need to migrate it to a new machine.

sudo /sw/bin/svnadmin create /var/svnuser/repo --fs-type fsfs

You probably have an existing directory that you would like to get under version control. This can be done after the server is fully functional by importing the directory. See the subversion documentation.

 

Import a Repository

If you already have and existing svn repository, just copy it en masse from its current location.

  1. First, on the new svn server, make sure that the svnuser directory is writeable by whichever user you will use to copy the repository. This won't be svnuser because it is a crippled account. It probably won't be root either, because that would be a security risk. Therefore, I temporarily make the directory writeable by all.
  2. sudo chmod a+x /var/svnuser
  3. Now copy the contents old "repo" folder to its new home, also called "repo". In this example, my new repository is on a different machine and I use rsync to execute the copy from the old machine. Note that the trailing slash in "repo/" indicates to copy the contents of the directory.
  4. rsync --progress -vae 'ssh' repo/ new.svnserver.example.org:/var/svnuser/repo
  5. Change the ownership of the new repository to svnuser:daemon on the new machine:
  6. sudo chown -Rv svnuser:daemon /var/svnuser

 

Create the Launch Daemon

In /Library/LaunchDaemons, add this file as "org.tigris.subversion.svnserve.plist":

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Debug</key>
<false/>
<key>Disabled</key>
<false/>
<key>GroupName</key>
<string>daemon</string>
<key>Label</key>
<string>svn</string>
<key>OnDemand</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/sw/bin/svnserve</string>
<string>--inetd</string>
<string>--root=/var/svnuser/repo</string>
</array>
<key>ServiceDescription</key>
<string>SVN Code Version Management</string>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockFamily</key>
<string>IPv4</string>
<key>SockServiceName</key>
<string>svn</string>
<key>SockType</key>
<string>stream</string>
</dict>
</dict>
<key>Umask</key>
<integer>2</integer>
<key>UserName</key>
<string>svnuser</string>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
</dict>
</plist>

 

Start it Up

The SVN Daemon should now be available on reboot. If it isn't available, you may have used a different user from svnuser, a different directory from /var/svnuser/repo, or something other than the fink svnserve, etc. In the case of these types of differences, you will want to go through the example step-by-step and adjust commands and the daemon plist file accordingly.