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

svn的安装及配置:

http://blog.csdn.net/kangquan2008/article/details/8070391

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

========================脚本=========================

[ruby] view plaincopyprint?

  1. #!/bin/bash
  2. conf=/conf/svnserve.conf 
  3. pw=/conf/passwd 
  4. changeConf(){ 
  5.         sed -i 's\# anon-access = read\anon-accss = none\g' "$1"${conf} 
  6.         sed -i 's\# auth-access = write\auth-accss = write\g' "$1"${conf} 
  7.         sed -i 's\# password-db = passwd\password-db = passwd\g' "$1"${conf} 
  8. addUser(){ 
  9.         sed -i "s/# sally = sallyssecret/$2 = $3/g" "$1"${pw} 
  10. if [ $# -lt 1 ];then
  11.         echo "Error param no.!"
  12.         echo "Usage(Root needed): svn.sh create reponame \nOR svn.sh restart "
  13.         exit 
  14. fi 
  15. if [ "$1" == "create" ]; then
  16. if [ -z "$2" ]; then
  17.                 echo "Error param"
  18.                 exit 
  19.         fi 
  20.         home=/home/ 
  21.         repo=${home}"$2"
  22.         echo "creating repo" $repo
  23.         svnadmin create $repo
  24. if [ $? -ne 0 ]; then
  25.                 echo create failed! 
  26.                 exit; 
  27. else
  28.         read -p "inpute the username:" username 
  29.         read -p "inpute the password:" password 
  30.                 changeConf $repo
  31.                 addUser $repo $username $password
  32.         fi 
  33. elif [ "$1" == "restart" ]; then
  34. if [ -z "$2" ]; then
  35.                 read -p "Listen on which ip:" ip 
  36.         fi 
  37.         pid=`ps -e | grep svnserve | awk '{print $1}'`   
  38.         kill -9 $pid 2>/dev/null 1>&2 
  39.         svnserve -d -r /home --listen-host $ip
  40. else
  41.         echo "error param"
  42. fi 
posted @ 2013-03-11 19:02  雾岛的朝雾  阅读(155)  评论(0编辑  收藏  举报