SVN

From Blue-IT.org Wiki

Revision as of 17:24, 17 January 2012 by Apos (talk | contribs)

svn+ssh and https together

  • Already running an ssh server?
  • Already have a user with ssh account (that's necessary)

Add the user you want to add to the subversion group:

adduser username subversion
(or later remove with: deluser username subversion)

Alter permissions of the repository "users_repository"

cd /home/svn
chown -R www-data:subversion users_repository
find users_repository/. -type d -name "*" -exec chmod -R g+rws {} \;
find users_repository/. -type f -name "*" -exec chmod -R g+rw {} \;

That's it.

Now you can connect e.g.:

svn checkout svn+ssh://username@SERVER_IP/home/svn/users_repository

Attention: In your checked out repository you have to switch the svn access url from http to svn+ssh!

svn switch --relocate http://domain.com/{repo} svn+ssh://{username}@domain.com/home/{username}/svn/{repo}

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