Step-by-step guide to installing Subversion
This guide will use the Subversion server svnserve in inetd spawned mode.
- 1 Install Subversion Server
- 1.1 Enable CLI on your Diskstation
- 1.2 Create a user for svnserve daemon
- 1.3 Create a new share for your repositories
- 1.4 Install the ipkg bootstrap
- 1.5 Install Subversion Package
- 1.6 Configure Unix inetd daemon to spawn Subversion when required
- 1.7 Edit /etc/services to include Subversion data
- 1.8 Reboot
- 2 Test the operation of Subversion on your Diskstation
- 3 Install WebSVN
- 4 Further information
Install Subversion Server
Enable CLI on your Diskstation
Create a user for svnserve daemon
For security reasons it is a good idea to create a separate user just for the Subversion daemon. Use the MUI under Privileges -> User to create a new user. In this guide I will be using svnowner. Give this user a complicated password, which we actually do not need to remember, as we will just spawn svnserve daemon with this user account from inetd, so just set it to some value (for security reasons to something other than the empty value).
This step is optional, but is a good idea to keep the management more straightforward. Use the MUI under Privileges -> Shared Folder to create a new shared folder. In this guide I will be using svn. Be sure to give admin and svnowner read-write permissions and remove all rights from the rest of the users.
Install the ipkg bootstrap
We need to install the ipkg bootstrap to be able to easily install the Subversion Package from the OptWare feeds. See the Bootstrap section in Overview on modifying the Synology Server, bootstrap, ipkg etc
Install Subversion Package
Now that you have installed ipkg we can install the Subversion Package from the Command Line Interface. Issue:
ipkg install svn
The ipkg will also install some dependencies (other required packages), which is normal and desired.
Configure Unix inetd daemon to spawn Subversion when required
I chose to use inetd method instead of running svnserve as daemon (see SVN Book under server configurations for more information about svnserve modes), as in this case the Unix inetd daemon will temporarily spawn svnserve whenever a request comes in on port 3690 (IANA-Subversion). This method uses the limited amount of RAM in Diskstation for Subversion only when required. Disadvantage over standalone svnserve daemon mode is that it takes a bit more time during client connect, as each time first the svnserve needs to be loaded into RAM.
For adding Subversion to inetd, we need to edit the inetd configuration file /etc/inetd.conf. For mods we will use somewhat unintuitive (specially for Windows users) text-editor vi from 1976 as this is the only editor already installed on the Synology. vi key-mapping can be seen here. Following the detailed instructions below requires no previous vi knowledge.
First open the file in vi with:
Press Shift+a to append to end of line. Press Enter for a newline and enter following text all in a single line:
svn stream tcp nowait svnowner /opt/bin/svnserve svnserve -i -r /volume1/svn
Be sure to match the username svnowner and the repository directory /volume1/svn to your customizations if you did choose something other than the examples in the beginning of this guide. Press ESC to quit the insert mode. Type:
to write the file to disk and quit vi.
Edit /etc/services to include Subversion data
Add the following 2 lines to your /etc/services file (see step 11 for vi instructions):
svn 3690/tcp # Subversion svn 3690/udp # Subversion
Be sure to save your changes with:
Subversion should be running on your Diskstation now. Below are some further tips on how to access and test the functionality of Subversion.
Test the operation of Subversion on your Diskstation
Create SVN Repository
Log into your Diskstation with SSH and root account. Change your personality to user svnowner with:
Notice: If you experience an error like
su: cannot run /sbin/nologin: No such file or directory you should look here: Changing the login shell for a user.
Create under /volume1/svn a new repository with:
cd /volume1/svn svnadmin create test
(Naturally test can be substituted with some other name you like.)
Notice, that a directory (with Subversion management content) named test is created. You can check this for example with command:
Set repository permissions
Under /volume1/svn/test/conf you will find repository configuration files, interesting for us at the moment are only passwd and svnserve.conf. For testing edit the passwd file to have following contents:
[users] testuser = testpw
Notice that the password will be written in clear-text in this file, so for security reasons you might want NOT to use the same credentials as you use in your system as a login account (although if you make sure with chmod 600 passwd that only the user svnowner can access the file, the risk of someone being able to sneak a peak without administrative account or knowing the svnowner password is minimal).
Edit also the svnserve.conf to have following contents:
[general] anon-access = none auth-access = write password-db = passwd realm = I am your test repository
This will disable anonymous access completely. If you want people to access your repo without any authentication, use following line instead to give anonymous users just read access:
or to give everybody full access (not really recommended for other than just testing):
Checkout the repository
Make sure you have svn client tools installed on your computer. In command line issue:
svn co svn://<IP of your Diskstation>/test <some localfolder>
When asked password for svnowner press just Enter. Input username: testuser and password: testpw as defined in file passwd.
Windows users might consider using TortoiseSVN, which will integrate Subversion client functionality into Windows Explorer. After installation and requested reboot just right click in an empty place in Windows Explorer and choose SVN Checkout... Your repository Path (URL of repository) is:
svn://<IP of your Diskstation>/test
In Checkout directory type a path to a new non-existing or empty directory. Leave the other options to their defaults and click OK. You will be asked for a username and password, these are according to file /volumes1/svn/test/conf/passwd testuser and testpw accordingly.
You should have successfully checked out the revision 0 of the repository. Click OK to dismiss the dialog.
Add a new file and commit it
To check that you can also commit into the repository, add a new file under the newly created repository.
In Unix, Linux and Mac this test could be performed like this:
cd /<localfolder, where you checked out the repository> echo "I am a Test" > test.txt svn add test.txt svn ci -m "Commit test"
Enter the credentials testuser and testpw accordingly.
To check commiting with TortoiseSVN under Windows you should first create or copy a sample file into the directory, which you checked out in last step. Add the new file under revision control by right-clicking it and selecting TortoiseSVN -> Add. Commit the changes by right clicking on the repository directory and choose SVN Commit...
Enter the optional, but recommended message (commit description) and click OK. Enter the credentials testuser and testpw accordingly.
You should get a commit success message Completed. Click OK to dismiss the dialog.
For more information please see the Subversion Book.
Remove test repository
To delete the test repository, SSH to your Diskstation and delete the folder /volume1/svn/test. It can be achieved with following command:
rm -rf /volume1/svn/test
Your local working copy folder, which you checked out, can be simply deleted.
What is WebSVN ?
WebSVN is a php based application which offers a view onto your subversion repositories that's been designed to reflect the Subversion methodology. You can view the log of any file or directory and see a list of all the files changed, added or deleted in any given revision. You can also view the differences between two versions of a file so as to see exactly what was changed in a particular revision.
WebSVN offers many features:
- Easy to use interface
- Customisable templating system
- Colourisation of file listings
- Blame view
- Log message searching
- RSS feed support
- and more...
How to install WebSVN
First, download the application files here  and unzip it in your apache main web directory. At this point we supposed you have created a repository named "test" with a valid configuration in subversion and you have apache with php running.
It is recommended to read the instructions from the included INSTALL.TXT (for websvn 2.3.2, look to 'doc/install.html') but basically you only need to do the following steps to make it works :
- Create your own config.php file, starting from the default one(/websvn/include/), and edit it. (for websvn 2.3.2, copy 'include/distconfig.php' to the same directory)
- Add the following line (where /opt/bin is the folder where svn was previously installed):
- You should add something like (near line 70)
$config->addRepository('Some repository','file:///data/svn/somerepository');Obviously you can add more repositories here! Add one for test :
- Tweak eventually other parameters if you know what you are doing and save the file.
- Open you php config file (php.ini from /usr/syno/etc/) and make the property safe_mode_execdir of the php.ini file empty
- Also add the folder, where svn (executable) is installed, to the property open_basedir of the php.ini file. Note: starting with DSM 3.0 open_basedir is instead set in /usr/syno/etc/php/user-setting.ini. Also, setting PHPINI_BASEDIR_DEF is optional. Note: starting with DSM 2.3 the php.ini is overwrited by S97apache-user.sh at boot and everytime you restart http calling S97apache-user.sh script. You should adjust the PHPINI_BASEDIR_DEF from /usr/syno/etc/rc.d/S97apache-user.sh script by adding /opt/bin to it.
- Restart apache (/usr/syno/etc/rc.d/S97apache-user.sh restart)
Finally you should now have a working WebSVN php application. You can test it here http://yoursite/websvn/.