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
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
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.
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
- Create a folder called SVNRepository in the newly created partition: mkdir SVNRepository
- Run the command to give admin privileges: sudo chgrp -R admin /Volumes/SVN/SVNRepository/
- Create the svn repository. For this exercise lets call the repository as DocumentsRepository. svnadmin create /SVN/SVNRepository/DocumentsRepository
- The next few steps involve configuring the settings for your server.
- Enter the /SVN/SVNRepository/DocumentsRepository folder cd /SVN/SVNRepository/DocumentsRepository.
- Enter the conf folder. cd conf
- Edit the svnserver.conf file.
- Edit the following elements in the file, make sure that there is no white space before the line.
- anon-access = read //this means no authentication is required to read
- auth-access = write
- password-db = passwd
- Save the file.
- Edit the passwd file.
- Edit the following elements in the file.
- Under users add the following users.
- employee1 = password1
- employee2 = password2 (Note: For a real world implementation make sure that you use stronger authentication methods for your server.)
- Add as many users as you wish.
- Save the file.
- Start the svnserver (as root) using the following command: sudo /usr/bin/svnserver -daemon -root /SVN/SVNRepositories
- Navigate to the folder where all your data is located
- cd ~/Documents/ImportFolder
- Run the import command to add the files to your repository.
- sudo svn import . file://SVN/SVNRepository/DocumentsRepository/ -m “Initial Checkin”
- This has setup your svn server with some initial data in it.
- Now we perform a sanity check to make sure that all is working well.
- cd ~/Documents/
- mkdir Test (This is the folder where we will check-out the files from the server)
- svn co svn://<ip address of your server>/DocumentsRepository
- This should check-out all the files from the repository into your folder.
- Check to make sure that all the files were checked out.
- 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.
- Make sure the computer for Employee1 is on the same network.
- Open Finder & Browse for the Network partition being shared by the server.
- Mount the shared volume in Finder. Authenticate using Employee1’s sharing user credentials if necessary.
- Open the Terminal application.
- Navigate to the Document’s folder: cd ~/Documents
- Create a project folder: mkdir Project.
- Navigate to the Project folder: cd Project.
- Now we run the command to checkout files into your folder: svn co svn://<ip address of your server>/DocumentsRepository.
- Browse through the newly checked out files.
- Let us try adding a file to the repository.
- Create a new file using TextEdit.
- Open Text edit.
- Type “This file was created by Employee 1”.
- Save the file as Employee_1_Report in the ~/Documents/SVNRepository/DocumentsRepository folder.
- Now run the command svn add Employee_1_Report.
- Lets commit the changes to the repository: svn ci —message “Adding new file” Employee_1_Report
- If prompted to authenticate enter the details you specified in the passwd file employee1 as the username & password1 as the password.
- Create a new file using TextEdit.
- Now you have added a file to repository from your client machine.
- Repeat steps 1 – 9 for Employee2 from a different machine.
- Verify that files added from one machine appear on the other.
- Thats it. You now have a working svn-server on your local area network.
- You can try adding & editing files to check if the changes reflect on both the computers.