Local SVN

Step 1: Installation of Packages.
The Two packages needed for svn is as below

#yum install -y subversion mod_dav_svn
* httpd package needs to be installed.

Step 2: Create and configure Subversion Repository.
The steps that I am going to follow are as follows.
1. Create subversion directory under /usr/local/ and change the owner and group as apache.apache.

#mkdir /usr/local/subversion
#chown –R apache.apache subversion/  #subversion and inside all the directories will have                                                                apache.apache ownership

Here the subversion folder will contain all the repository that we are going to create now and in future.

2. Create repository by using svnadmin command as follows.

#svnadmin create myproject1
* Here my repository name is myproject1

3. Touch svnupload.sh file and add following lines and save.
#vim svnupload.sh   
       
#!/bin/bash
home_dir=/usr/local/subversion/myproject1/
svnlook changed /usr/local/subversion/myproject1 >> /usr/local/subversion/myproject1/test.txt
cat /usr/local/subversion/myproject1/test.txt| sed 's/^[A-Z]//g'| sed 's/^  //g' >> /usr/local/subversion/myproject1/upload.txt
for i in `cat /usr/local/subversion/myproject1/upload.txt`;do svn export --username "svn" --password "svn123" --no-auth-cache http://localhost/myproject1/$i /var/www/html/$i --force;done
for i in `cat /usr/local/subversion/myproject1/upload.txt`;do chown -R apache:apache /var/www/html/$i ;done
for i in `cat /usr/local/subversion/myproject1/upload.txt`;do chmod -R 775 /var/www/html/$i ;done
cat /usr/local/subversion/myproject1/test.txt |grep D | sed 's/^[A-Z]//g'| sed 's/^  //g' >> /usr/local/subversion/myproject1/delete.txt
for i in `cat /usr/local/subversion/myproject1/delete.txt`;do /bin/rm –rf /var/www/html/$i ;done
> /usr/local/subversion/myproject1/test.txt
> /usr/local/subversion/myproject1/upload.txt
> /usr/local/subversion/myproject1/delete.txt

 # chmod +x svnupload.sh           #give this file a execute permission   

4. Go to the hooks directory under repository.

#cd /usr/local/subversion/myproject1
#cd hooks
#cp post-commit.tmpl post-commit --- copy post-commit.tmpl as post-commit
#vim post-commit --- open post-commit file

#REPOS="$1"                                                                 #comment this line
#REV="$2"                                                                    #comment this line
#mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf     #comment this line
/bin/sh /usr/local/subversion/myproject1/svnupload.sh        #add this line

#chmod –R 775 hooks/                  #give hooks directory and sub-files 775 permission

Step 3: Configuring subversion.

#cd /etc/httpd/conf.d/
#vim svn.conf --- touch new file say svn.conf and add following line.

<Location /myproject1>
DAV svn
SVNPath /usr/local/subversion/myproject1
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile /etc/httpd/conf.d/.htpasswd
Require valid-user
</Location>

Now create user for subversion say test1

#htpasswd –cm /etc/httpd/conf.d/.htpasswd test1

Now restart Apache service.

Take checkout of the repository on your local machine and try to upload code through local svn.

http://<server-ip-address>/myproject1


For More Details Refer Link What is SVN? && How does SVN work?

No comments:

Post a Comment