您的位置:首页 > 运维架构 > Shell

SVN 多项目配置 (shell 一键配置)

2015-11-11 15:17 435 查看

SVN仓库配置

在SVN仓库目录中新建一个配置文件夹Config

mkdir ./Config


里面可以复制利用下面命令创建的仓库配置

svnadmin create repository
cp ./repository/conf/authz ./Config/authz
cp ./repository/conf/passwd ./Config/passwd
cp ./repository/conf/svnserve.conf ./Config/svnserve.conf


操作结果



然后对这三个文件进行配置

这里我先配置一个叫repository的svn仓库例子

authz文件配置如下:

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe

[repository:/]
repository = rw


passwd文件配置如下:

[users]
repository = 123456


svnserve.conf文件配置如下:

[general]
anon-access = none
auth-access = write
### 两行代码要注意看路径,你们的svn仓库也许不是/home/svnService
password-db = /home/svnService/Config/passwd
authz-db    = /home/svnService/Config/authz
# groups-db = groups
realm = example
# force-username-case = none
# hooks-env = hooks-env

[sasl]
# use-sasl = true
# min-encryption = 0
# max-encryption = 256


到这一步可以把Config中的svnserve.conf文件复制回./repository/conf文件夹里面

然后把realm = example 改成 realm = repository

在命令行运行svnserve -d -r /home/svnService即可完成一个版本库的配置

在客户端可以使用tortoisesvn进行checkout操作了,输入用户repository和密码123456 就能checkout完成



但我的目的不是到这步结束,把上面说的authz、passwd 和svnserve.conf是有目的性的

authz 文件对SVN仓库的所有权限和访问路径进行配置

passwd 文件对所有SVN仓库的密码进行设置

svnserve.conf 这个文件只是一个模板,供新增的仓库使用

svn一键创建仓库脚本

编辑一个sh文件,放到版本库的根目录,文件名为setup.sh

#!/bin/bash

echo -n "Please input the svn repository name:"
read name
echo -n "Please input the svn username:"
read user
echo -n "Please input the svn password:"
read password

if [ -d $name ]
then
echo "Directory is exist!"
else
svnadmin create $name
rm -rf ./${name}/conf/*
cp ./Config/svnserve.conf ./${name}/conf/
sed -i "s/realm = example/realm = ${name}/" ./${name}/conf/svnserve.conf
echo "${user} = ${password}" >> ./Config/passwd
echo -e "[${name}:/]\n${user} = rw" >> ./Config/authz
killall svnserve
# 这里的svn仓库要改成你自己的svn仓库绝对路径
svnserve -d -r /home/svnService
fi


使用:

# bash ./setup.sh
Please input the svn repository name:kkk
Please input the svn repository username:ddd
Please input the svn repository password:123456


版本创建好了,直接在客户机上checkout即可(注意输入对应的用户密码,不能搞混了)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: