вот главный:
- Код: Выделить всё
#!/bin/bash
# SYS REQ:
# realpath, uuencode
# get users
# example:
# "vooon/535
# digit/19
# сергей/34"
if [ -n "$1" ]; then
names="$1"
else
echo "Nothing to do"
exit 0
fi
# get basepath
if [ -n "$2" ]; then
cd "$2" || { echo "Error1"; exit 1; }
basepath=`realpath ./`
else
basepath=`realpath ./`
fi
cd "${basepath}/byid" || {
echo "creating ${basepath}/byid"
mkdir "${basepath}/byid"
}
cd "${basepath}"
userpasswds="./pwds.log"
for nameid in $names; do
name=`echo ${nameid} | cut -d"/" -f 1`
id=`echo ${nameid} | cut -d"/" -f 2`
repobase="${basepath}/${name}"
mkdir ${repobase} && {
pub="${repobase}/public"
priv="${repobase}/private"
# keygen :)
pass=`head -c 8 /dev/random | uuencode -m - | tail -n 2 | head -n 1`
echo "creating repositories for ${name}"
ln -s ${repobase} "${basepath}/byid/${id}"
mkdir "${pub}"
mkdir "${priv}"
svnadmin create "${pub}"
svnadmin create "${priv}"
rm "${pub}/conf/authz"
rm "${pub}/conf/passwd"
ln -s "${priv}/conf/authz" "${pub}/conf/authz"
ln -s "${priv}/conf/passwd" "${pub}/conf/passwd"
echo "repositories created, configuring"
# authz file
echo "[groups]
user = ${name}
[/]
@user = rw
* = r
" > "${priv}/conf/authz"
# passwd file
echo "[users]
${name} = ${pass}
" > "${priv}/conf/passwd"
# svnserve.conf files
# public
echo "[general]
anon-access = read
auth-access = write
password-db = passwd
authz-db = authz
realm = ${name} public repo
" > "${pub}/conf/svnserve.conf"
# private
echo "[general]
anon-access = none
auth-access = write
password-db = passwd
authz-db = authz
realm = ${name} private repo
" > "${priv}/conf/svnserve.conf"
echo "`date` - ${name} = ${pass}" >> $userpasswds
echo "configuried successful. password for ${name}: ${pass}"
}
done
### run svnserve
### urls:
# svn://<host>/<username>/public
# svn://<host>/<username>/private
# svn://<host>/byid/<userid>/public
# svn://<host>/byid/<userid>/private
#svnserve -d -r "${basepath}"
### open svn://host:3690
### TODO: нужно написать комманды чтобы открыть порт
# $ grep ^svn /etc/services
# svn 3690/tcp subversion # Subversion protocol
# svn 3690/udp subversion
# закончили успешно
exit 0
может можно его сделать лучше?