SVN
From Blue-IT.org Wiki
Contents
SVN Integration with https
First of all your repository, e.g. /home/svn must be writable by the webserver:
MYREPO="/home/svn" chown -R www-data:www-data ${MYREPO} find ${MYREPO} -type d -exec chmod 2755 \{} \; find ${MYREPO} -not -type d -exec chmod 0644 \{} \;
Then you need mod_dav for apache2:
apt-get install libapache2-svn cd /etc/apache2/mods-available/ vim dav_svn.conf
To access an svn like https://serverip/svn/repo1 (adn read/write access for user1) https://serverip/svn/repo2 (and read/write access for user2)
/path/to/ └── svn ├── repo1 -> should only be rw-accessible by user1 └── repo2 -> should only be rw-accessible by user2
do the following 3 (4) steps:
First: create a dav configuration file
vim /etc/apache2/dav_svn.passwd
<Location /svn> DAV svn SVNParentPath /path/to/svn AuthType Basic AuthName "Subversion Repository" AuthUserFile /etc/apache2/dav_svn.passwd AuthzSVNAccessFile /etc/apache2/dav_svn.authz # Allow access only with authentification Require valid-user # Allow acces with anonymous checkout #<LimitExcept GET PROPFIND OPTIONS REPORT> # Require valid-user #</LimitExcept> </Location>
Second: set passwords for users:
htpasswd -c /etc/apache2/dav_svn.passwd user1
and for every one after that without “-c“ (because this in case will overwrite the file!!!)
htpasswd /etc/apache2/dav_svn.passwd user2
Third: create the authz file for authorization:
vim /etc/apache2/dav_svn.authz
## Groups or users #groupname = user1,user2 ## repositories #[reponame:/] ## read / write access for all users #* = rw ## nor read acces for this group #@groupname = ## read access for this user #user1 = r #[reponame:/trunk/] ## read / write access for user1 to /trunk/ #user1 = rw [repo1:/] user1 = rw [repo2:/] user2 = rw
Create a virtual host if you like:
SERVERIP="1.2.3.4" MAIL="webmaster@mydomain.com" DOMAIN="svn.example.com" DOCPATH="/var/www" SSLPATH="/var/webs/ssl" CUSTOMER="" CHAINFILE="/var/webs/ssl/CAcert_chain.pem" cat << EOF > ${DOMAIN}.conf <VirtualHost ${SERVERIP}:443> ServerAdmin webmaster@${DOMAIN} ServerName www.${DOMAIN} ServerAlias ${DOMAIN} DocumentRoot ${DOCPATH} <Directory ${DOCPATH}> Options -MultiViews allow from all </Directory> # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ErrorLog /var/log/apache2/error.log SSLEngine on SSLCertificateFile ${SSLPATH}/${CUSTOMER}/${DOMAIN}.cert SSLCertificateKeyFile ${SSLPATH}/${CUSTOMER}/${DOMAIN}.key SSLCertificateChainFile ${CHAINFILE} </VirtualHost> EOF
Restart Apache:
/etc/init.d/apache2 restart
svnsync
Taken from:
Create the following variables:
MYPATH="/home/svn" URL_TO_REPO_ROOT_TO_CLONE="https://axelpospischil@ssl.qwws.net/svn/mt_roadrunner" DEST_URL="/home/svn"
(Note: „DEST_URL“ is the url to the Subversion repository you create in step 1.)
1. Create your local repository:
svnadmin create ${MYPATH}
2. Create an empty pre-revprop-change hook script:
echo '#!/bin/bash' > ${MYPATH}/hooks/pre-revprop-change
3. Make the pre-revprop-change hook script executable:
chmod +x ${MYPATH}/hooks/pre-revprop-change
4. Initialize svnsync:
svnsync init file:⁄⁄⁄${MYPATH} ${URL_TO_REPO_ROOT_TO_CLONE}
5. Synchronize:
svnsync sync ${DEST_URL}
Subversion 1.6.x needs those added to the pre-revprop-change script:
REPOS="$1" REV="$2" USER="$3" PROPNAME="$4" ACTION="$5"
Einrichten unter Debian
1. Svn installieren:
apt-get update apt-get install subversion
2. Eine svn Gruppe erstellen und einen Benutzer hinzufügen:
groupadd subversion addgroup username subversion
3. Ein svn Repository erzeugen oder ein Vorhandenes kopieren
mkdir /home/svn/myrepo rsync -av oldserver:/home/svn /home/. chown -R root:subversion /home/svn svnadmin create --fs-type fsfs /home/svn/myrepo/projekt1 svnadmin create --fs-type fsfs /home/svn/myrepo/projekt2
4. Einloggen via ssh (geht nur, wenn ein ssh-Schlüssel im Userverzeichnis generiert wurde)
ssh+svn://servername/home/svn/myrepo