本文最后更新于 2023年9月8日 下午
0. 准备工作
1 2 3 4 5 6 7 8 9
| user add -m svn
su svn mkdir /home/svn/svn_repos/ mkdir /home/svn/log touch /home/svn/log/svn.log mkdir /home/svn/svn_users.conf cd /home/svn/svn_repos/
|
1. 创建仓库
1 2
| svnadmin create test1 svnadmin create test2
|
2. 修改仓库配置
1 2 3 4 5 6 7
| [general] anon-access = none auth-access = write password-db = /home/svn/svn_users.conf/passwd authz-db = /home/svn/svn_users.conf/authz realm = test1
|
1 2 3 4 5 6 7
| [general] anon-access = none auth-access = write password-db = /home/svn/svn_users.conf/passwd authz-db = /home/svn/svn_users.conf/authz realm = test2
|
修改完 svnserve.conf
后必须重启 svn
服务,修改下面两个文件无需重启 svn 服务
3. 创建仓库间公用的认证文件
1 2 3 4 5
| [users] admin = admin user1 = user1 user2 = user2
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| [groups] Admin = admin,user1 Dev = user1,user2
[test1:/] @Admin = rw @Dev = rw * =
[test2:/] @Admin = rw @Dev = r * =
|
4. 设定开机自启
创建/修改 /etc/systemd/system/svn.service
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| [Unit] Description=Subversion Server After = network.target syslog.target Wants = network.target
[Service] User=svn Group=svn Type=forking ExecStart=/usr/bin/svnserve --daemon --log-file /home/svn/log/svn.log --root /home/svn/svn_repos ExecStop=/usr/bin/killall svnserve Restart=always
[Install] WantedBy=default.target
|
然后
1 2 3 4 5
| mkdir /home/svn/log/ touch /home/svn/log/svn.log systemctl daemon-reload systemctl start svn systemctl enable svn
|
5. 测试
1 2 3
| svn co svn://localhost/test1 test1 --username admin --password admin svn add path/to/file svn ci -m 'xxxxx' --username admin --password admin
|
The end...