CentOS6.9下svn快速安装配置方法
本文实例为大家分享了CentOS6.9快速安装配置svn的具体代码,供大家参考,具体内容如下
环境介绍:
操作系统:CentOSrelease6.9(Final)
192.168.65.130(svn服务器)
192.168.65.129(svn客户端)
一、svn安装检查(在两台上都执行)
if[!-f/usr/bin/svn];then yum-yinstallsubversion>/dev/null echo"svnhasbeeninstalled.">/dev/null /usr/bin/svn--version|head-1|awk-F""'{print$3}' fi
二、创建版本库文件夹(仅在130上操作)
mkdir-p/data/svn/sinsvn #创建版本库 svnadmincreate/data/svn/sinsvn mkdir-p/data/www/sinsvn
三、主要操作
#导入所需管理的项目到版本库repository中 svnimport/data/www/sinsvn/file:///data/svn/sinsvn-m"svnfirsttest" #检查是否导入成功 svnlist--verbosefile:///data/svn/sinsvn #修改版本库的配置文件 #vim/data/svn/sinsvn/conf/svnserve.conf cat>/data/svn/sinsvn/conf/svnserve.conf<<"EOF" [general] anon-access=none auth-access=write password-db=/data/svn/passwd authz-db=/data/svn/authz realm=sinsvn EOF cp/data/svn/sinsvn/conf/passwd/data/svn cp/data/svn/sinsvn/conf/authz/data/svn #修改允许访问版本库的用户文件 #vim/data/svn/passwd cat>/data/svn/passwd<<"EOF" [users] harry=harry sin=sin EOF #vim/data/svn/authz cat>/data/svn/authz<<"EOF" [groups] myteam=harry,sin [/] harry=rw [sinsvn:/] @myteam=rw [secsvn:/www] @myteam=r sin=rw [sincms:/] sin=rw harry= EOF #启动svn服务 svnserve-d-r/data/svn/ #查看 ps-ef|grepsvnserve|grep-v'grep' netstat-anltp|grep3690
四、测试
#测试,在另外一台机器上操作(129),目的是效果更为明显些 #1、mkdir-p/data/www mkdir-p/data/www cd/data/www/ #2、svnco代码 svncosvn://192.168.65.130/sinsvn--username=harry--password=harry #3、添加branches,tags,trunk目录 cdsinsvn/ mkdirbranches mkdirtags mkdirtrunk svnaddbranchestrunktags svnci-m'createbranchestrunktagsdir' #4、在trunk中添加测试文件,并提交到版本库 cdtrunk touchindex.php mkdirclass touchclass/conn.php svnaddindex.php svnaddclass/ ...... svnci-m'testfile' svndeleteindex.phpclassclass/index.php svnci-m'deletefiles' mkdirwebgame svnaddwebgame/ svnci-m'addwebgamedir' #追加操作 cdwebgame cp/tmp/VMwareTools-10.2.0-7259539.tar.gz. cp/tmp/yum.log. svnadd* svnci-m'addVMwareToolsyum.logfortest' ###############这里假设130的机器上有个web项目 mkdir-p/data/webdir cd/data/webdir svncosvn://192.168.65.130/sinsvn/trunk/webgame--username=harry--password=harry #追加操作 cd/data/webdir/webgame/ svnupdate ll#可以查看到更新后的结果
五、脚本定制更新
#定时更新脚本(针对整个目录自动更新的脚本,被动模式) cat>/root/svnauto_update.sh<<"EOF" cd/data/webdir/webgame/ svnupdate&>>/tmp/svnauto_update.log EOF chmod+x/root/svnauto_update.sh chmod+x/etc/crontab /etc/init.d/crondrestart #添加至crontab计划任务中 cat>>/var/spool/cron/root<<"EOF" #svnauto_update.sh *09-23***/bin/sh/root/svnauto_update.sh EOF #自动更新脚本(针对版本号触发式更新) #svn目录:/data/svn/sinsvn #站点目录:/data/webdir/webgame #实现: #1.找到svn项目的hooks目录,这里是/data/svn/sinsvn/hooks。目录中默认会几个对应操作的钩子模板,我们需要创建一个post-commit的文件。 find/data/svn/sinsvn/-namehooks #2.新建post-commit,内容如下 cat>/data/svn/sinsvn/hooks/post-commit<<"EOF" #!/bin/bash REPOS="$1" REV="$2" exportLANG=zh_CN.UTF-8 echo"CodeDeployedat"$1"Committedrevision"$2";`date"+%Y-%m-%d%H:%M:%S"`">>/tmp/post-commit.log /usr/bin/svnupdate--usernameharry--passwordharry/data/webdir/webgame>>/tmp/post-commit.log EOF chmod+x/data/svn/sinsvn/hooks/post-commit
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。