#!/bin/bash ############################### # Author: Neo<openunix@163.com # Home: http://netkiller.sf.net ############################### SVNROOT=/srv/svnroot/project adduser(){ echo $1 $2 if [ -z $1 ]; then usage else local user=$1 fi if [ -z $2 ]; then usage else local passwd=$2 fi echo "$1 = $2" >> $SVNROOT/conf/passwd } deluser(){ local user=$1 if [ -z $user ]; then usage else ed -s $SVNROOT/conf/passwd <<EOF /$user/ d wq EOF fi } list(){ cat $SVNROOT/conf/passwd } usage(){ echo $"Usage: $0 {list|add|del} username" } case "$1" in list) list ;; add) adduser $2 $3 ;; del) deluser $2 ;; restart) stop start ;; condrestart) condrestart ;; *) usage exit 1 esac
用法
./svnuser list ./svnuser add user passwd ./svnuser del user
$ svnadmin create /home/svnroot/project
$ svnserve --daemon --root /home/svnroot/project
[groups] member = neo blog = neo,netkiller wiki = bg7nyt,chen,jingfeng [/] * = [/member] @member = rw * = r [/app/blog] @blog = rw * = [/app/wiki] @blog = rw * = # [repository:/baz/fuz] # @harry_and_sally = rw # * = r
$ svnadmin create /home/svnroot/project1
$ svnadmin create /home/svnroot/project2
$ svnserve --daemon --root /home/svnroot
[groups] member = neo blog = neo,netkiller wiki = bg7nyt,chen,jingfeng [project1:/] * = [project2:/] * = r [project1:/member] @member = rw * = r [project2:/app/blog] @blog = rw * = [project2:/app/wiki] @blog = rw * = r
例 6.1. authz
[aliases] # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average ### 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] manager = neo developer = jam,john,zen tester = eva designer = allan deployer = ken [/] @manager = rw @developer = r @designer = r @deployer = r @tester = r * = ############################# # Trunk # ########################## [/www.mydomain.com/trunk] @manager = rw @designer = rw @developer = rw @deployer = r [/images.mydomain.com/trunk] @designer = rw [/myid.mydomain.com/trunk] @designer = r [/info.mydomain.com/trunk] @developer = r @designer = r ############################# #\Branches ############################# [/admin.mydomain.com/branches] @developer = rw @designer = rw [/myid.mydomain.com/branches] @developer = rw @designer = rw [/info.mydomain.com/branches] @developer = rw @designer = rw [/www.mydomain.com/branches] @developer = rw @designer = rw [/images.mydomain.com/branches] @developer = rw @designer = rw [/log.mydomain.com/branches] @developer = rw [/report.mydomain.com/branches] @developer = rw ############################### # TAGS # ############################# [/myid.mydomain.com/tags] @deployer = rw [/admin.mydomain.com/tags] @deployer = rw [/info.mydomain.com/tags] @deployer = rw
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。