8,测试服务器 # svn co svn://192.168.60.10/project Authentication realm: 92731041-2dae-4c23-97fd-9e1ed7f0d18d Password for 'root': Authentication realm: 92731041-2dae-4c23-97fd-9e1ed7f0d18d Username: server_group Password for 'server_group': svn: Authorization failed ( server_group没用根目录的访问权 )
# svn co svn://192.168.60.10/project Authentication realm: 92731041-2dae-4c23-97fd-9e1ed7f0d18d Password for 'root': Authentication realm: 92731041-2dae-4c23-97fd-9e1ed7f0d18d Username: pm Password for 'pm': A project/test A project/server A project/client Checked out revision 1. ( 测试提取成功 )
# cd project/server # vim main.c # svn add main.c # svn commit main.c -m "测试一下我的C程序,看什么看,不行啊??" Adding main.c Transmitting file data . Committed revision 2. ( 测试提交成功 )
三,配置SVN服务器的HTTP支持 1,转换SVN服务器的密码 由于SVN服务器的密码是明文的,HTTP服务器不与支持,所以需要转换成HTTP支持的格式。我写了一个Perl脚本完成这个工作. 脚本内容如下: # cd /home/svn/project/conf/ # cat PtoWP.pl #!/usr/bin/perl # write by huabo, 2009-11-20 use warnings; use strict; #open the svn passwd file open (FILE, "passwd") or die ("Cannot open the passwd file!!!\n"); #clear the apache passwd file open (OUT_FILE, ">webpasswd") or die ("Cannot open the webpasswd file!!!\n"); close (OUT_FILE); #begin foreach () { if($_ =~ m/^[^#].*=/) { $_ =~ s/=//; `htpasswd -b webpasswd $_`; } }
# ./PtoWP.pl ( 先给该脚本加可执行权限,然后执行以转换密码 ) Adding password for user pm Adding password for user server_group Adding password for user client_group Adding password for user test_group 现在目录下会多一个webpasswd文件。
2,修改httpd.conf,添加关于SVN服务器的内容 编辑/etc/httpd/conf/httpd.conf,在最后添加如下信息: DAV svn SVNPath /home/svn/project/ AuthType Basic AuthName "svn for project" AuthUserFile /home/svn/project/conf/webpasswd AuthzSVNAccessFile /home/svn/project/conf/authz Satisfy all Require valid-user
3,启动HTTPD服务器 # service httpd restart Stopping httpd: [FAILED] Starting httpd: [ OK ]
4,用浏览器访问测试 测试结果如下图所示:
( 测试成功 )
四,配置邮件提醒支持 1,安装Perl模块Module::Build # wget # tar xvf Module-Build-0.36_11.tar.gz # cd Module-Build-0.36_11 # perl Build.PL # ./Build # ./Build test # ./Build install # cd ..
2,安装Perl模块Authen::SASL # wget # tar xvf Authen-SASL-2.15.tar.gz # cd Authen-SASL-2.15 # perl Makefile.PL # make test # make install # cd ..
3,安装Perl模块Net::SMTP_auth # wget # tar xvf Net-SMTP_auth-0.08.tar.gz # cd Net-SMTP_auth-0.08 # perl Makefile.PL # make test # make install # cd ..
4,安装Perl模块SVN::Notify # wget # tar xvf SVN-Notify-2.80.tar.gz # cd SVN-Notify-2.80 # perl Build.PL # ./Build # ./Build test # ./Build install # cd ..
5,启动邮件服务器 # service sendmail restart Shutting down sendmail: [FAILED] Starting sendmail: [ OK ] Starting sm-client: [ OK ]
五,其它常用配置 1,强制写log脚本 配置pre-commit文件,要求用户每次更新文件都必须写log. # cd /home/svn/project/hooks/ # vim pre-commit 文件内容如下: #!/bin/sh REPOS="$1" TXN="$2" SVNLOOK=/usr/bin/svnlook LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c` if [ "$LOGMSG" -lt 5(要求的log长度,依实际需要修改) ]; then echo -e "\nEmpty log message not allowed. Commit aborted!" 1>&2 exit 1 fi
配置完成后,给本件加上可执行权限。再提交代码时,就必须按要求写注释了,:)
2,可修改log脚本 配置pre-revprop-change文件,此文件在show log中修改log时会运行,得到修改的权限,否则会报错:DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent. At least one property change failed; repository is unchanged # cd /home/svn/project/hooks/ # vim pre-revprop-change 文件内容如下: REPOS="$1" REV="$2" USER="$3" PROPNAME="$4" if ["$PROPNAME" = "svn:log"];then exit 0;fi exit 1