Configuring an SVN Server on OS X on your Local Network

The following post walks through the steps required to setup a simple SVN server to share files with users on the network. Note: Familiarity with Terminal Commands is required. Please go through the following blogs: Terminal Commands, Terminal Commands 2, Terminal Commands 3

Note:

The following steps illustrate the process of setting up an SVN server for a simple scenario. It can be easily scaled to handle multiple computers & users. In a real world situation you would have to deal with stronger authorisation procedures & larger networks.

 

Requirements for this demo

  • 3 Apple Computers running OS X Mavericks
  • All 3 computers should be on the same network
  • Knowledge of Terminal commands

 

Pre-setup steps

1.Decide which computer you want to setup as the SVN server. Change the hostname of the computer to SVN Server.

2.To change the hostname open System Preferences > Sharing > Click on Computer Name > Enter SVN Server.

3.Create a Share Point where you will be hosting the server. For this exercise we will be creating a separate partition & will be sharing it with other users on the network.

4.To create a new partition open Disk Utility > Select the Disk entry (not the volume entry) > Click on Partition Tab > Select the Partition you want to further partition >  Click on the ‘+’ sign > Specify the name, size & format for the partition (for this demo we will use SVN, 10 GB, Mac OS Extended Journaled) > Click Apply

5.Access authorisation for this share point will be via a sharing only user. Create to users called Employee1 & Employee2. Give them a password emp1 & emp2 respectively.

6.To create sharing only users open System Preferences > Click on Users & Groups > Click on ‘+’ sign to add new user (If necessary authenticate as an admin user to unlock) > From the drop down select Sharing User > Provide the login credentials specified above.

7.Repeat the above step for the second user.

8.Now that we have our users ready we should go ahead & setup the newly created partition for sharing.

9.Open System Preferences > Sharing > Click on File Sharing in the service list, make sure the checkbox is checked > Click the ‘+’ sign under ‘Shared Folders’, add the newly created partition > Under the ‘Users’ list add the newly created sharing users Employee1 & Employee2, remove all other users except Admin > Give the admin user, Employee1 & Employee2 Read-write access & Everyone No Access.

10.Create a folder called ImportFolder in the Documents folder.

cd ~/Documents 

mkdir ImportFolder

  11.  Now that we have prepared the server computer, test the new shared folders from the other 2  computers (which will be used by Employee1 & Employee2).

 

Setting up the svn server

Perform these steps on the SVN Server machine

  1. Create a folder called SVNRepository in the newly created partition: mkdir SVNRepository
  2. Run the command to give admin privileges: sudo chgrp -R admin /Volumes/SVN/SVNRepository/
  3. Create the svn repository. For this exercise lets call the repository as DocumentsRepository.   svnadmin create /SVN/SVNRepository/DocumentsRepository
  4. The next few steps involve configuring the settings for your server.
    1. Enter the /SVN/SVNRepository/DocumentsRepository folder cd /SVN/SVNRepository/DocumentsRepository.
    2. Enter the conf folder. cd conf
    3. Edit the svnserver.conf file.
      1. Edit the following elements in the file, make sure that there is no white space before the line.
      2. anon-access = read //this means no authentication is required to read
      3. auth-access = write
      4. password-db = passwd
      5. Save the file.
    4. Edit the passwd file.
      1. Edit the following elements in the file.
      2. Under users add the following users.
      3. employee1 = password1
      4. employee2 = password2 (Note: For a real world implementation make sure that you use stronger authentication methods for your server.)
      5. Add as many users as you wish.
      6. Save the file.
  5. Start the svnserver (as root) using the following command: sudo /usr/bin/svnserver -daemon -root /SVN/SVNRepositories
  6. Navigate to the folder where all your data is located
    1. cd ~/Documents/ImportFolder
    2. Run the import command to add the files to your repository.
    3. sudo svn import . file://SVN/SVNRepository/DocumentsRepository/ -m “Initial Checkin”
  7. This has setup your svn server with some initial data in it.
  8. Now we perform a sanity check to make sure that all is working well.
    1. cd ~/Documents/
    2. mkdir Test (This is the folder where we will check-out the files from the server)
    3. svn co svn://<ip address of your server>/DocumentsRepository
    4. This should check-out all the files from the repository into your folder.
    5. Check to make sure that all the files were checked out.
  9. If all went ok, then you server is up & ready.

 

Testing the svn process from the 2 different computers

We are now ready to test this on different computers.

  1. Make sure the computer for Employee1 is on the same network.
  2. Open Finder & Browse for the Network partition being shared by the server.
  3. Mount the shared volume in Finder. Authenticate using Employee1’s sharing user credentials if necessary.
  4. Open the Terminal application.
  5. Navigate to the Document’s folder: cd ~/Documents
  6. Create a project folder: mkdir Project.
  7. Navigate to the Project folder: cd Project.
  8. Now we run the command to checkout files into your folder: svn co svn://<ip address of your server>/DocumentsRepository.
  9. Browse through the newly checked out files.
  10. Let us try adding a file to the repository.
    1. Create a new file using TextEdit.
      1. Open Text edit.
      2. Type “This file was created by Employee 1”.
      3. Save the file as Employee_1_Report in the ~/Documents/SVNRepository/DocumentsRepository folder.
    2. Now run the command svn add Employee_1_Report.
    3. Lets commit the changes to the repository: svn ci —message “Adding new file” Employee_1_Report
    4. If prompted to authenticate enter the details you specified in the passwd  file employee1 as the username & password1 as the password.
  11. Now you have added a file to repository from your client machine.
  12. Repeat steps 1 – 9 for Employee2 from a different machine.
  13. Verify that files added from one machine appear on the other.
  14. Thats it. You now have a working svn-server on your local area network.
  15. You can try adding & editing files to check if the changes reflect on both the computers.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s