centos7 脚本搭建SVN

#!/usr/bin/env bash
#安装软件 HTTP 和 SVN软件
yum install -y httpd subversion mod_dav_svn
#创建库文件夹并更改文件夹权限
mkdir /home/svn
chown -R apache:apache /home/svn
svnadmin create /home/svn
chmod -R g+rws /home/svn
#修改SVN配置文件
cat > /etc/httpd/conf.modules.d/10-subversion.conf << EOF
LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
LoadModule dontdothat_module  modules/mod_dontdothat.so
<Location /svn>
DAV svn
SVNPath /home/svn
AuthType Basic
AuthName "SVN repository"
AuthUserFile /etc/subversion/passwd 
AuthzSVNAccessFile /home/svn/conf/authz
Require valid-user
</Location>
EOF
#启动HTTP服务
systemctl enable httpd
systemctl start httpd
#创建用户,设置库文件的用户权限
echo "admin = jason" >> /home/svn/conf/authz
echo "[/]" >> /home/svn/conf/authz
echo "@admin = rw" >> /home/svn/conf/authz
echo "*=" >> /home/svn/conf/authz
htpasswd -c /etc/subversion/passwd jason
chown -R apache:apache /home/svn

#关闭防火墙和selinux,selinux必须关闭,防火墙不关闭的话打开防火墙的80和3690端口
#运行脚本:  sh  -x  svn.sh

添加账户:  htpasswd -m /etc/subversion/passwd  monday   

账户权限:

cd  /home/svn/conf
[root@jason conf]# cat authz |grep -Ev '^%|^$'
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').
[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
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
admin = jason,test,monday,aimee
users =luffy
[/]
@admin = rw              #读写
@users=r                 #读
*= #其他用户无权限

[/test]
@users = r

重启httpd服务

客户端

TortoiseSVN-1.9.7.27907-x64-svn-1.9.7

SVN地址:http://192.168.199.224/svn/

http://192.168.199.224/svn/test

 

原文地址:https://www.cnblogs.com/xiaoyou2018/p/10007653.html