Tuesday, March 5, 2013

Set up my svn server for svnsync purpose


OS = RHEL/CentOS/Fedora

1. Install LAMP or at least httpd and php

yum install httpd php php-common

yum install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

start apache:

Start apache server:

/etc/init.d/httpd start ## use restart after update
## OR ##
service httpd start ## use restart after update
chkconfig --levels 235 httpd on


Add following content to /var/www/html/test.php file to test php

<?php
 
    phpinfo();
 
?>



2. then install svn:

yum install mod_dav_svn subversion

Add following config to /etc/httpd/conf.d/subversion.conf file:

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
 
<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   Require valid-user
</Location>


Add subversion users:
## Create testuser ##
htpasswd -cm /etc/svn-auth-users testuser
New password: 
Re-type new password: 
Adding password for user testuser
 
## Create testuser2 ##
htpasswd -m /etc/svn-auth-users testuser2
New password: 
Re-type new password: 
Adding password for user testuser2




Create and configure SVN repository

mkdir /var/www/svn
cd /var/www/svn
 
svnadmin create testrepo
chown -R apache.apache testrepo
 
chcon -R -t httpd_sys_content_t /var/www/svn/testrepo
 
## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo

Restart Apache:

/etc/init.d/httpd restart
## OR ##
service httpd restart
Goto http://localhost/svn/testrepo address and you should see something like following, write username and password:
SVN Subversion username and password
SVN testrepo revision 0:
SVN Subversion Repository Revision 0

6. Configure repository

To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:
## Disable anonymous access ##
anon-access = none
 
## Enable access control ##
authz-db = authz

7. Create trunkbranches and tags structure under testrepo

Create “template” directories with following command:
mkdir -p /tmp/svn-structure-template/{trunk,branches,tags}
Then import template to project repository using “svn import” command:
svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Adding         /tmp/svn-structure-template/trunk
Adding         /tmp/svn-structure-template/branches
Adding         /tmp/svn-structure-template/tags
 
Committed revision 1.
Check results on browser and see testrepo revision 1:



SVN Subversion Repository Revision 1








svnadmin create /var/www/svn/iphone-mirror

chown -R apache.labtools /var/www/svn/iphone-mirror

vi /var/www/svn/iphone-mirror/hooks/pre-revprop-change


#!/bin/sh
USER="$3"
if [ "$USER" = "user-who-is-allowed-to-do-the svnsync" ]; then exit 0; fi
echo "Only the svnsync user can change revprops" >&2
exit 1


chmod 755 /var/www/svn/iphone-mirror/hooks/pre-revprop-change

svnsync init --username cccc file:///var/www/svn/iphone-mirror svn://xx.xx.xx.121:3692/

svnsync sync --username cccc file:///var/www/svn/iphone-mirror




------------------------------------------------------------------------------------------
more URL's

http://svn.apache.org/repos/asf/subversion/trunk/notes/svnsync.txt
http://josephscott.org/archives/2010/01/setting-up-svnsync-and-svn-notify/
http://www.kirkdesigns.co.uk/mirror-svn-repository-svnsync
https://blogs.oracle.com/ashamash/entry/using_svnsync_to_migrate_an
http://blogs.collab.net/subversion/mirroring-repos


Schedule a cron job to run the sync periodically, say once every hour (on a nice odd number like 17 after the hour): 17 * * * * /usr/local/bin/svnsync --non-interactive sync file:///home/svn/repo-name












No comments:

Post a Comment