Tutorials and How-tos/Install Subversion

From BubbaWiki
Jump to navigation Jump to search

Subversion is a very good for developers to have. I will expand and old how to, that can be found from the forum: http://forum.excito.net/viewtopic.php?f=8&t=557

This extended installation is depending on a second server ( I use a Qnap-TS639 Pro ).

The reason for this how to is to make sure the source code that is checked in is always backed up and safe. By setting up the Subversion server on Bubba and store the important data on another server that runs raid but not Subversion, we can combine the best things.

HINT: Before you begin with this make sure the share on the QNAP server is setup with the name DevRepositories on example shown here this QNAP server IP is

Enough talk now let's get started.

Installation (One time only)

1. First we need to do is to install subversion.

# apt-get install subversion

2. The next thing we need to do is add a subversion group.

# groupadd svn

3. Followd by a new user.

# useradd -m -d /home/svn -s /bin/bash -g svn svn

4. Now let us add a secure password for the subversion user.

# passwd svn

5.Now we can go to the new user svn home directory.

# cd /home/svn

6. Now we need to create the repository directory.

# mkdir DevRepositories

7. Now to acctully combine the Qnap server with the Bubba|Two server we need to do a network mount.

# mount -t nfs -o nolock DevRepositories/

8. Now let us go in to the repository directory.

# cd DevRepositories

9. Now we need to be the user svn. To achive this we can run the following command.

# su svn

10. Now we need to create the repository.

# svnadmin create Projects

11. Now we need to setup the configurations. First let us go to the folder.

# cd Projects/conf

12. With you favorite editor edit the passwd file. I will use nano editor.

Add a new svn user to the file and save the file when done.

# nano passwd

13. When you have add the user(s) you need to edit the svnserve.conf file. I will use nano editor.

# nano svnserve.conf 

14. Edit the following lines in the svnserve.conf file. Save the file and logout (CTRL+D) the svn user.

# anon-access = none
# auth-access = write
# password-db = passwd

15. Now we need to create the auto start script so when the Bubba|Two server reboot it will start the subversion server.
Start with creating the file and make it executable.

# touch /etc/init.d/subversion
# chmod +x /etc/init.d/subversion

16. Edit the new created file /etc/init.d/subversion I will use nano to edit the file.

# nano /etc/init.d/subversion

17. Modify the file to look like this (This script was copied from the this forum post:http://forum.excito.net/viewtopic.php?f=8&t=557)

# Start/stop the subversion daemon.

test -f /usr/bin/svnserve || exit 0

case "$1" in

start)   echo -n "Starting Subversion server"
       start-stop-daemon --start --chuid svn:svn --exec /usr/bin/svnserve --quiet -- -d -r /home/svn/DevRepositories
       echo "."
stop)   echo -n "Stopping Subversion server"
       start-stop-daemon --stop  --exec /usr/bin/svnserve --quiet
       echo "."
restart) echo -n "Restarting Subversion"
       start-stop-daemon --stop  --retry 5 --exec /usr/bin/svnserve --quiet
       start-stop-daemon --start --chuid svn:svn --exec /usr/bin/svnserve --quiet -- -d -r /home/svn/DevRepositories
       echo "."
*)   echo "Usage: /etc/init.d/subversion start|stop|restart"
       exit 1
exit 0

18. [Recommended] To add the script to autostart run the following command.

# update-rc.d /etc/init.d/subversion defaults

19. [Optional] To remove the autostart run the following command.

# update-rc.d /etc/init.d/subversion remove

Recovery Process

To recover the repository if something happen. Follow the instructions below.

1. Follow the above instruction to step no. 9.

2. Instead of svnadmin create. Use svnadmin recover.

# svnadmin recover DevRepositories/Projects

3. Now follow the steps 15 - 17 to add the start/stop script, it is recommended to add the script to auto start (step 18).

This should be all, everything should be back to normal!