Description
Server operating system: CentOS
Server ip:192.168.21.134
SVN installation path:/USR/LOCAL/SVN
SVN project path:/HOME/SVN
SVN login account: Osyunwei
SVN login Password: 123456
Web site root directory:/home/web
to achieve the purpose:
When any updates are modified in the SVN project, the system automatically checks out the files from SVN and synchronizes to the Web site root directory
Specific actions:
First, use SVN post-commit implementation to automatically check out the files from SVN and sync to the Web site root directory
Cd/home/svn/hooks
VI post-commit #编辑, add the following code
#!/bin/sh
repos= "$"
rev= "$"
svn_path=/usr/local/svn/bin
web_path=/home/web
svn_user= Osyunwei
svn_pass=123456
web_user=www
log_path=/tmp/svn.log
echo ' date ' +%y-%m-%d%h:%m:%s ' >> $LOG _path
echo ' WhoAmI ', $REPOS, $REV >> $LOG _path
$SVN _path/svn update $WEB _path--username $ Svn_user--password $SVN _pass--no-auth-cache >> $LOG _path chown
$WEB _user. $WEB _user-r $WEB _path
: wq! #保存退出
Chown www:www/home/svn/hooks/post-commit #设置脚本所属用户组, www run accounts and groups for Web services
chmod +x/home/svn/hooks/post-commit #添加脚本执行权限
Description
WhoAmI #执行此程序的用户
Repos= "$" #svn项目绝对路径值
rev= "$" #最新版本号
--no-auth-cache #不保存账户认证信息
Second, the client testing
After you use the SVN client to add a file, the Web page is displayed in real time! As shown in the following illustration:
At this point, the SVN server under Linux automatically updates files to the Web directory tutorial complete.