Environment Introduction:
Operating system: CentOS release 6.5 (Final) 64-bit
Network Environment: Intranet
1 ConfigurationSVN1.1 installationSvnComponent Packages
Install the package required for svn with Yum
# Yum–y Install Subversion
1.2 ConfigurationSVN1.2.1 CreateSvnLibrary Path
creates an SVN library path that provides user file writes and reads later in the directory.
# mkdir-p/date/svn/
1.2.2 CreateSvnVersion Library
use a specific command to create a repository that will appear after a successful creation SVN configuration file.
# svnadmin create/date/svn/
1.2.3 defining a configuration file
#vim/opt/svndata/repos1/conf/svnserve.conf
[general]anon-access = noneauth-access = Writepassword-db = passwd #定义用户密码的配置文件authz-db = Authz #定义用户权限的配置文件realm = SVN
1.2.4 User Rights Configuration
1. Create svn Access User
#vim/data/svn/passwd
[Users]test = Test Creates a user named Tset password as test
2. Configure User access rights
#vi/opt/svndata/repos1/conf/authz
[Groups]admin = test# harry_and_sally = harry,sally[/] @admin = rw[repos1:/abc/aaa] @admin = r
Repository directory format:
[< repository >:/ project / directory ] # is the first unit of the project name. Think of the project as a unit.
@< User group name > = < permissions >
< user name > = < permissions >
where the box number can be written in several ways :
/, which indicates the root directory and the following. The root directory is specified at Svnserve startup and we specify /opt/svndata. Thismeans that the permissions are set for all repositories.
repos1:/, which indicates that permissions are set on version Library 1
REPOS2:/ABC, which indicates that permissions are set on the ABC project in version Library 2
REPOS2:/ABC/AAA, which represents the AAA directory setting permissions on the ABC project in version 2
The permission principal can be a user group, user, or *, the user group is preceded by @,* represents all users. Permissions can be w,R,WR, and NULL, and NULL indicates no permissions.
1.2.5 StartSvn
# svnserve-d-r/date/svn/
-D means running in daemon (background run)
-R/DATE/SVN Specifies that the root directory is /date/svn
1.3 Configuring Hooks1.3.1 Configuring the Version Detection Tool
I used python to write a tool that automatically detects the file versions inside the library. The code is as follows:
# vim/date/svn/hooks/gouzi.py#!/usr/bin/env pythonif __name__== ' __main__ ': importsys,string try:logfile= open ('/t Mp/python.out ', ' A + ') logfile.write ("This is Python hook") Logfile.close () except:exit (1) sys.exit (0)
This tool needs to be placed in the hooks directory in the library directory .
1.3.2 ConfigurationUPDATEScript
1, first on the client manually checkout one time
# SVN Checkout Svn://192.168.21.28/repos
2. Edit the automatic synchronization script
# Vim Svn_update.sh
The code is as follows
#!/bin/bash/usr/bin/svn update/linshi/repos--username Test--password testif [$? = 0] then echo "OK" >&G T /tmp/z.outfi
Where:/linshi/ for the storage directory (depends on the environment)
--username Test User name is test
--password test password is test
3. Modify Permissions
# chmod +x/root/svn_update.sh
4. Configure Scheduled Tasks
The Configuration Schedule task settings are executed every minute because the script cannot be implemented automatically.
# crontab-e* * * */root/svn_update.sh >/dev/null 2>&1
-----------Xiao Huan Original
This article is from "Xiao Huan" blog, please be sure to keep this source http://x1aoxiao.blog.51cto.com/1836651/1655046
Linux CentOS under Configuration svn+svn hooks