|
本文实例为大家分享了CentOS6.9快速安装配置svn的具体代码,供大家参考,具体内容如下
环境介绍:
操作系统:CentOS release 6.9 (Final)
192.168.65.130 (svn服务器)
192.168.65.129 (svn客户端)
一、svn安装检查(在两台上都执行)
?
|
1
2
3
4
5
|
if [ ! -f /usr/bin/svn ]; then
yum -y install subversion >/dev/null
echo "svn has been installed." >/dev/null
/usr/bin/svn --version|head -1|awk -F" " '{print $3}'
fi
|
二、创建版本库文件夹(仅在130上操作)
?
|
1
2
3
4
|
mkdir -p /data/svn/sinsvn
svnadmin create /data/svn/sinsvn
mkdir -p /data/www/sinsvn
|
三、主要操作
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
svn import /data/www/sinsvn/ file:///data/svn/sinsvn -m "svn first test"
svn list --verbose file:///data/svn/sinsvn
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
cat >/data/svn/passwd <<"EOF"
[users]
harry = harry
sin = sin
EOF
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
svnserve -d -r /data/svn/
ps -ef|grep svnserve|grep -v 'grep'
netstat -anltp|grep 3690
|
四、测试
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
mkdir -p /data/www
cd /data/www/
svn co svn://192.168.65.130/sinsvn --username=harry --password=harry
cd sinsvn/
mkdir branches
mkdir tags
mkdir trunk
svn add branches trunk tags
svn ci -m 'create branches trunk tags dir'
cd trunk
touch index.php
mkdir class
touch class/conn.php
svn add index.php
svn add class/
......
svn ci -m 'test file'
svn delete index.php class class/ index.php
svn ci -m 'delete files'
mkdir webgame
svn add webgame/
svn ci -m 'add webgame dir'
cd webgame
cp /tmp/VMwareTools-10.2.0-7259539.tar.gz .
cp /tmp/yum.log .
svn add *
svn ci -m 'add VMwareTools yum.log for test'
mkdir -p /data/webdir
cd /data/webdir
svn co svn://192.168.65.130/sinsvn/trunk/webgame --username=harry --password=harry
cd /data/webdir/webgame/
svn update
ll
|
五、脚本定制更新
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
cat >/root/svnauto_update.sh<<"EOF"
cd /data/webdir/webgame/
svn update &>>/tmp/svnauto_update.log
EOF
chmod +x /root/svnauto_update.sh
chmod +x /etc/crontab
/etc/init.d/crond restart
cat >>/var/spool/cron/root<<"EOF"
* 09-23 * * * /bin/sh /root/svnauto_update.sh
EOF
find /data/svn/sinsvn/ -name hooks
cat >/data/svn/sinsvn/hooks/post-commit<<"EOF"
REPOS="$1"
REV="$2"
export LANG=zh_CN.UTF-8
echo "Code Deployed at "$1" Committed revision "$2" ; `date "+%Y-%m-%d %H:%M:%S"`" >> /tmp/post-commit.log
/usr/bin/svn update --username harry --password harry /data/webdir/webgame >> /tmp/post-commit.log
EOF
chmod +x /data/svn/sinsvn/hooks/post-commit
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://www.cnblogs.com/bjx2020/p/8727641.html |