安装方法
1wget -c http://mrasong.com/attachment/2012/05/subversion-1.6.18.sh && chmod +x subversion-1.6.18.sh && ./subversion-1.6.18.sh
使用方法
1/etc/init.d/subversion {start|stop|restart|reload}
修改配置
/home/data/svn/main/conf/svnserve.conf
1[general]
2### 匿名访问
3anon-access = none
4# auth-access = write
5
6### 用户文件
7password-db = passwd
8
9### 权限文件
10authz-db = authz
11
12### svn 名称
13realm = MY SVN
14
15[sasl]
16### 这些可以默认
17# use-sasl = true
18# min-encryption = 0
19# max-encryption = 256
添加用户
/home/data/svn/conf/passwd
1[users]
2### 用户名 = 密码
3zhangsan = password
4lisi = password2
5### .....
设置权限
/home/data/svn/conf/authz
1[aliases]
2# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
3
4[groups]
5# harry_and_sally = harry,sally
6# harry_sally_and_joe = harry,sally,&joe
7
8[/]
9### 根目录下 zhangsan 可读写, lisi 只读
10zhangsan = rw
11lisi = r
12
13# [/foo/bar]
14# harry = rw
15
16### 别名用户 joe
17# &joe = r
18
19### 所有用户
20# * =
21
22# [repository:/baz/fuz]
23### 用户组
24# @harry_and_sally = rw
25# * = r
源码
1#!/bin/bash
2PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
3export PATH
4
5SVN_PATH=/usr/local/subversion
6SVN_DATA=/home/data/svn
7SVNSERVE=/etc/init.d/subversion
8# Check if user is root
9if [ $(id -u) != "0" ]; then
10 echo "Error: You must be root to run this script!"
11 exit 1
12fi
13
14clear
15printf "=======================================================================\n"
16printf "Install Subversion-1.6.18 Written by MrAsong \n"
17printf "=======================================================================\n"
18printf "Author: MrAsong \n"
19printf "Email: i@mrsaong.com \n"
20printf "Home: http://mrasong.com/ \n"
21printf "Version: 2012-05-25 \n"
22printf "\n"
23printf "=======================================================================\n"
24cur_dir=$(pwd)
25
26 get_char()
27 {
28 SAVEDSTTY=`stty -g`
29 stty -echo
30 stty cbreak
31 dd if=/dev/tty bs=1 count=1 2> /dev/null
32 stty -raw
33 stty echo
34 stty $SAVEDSTTY
35 }
36 echo ""
37 echo "Press any key to start install Subversion..."
38 char=`get_char`
39
40printf "=========================== install Subversion ======================\n"
41
42wget -c http://subversion.tigris.org/downloads/subversion-1.6.18.tar.gz
43wget -c http://subversion.tigris.org/downloads/subversion-deps-1.6.18.tar.gz
44
45tar zxvf subversion-1.6.18.tar.gz
46tar zxvf subversion-deps-1.6.18.tar.gz
47cd subversion-1.6.18
48
49./configure --prefix=$SVN_PATH --without-berkeley-db
50make && make install
51
52rm -f $SVNSERVE
53
54cat >$SVNSERVE<<eof
55#! /bin/bash
56# chkconfig: 2345 99 99
57# Subversion: Subversion Daemon
58# Description: Startup script for subversion on Debian. Place in /etc/init.d and
59# run 'update-rc.d -f subversion defaults', or use the appropriate command on your
60# distro. For CentOS/Redhat run: 'chkconfig --add subversion'
61
62SVNPATH=$SVN_DATA
63SVN=$SVN_PATH/bin/svnserve
64
65RETVAL=0
66prog="Subversion By MRASONG"
67
68start () {
69 echo -n \$"Starting \$prog: "
70 \$SVN -d -r \$SVNPATH
71 RETVAL=\$?
72 echo
73 [ \$RETVAL -eq 0 ]
74}
75stop () {
76 echo -n \$"Stopping \$prog: "
77 killall \$SVN
78 RETVAL=\$?
79 echo
80 [ \$RETVAL -eq 0 ]
81}
82
83restart () {
84 stop
85 start
86}
87
88
89# See how we were called.
90case "\$1" in
91 start)
92 start
93 ;;
94 stop)
95 stop
96 ;;
97 restart|reload)
98 restart
99 ;;
100 *)
101 echo \$"Usage: \$0 {start|stop|restart|reload}"
102 exit 1
103esac
104
105exit \$?
106
107eof
108chmod +x $SVNSERVE
109
110mkdir -p $SVN_DATA
111$SVN_PATH/bin/svnadmin create $SVN_DATA/main #create main project
112
113
114if [ -s /etc/debian_version ]; then
115update-rc.d -f subversion defaults
116elif [ -s /etc/redhat-release ]; then
117chkconfig --level 345 subversion on
118fi
119
120#Starting Subversion...
121$SVNSERVE start
122
123printf "===================== install Subversion completed =====================\n"
124printf "Install Subversion completed,enjoy it!\n"
125printf "For more information please visit http://mrasong.com/a/subversion \n"
126printf "=======================================================================\n"