# Subversion

#### Quick reference card

 Cloud Servers Virtual Machines Native Installers Configuration file(s) your-repository/conf/svnserver.conf your-repository/conf/svnserver.conf your-repository/conf/svnserver.conf Default port 3690 3690 3690 System user account subversion subversion subversion Service control sudo /opt/bitnami/ctlscript.sh start|stop|restart subversion sudo /opt/bitnami/ctlscript.sh start|stop|restart subversion install_dir/ctlscript.sh start|stop|restart subversion

#### How to start with Subversion in Amazon EC2?

The Subversion EC2 AMI configures a Subversion repository and Apache server to show it. The default configuration is using "svnserver" but you can use other methods (like SSH) to access your repository.

Before starting the instance, you should take into account that the default Subversion port is 3690 so it is necessary to open this port in your security group.

[general]
auth-access = write


You can edit the "passwd" file at the same directory to manage subversion users. For example, if you uncomment these lines you create two subversion users; harry and sally.

[users]
harry = harryssecret
sally = sallyssecret


Then restart the Subversion server to load the changes.

$sudo /opt/bitnami/ctlscript.sh restart subversion  Finally you can import a project directory to subversion server from your local machine and show the files in the browser. $ svn import /path/to/project/ svn://ec2-xx-yy-zz.compute-1.amazonaws.com/repository/ -m "first import"


#### How to start the Subversion server: svnserver?

By default, the "svnserver" is running in the Stacks and you can configure it. The default port is 3690.

The user have to open this port to get access to the application. Please check the following guides about how to open a port for the different types of server.

The repository's svnserve.conf file is the central mechanism for controlling authentication and authorization policies. You can edit this file in /installdir/repository/conf/svnserve.conf. If you want to create a different repository you can create it manually:

On Windows: Go to BitNami Console console and run the following command:

> svnadmin create “C:\new_repository_path”

On Linux and OS X:

Go to a BitNami Console and then run the following command:

$svnadmin create /path/to/new/repository The variables anon-access and auth-access can be set to the values none, read, or write. Setting the value to none prohibits both reading and writing; read allows read-only access to the repository, and write allows complete read/write access to the repository. For example, you can uncomment these lines: [general] anon-access = read auth-access = write password-db = passwd  You can edit passwd file at the same directory to manage subversion users. For example, if you uncomment these lines you create two subversion users; harry and sally. [users] harry = harryssecret sally = sallyssecret  It is necessary to restart "svnserve" to apply the changes. Finally you can import a project directory to subversion. $ svn import /path/to/project/ svn://localhost/repository/ -m "first import"


#### How to configure your Subversion repository though SSH?

This guide describes how to create a repository in your Virtual Machine or AMI to access remotely through SSH.

First, connect to your machine via SSH and execute the following commands to create your repositories directory /installdir/repositories and your subversion repository myapp:

$sudo mkdir /opt/bitnami/repositories$ sudo svnadmin create /opt/bitnami/repositories/myapp
$sudo chown -R bitnami:bitnami /opt/bitnami/repositories  Assign your repository to your Redmine project. In Redmine go to your project Settings/Repository section and add the following value in the URL field (login and password are not necessary): file:///opt/bitnami/repositories/myapp Now you need to check if you have subversion binaries in the PATH even in the non-interactive SSH session. Try to execute the following command: ssh -l bitnami -i /path/to/bitnami-hosting.pem mymachine.bitnamiapp.com svn  If you get "command not found" error, then you will need to update your /home/bitnami/.bashrc, and move all BitNami PATH configuration from the bottom of this file to the top, above the following entry "[ -z "$PS1" ] && return"

Checkout your repository now, start adding and commiting new files. Your repository is available remotely via the following url (please configure your Subversion client with your login: bitnami and SSH key):

svn+ssh://mymachine.bitnamiapp.com/opt/bitnami/repositories/myapp

To add example file to your repository execute the following commands on you local machine (Unix only):

$export SVN_SSH="ssh -l bitnami -i /path/to/bitnami-hosting.pem"$ svn checkout svn+ssh://mymachine.bitnamiapp.com/opt/bitnami/repositories/myapp
Checked out revision 0.
$cd myapp$ echo "This is a simple test" > Readme.txt
$svn add Readme.txt A Readme.txt$ svn commit -m "Adding simple readme file, closes #1"
Transmitting file data .
Committed revision 1.


#### How to see the Subversion repository from the web browser?

To browse the Subversion repository using a Web browser, follow the steps below.

Bitnami Cloud Hosting

• Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf to load the following modules:
LoadModule dav_module modules/mod_dav.so

• In the same file, verify the endpoint URL and path for your Subversion repository. For example, the directives below will let you view the default repository at /opt/bitnami/repository by browsing to http://[your-server]/repository.
<Location /subversion>
DAV svn
SVNPath "/opt/bitnami/repository"
</Location>

• Restart Apache:
$sudo /opt/bitnami/ctlscript.sh restart apache  Microsoft Azure Follow these steps: • Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf to load the following modules: LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so  • In the same file, verify the endpoint URL and path for your Subversion repository. For example, the directives below will let you view the default repository at /opt/bitnami/repository by browsing to http://[your-server]/repository. <Location /subversion> DAV svn SVNPath "/opt/bitnami/repository" </Location>  • Restart Apache: $ sudo /opt/bitnami/ctlscript.sh restart apache


• Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf to load the following modules:
LoadModule dav_module modules/mod_dav.so

• In the same file, verify the endpoint URL and path for your Subversion repository. For example, the directives below will let you view the default repository at /opt/bitnami/repository by browsing to http://[your-server]/repository.
<Location /subversion>
DAV svn
SVNPath "/opt/bitnami/repository"
</Location>

• Restart Apache:
$sudo /opt/bitnami/ctlscript.sh restart apache  Virtual Machine Follow these steps: • Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf to load the following modules: LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so  • In the same file, verify the endpoint URL and path for your Subversion repository. For example, the directives below will let you view the default repository at /opt/bitnami/repository by browsing to http://[your-server]/repository. <Location /subversion> DAV svn SVNPath "/opt/bitnami/repository" </Location>  • Restart Apache: $ sudo /opt/bitnami/ctlscript.sh restart apache


Native Installer

• Update the Apache configuration file at install_dir/apache2/conf/httpd.conf to load the following modules:
LoadModule dav_module modules/mod_dav.so

• In the same file, verify the endpoint URL and path for your Subversion repository. For example, the directives below will let you view the default repository at install_dir/repository by browsing to http://[your-server]/repository.
<Location /subversion>
DAV svn
SVNPath "install_dir/repository"
</Location>

• Restart Apache:
$sudo install_dir/ctlscript.sh restart apache  Tabs end You should now be able to checkout the repository using a tool like TortoiseSVN. Simply enter the URL as http://[your-server]/repository as the repository checkout URL in the TortoiseSVN interface, as shown below. ##### Enabling HTTPS You can also access through HTTPS if you already configured the Apache SSL certificate for your server. The following error can happen when the hostname reported by the server does not the match hostname given in the SSL certificate. Make sure your server configuration uses correct value for ServerName. svn: OPTIONS of 'https://example.com/repository': SSL negotiation failed: SSL error code -1/1/336032856 (https://example.com) #### How to enable commits over HTTP(S)? For security reasons, the default configuration does not allow users to commit changes to the repositories over HTTP or HTTPS. To permit this, change the permissions of your repository directory so that the Apache user is able to write to it. Bitnami Cloud Hosting Run the following command, assuming your repository is located at the default location of /opt/bitnami/repository: $ sudo chown -R daemon:subversion /opt/bitnami/repository


Microsoft Azure

Run the following command, assuming your repository is located at the default location of /opt/bitnami/repository:

$sudo chown -R daemon:subversion /opt/bitnami/repository  Google Cloud Platform Run the following command, assuming your repository is located at the default location of /opt/bitnami/repository: $ sudo chown -R daemon:subversion /opt/bitnami/repository


Virtual Machine

Run the following command, assuming your repository is located at the default location of /opt/bitnami/repository:

$sudo chown -R daemon:subversion /opt/bitnami/repository  Native Installer Run the following command, assuming your repository is located at the default location of install_dir/repository. Note that using sudo is only required if you installed the Bitnami Subversion Stack as the root user. $ sudo chown -R daemon:subversion install_dir/repository


Tabs end

 IMPORTANT: Making this change will allow any user to commit changes to your repository. To avoid unauthorized commits and possible data loss, configure basic authentication for your repository as discussed in the next section

You should now be able to commit changes to the repository using a tool like TortoiseSVN, as shown below.

#### How to configure basic authentication for your repository?

Once your repository is accessible over HTTP(s), it is recommended that you protect it from unauthorized access by configuring authentication for different users. To do this, follow the steps below for your platform.

Bitnami Cloud Hosting

• Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf and add the highlighted directives below.
<Location /subversion>
DAV svn
SVNPath "/opt/bitnami/repository"
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /opt/bitnami/repository/users
require valid-user
</Location>

With this configuration, repository access is only available to those users listed in the /opt/bitnami/repository/users file and they will need to authenticate themselves before gaining access. Note that you should update the path to the file based on the actual location of your repository.
• Create the /opt/bitnami/repository/users file and add a user account named myuser to it using the following command. You will be prompted to enter a password for the user account. Note that you should update the path to the file based on the actual location of your repository.
$sudo /opt/bitnami/apache2/bin/htpasswd -c /opt/bitnami/repository/users myuser  Repeat this step to add more users, omitting the -c argument on subsequent invocations. For example: $ sudo /opt/bitnami/apache2/bin/htpasswd /opt/bitnami/repository/users myotheruser

• Restart the Apache server.
$sudo /opt/bitnami/ctlscript.sh restart apache  Microsoft Azure Follow these steps: • Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf and add the highlighted directives below. <Location /subversion> DAV svn SVNPath "/opt/bitnami/repository" AuthType Basic AuthName "Subversion repository" AuthUserFile /opt/bitnami/repository/users require valid-user </Location>  With this configuration, repository access is only available to those users listed in the /opt/bitnami/repository/users file and they will need to authenticate themselves before gaining access. Note that you should update the path to the file based on the actual location of your repository. • Create the /opt/bitnami/repository/users file and add a user account named myuser to it using the following command. You will be prompted to enter a password for the user account. Note that you should update the path to the file based on the actual location of your repository. $ sudo /opt/bitnami/apache2/bin/htpasswd -c /opt/bitnami/repository/users myuser

Repeat this step to add more users, omitting the -c argument on subsequent invocations. For example:
$sudo /opt/bitnami/apache2/bin/htpasswd /opt/bitnami/repository/users myotheruser  • Restart the Apache server. $ sudo /opt/bitnami/ctlscript.sh restart apache


• Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf and add the highlighted directives below.
<Location /subversion>
DAV svn
SVNPath "/opt/bitnami/repository"
AuthType Basic
AuthName "Subversion repository"
AuthUserFile /opt/bitnami/repository/users
require valid-user
</Location>

With this configuration, repository access is only available to those users listed in the /opt/bitnami/repository/users file and they will need to authenticate themselves before gaining access. Note that you should update the path to the file based on the actual location of your repository.
• Create the /opt/bitnami/repository/users file and add a user account named myuser to it using the following command. You will be prompted to enter a password for the user account. Note that you should update the path to the file based on the actual location of your repository.
$sudo /opt/bitnami/apache2/bin/htpasswd -c /opt/bitnami/repository/users myuser  Repeat this step to add more users, omitting the -c argument on subsequent invocations. For example: $ sudo /opt/bitnami/apache2/bin/htpasswd /opt/bitnami/repository/users myotheruser

• Restart the Apache server.
$sudo /opt/bitnami/ctlscript.sh restart apache  Virtual Machine Follow these steps: • Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf and add the highlighted directives below. <Location /subversion> DAV svn SVNPath "/opt/bitnami/repository" AuthType Basic AuthName "Subversion repository" AuthUserFile /opt/bitnami/repository/users require valid-user </Location>  With this configuration, repository access is only available to those users listed in the /opt/bitnami/repository/users file and they will need to authenticate themselves before gaining access. Note that you should update the path to the file based on the actual location of your repository. • Create the /opt/bitnami/repository/users file and add a user account named myuser to it using the following command. You will be prompted to enter a password for the user account. Note that you should update the path to the file based on the actual location of your repository. $ sudo /opt/bitnami/apache2/bin/htpasswd -c /opt/bitnami/repository/users myuser

Repeat this step to add more users, omitting the -c argument on subsequent invocations. For example:
$sudo /opt/bitnami/apache2/bin/htpasswd /opt/bitnami/repository/users myotheruser  • Restart the Apache server. $ sudo /opt/bitnami/ctlscript.sh restart apache


Native Installer

• Update the Apache configuration file at install_dir/apache2/conf/httpd.conf and add the highlighted directives below.
<Location /subversion>
DAV svn
SVNPath "install_dir/repository"
AuthType Basic
AuthName "Subversion repository"
AuthUserFile install_dir/repository/users
require valid-user
</Location>

With this configuration, repository access is only available to those users listed in the /opt/bitnami/repository/users file and they will need to authenticate themselves before gaining access. Note that you should update the path to the file based on the actual location of your repository.
• Create the install_dir/repository/users file and add a user account named myuser to it using the following command. You will be prompted to enter a password for the user account. Note that you should update the path to the file based on the actual location of your repository.
$sudo install_dir/apache2/bin/htpasswd -c install_dir/repository/users myuser  Repeat this step to add more users, omitting the -c argument on subsequent invocations. For example: $ sudo install_dir/apache2/bin/htpasswd install_dir/repository/users myotheruser

• Restart the Apache server.
$sudo install_dir/ctlscript.sh restart apache  Tabs end If you now attempt to browse to the repository or access it using TortoiseSVN, you will be prompted for a user name and password, as shown below: ##### How to enable anonymous browsing? If you want your repository being readable but not editable by any other user, you should perform the steps above but changing the line require valid-user  for <LimitExcept GET PROPFIND OPTIONS REPORT> require valid-user </LimitExcept> ##### How to restrict HTTP access? If you only want to only allow access through HTTPS, not HTTP, you should add SSLRequireSSL to the directives described above:  ... AuthName "Subversion repository" AuthUserFile /opt/bitnami/repository/users require valid-user SSLRequireSSL </Location> #### How to enable post commit notifications via email for Subversion? In this section we will check how to configure a Subversion repository to send emails via SMTP with the commit log. Download the latest source code from Subversion and copy the hooks folder into the subversion folder: wget http://apache.mesi.com.ar/subversion/subversion-1.8.9.tar.gz tar -xzvf subversion-1.8.9.tar.gz sudo cp -r subversion-1.8.9/tools/hook-scripts /opt/bitnami/subversion/hooks Then configure the SMTP mail settings in the "mailer.conf" file: sudo cp /opt/bitnami/subversion/hooks/mailer/mailer.conf.example /opt/bitnami/subversion/hooks/mailer/mailer.conf And edit the file to add the SMTP settings. In this example we are going to use the SMTP settings for a Gmail account: [General] smtp_hostname = smtp.gmail.com:587 smtp_username = your_gmail_account smtp_password = your_password smtp_use_ssl = true ... [defaults] from_addr = mail@example.com # The default To: addresses for message. One or more addresses, # separated by whitespace (no commas). # NOTE: If you want to use a different character for separating the # addresses put it in front of the addresses included in square # brackets '[ ]'. to_addr = mail@example.com # If this is set, then a Reply-To: will be inserted into the message. reply_to = mail@example.com If you use a Gmail account or you need to use a SSL connection for your SMTP settings, you need to modify SMTPOutput class in "mailer.py" in order to use added “smtp_use_ssl” setting. This patch was submited by Alexey Samodov: @@ -278,6 +278,12 @@ def finish(self): server = smtplib.SMTP(self.cfg.general.smtp_hostname) + # 2009-12-13 asadomov: add ssl configuration (e.g. for gmail smtp server) + if self.cfg.is_set('general.smtp_use_ssl') and self.cfg.general.smtp_use_ssl.lower() == "true": + server.ehlo() + server.starttls() + server.ehlo() + if self.cfg.is_set('general.smtp_username'): Then configure your post-commit hook script to use the "mailer.py" and "mailer.conf" files. The location of your post-commit scripts depends on the location of your repository. We will use the following path in this example "/opt/bitnami/repositories/your_repo". Edit the "/opt/bitnami/repositories/your_repo/hooks/post-commit.tmpl" file and replace the last line with the following one: /opt/bitnami/python/bin/python /opt/bitnami/subversion/hooks/mailer/mailer.py commit "$REPOS" "$REV" /opt/bitnami/subversion/hooks/mailer/mailer.conf  If you don't find any python folder under /opt/bitnami/ you could use the python of your system (/usr/bin/python). In order to enable post-commits you only have to rename the post-commit script to remove the "tmpl" extension: sudo mv /opt/bitnami/repositories/your_repo/hooks/post-commit.tmpl /opt/bitnami/repositories/your_repo/hooks/post-commit Then try to do a change in any file and commit the changes. If there is any error you can see after the commit: $ svn commit -m "test" README.txt
Transmitting file data .
Committed revision 742.

#### How to configure the repository URL?

If you do not set the prefix in the Subversion scripts, you should specify the full path to the repository, for instance svn://YOUR_IP/home/user/repository. If you do not want to specify the full path of the repository, you should add the repository path option in the following scripts:

On Windows: "installdir/subversion/scripts/serviceinstall.bat"

-d --listen-port=3690 --root "C:\path\to\repository"


Then run the script to apply the changes: "serviceinstall.bat UNINSTALL" and "serviceinstall.bat INSTALL" from a command prompt as Administrator.

On Linux and OS X: "installdir/subversion/scripts/ctl.sh"

-d --listen-port=3690 --root=/path/to/repository


Then restart the Subversion server.