您的位置:首页 > 其它

svn自动生成并简易配置repository和重启服务的脚本

2013-01-24 18:57 411 查看
svn的安装及配置:
http://blog.csdn.net/kangquan2008/article/details/8070391
svn自动生成并简易配置repository和重启服务的脚本:
========================脚本=========================
#!/bin/bash

conf=/conf/svnserve.conf
pw=/conf/passwd

changeConf(){
sed -i 's\# anon-access = read\anon-accss = none\g'  "$1"${conf}
sed -i 's\# auth-access = write\auth-accss = write\g'   "$1"${conf}
sed -i 's\# password-db = passwd\password-db = passwd\g'  "$1"${conf}
}

addUser(){
sed -i "s/# sally = sallyssecret/$2 = $3/g"  "$1"${pw}
}

if [ $# -lt 1 ];then
echo "Error param no.!"
echo "Usage(Root needed): svn.sh create reponame \nOR svn.sh restart "
exit
fi

if [ "$1" == "create" ]; then
if [ -z "$2" ]; then
echo "Error param"
exit
fi
home=/home/
repo=${home}"$2"
echo "creating repo" $repo

svnadmin create $repo
if [ $? -ne 0 ]; then
echo create failed!
exit;
else
read -p "inpute the username:" username
read -p "inpute the password:" password
changeConf $repo
addUser $repo $username $password
fi

elif [ "$1" == "restart" ]; then
if [ -z "$2" ]; then
read -p "Listen on which ip:" ip
fi
pid=`ps -e | grep svnserve | awk '{print $1}'`
kill -9 $pid 2>/dev/null 1>&2
svnserve -d -r /home --listen-host $ip
else
echo "error param"
fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐