Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29422
  • 博文数量: 5
  • 博客积分: 133
  • 博客等级: 入伍新兵
  • 技术积分: 111
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-29 23:00
文章分类

全部博文(5)

文章存档

2012年(1)

2011年(4)

我的朋友

分类: LINUX

2011-11-30 21:55:29

本脚本是临时写的,可能有些乱,只是做些测试用,有什么问题可以直接联系我zongzk@zongzk.com

功能:
实现SVN服务器到开发服务器之间的同步
  1. #!/bin/bash
  2. clear

  3. #Main
  4. num(){
  5. i=1
  6. while (( i<=100 ))
  7. do
  8.         echo -en "$i%""\b\b\b"
  9.         sleep 0.01
  10.         ((i++))
  11. done
  12.         echo
  13.         echo "初始化成功!"
  14.         sleep 1
  15. }
  16. welcome(){
  17. for i in {5..1}
  18. do
  19.         echo -ne $i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i$i"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
  20.         sleep 0.5
  21.         echo "welcome to "
  22. done
  23. }

  24. #Main_Var
  25. PATH="/usr/local/ruby/bin:/app/mysql/bin/:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
  26. IPADDR=8.8.8.8
  27. PUBLICSVNDIR="/sinten/WOS_Public/WebContent"
  28. ENTERPRISESVNDIR="/sinten/WOS_Enterprise/WebContent"
  29. USER=zongzk
  30. PASS=zongzk0704
  31. TEMP_SVN_ENTERPRISE=/root/SVN/SVNTEMP_ENTERPRISE
  32. TEMP_SVN_PUBLIC=/root/SVN/SVNTEMP_PUBLIC
  33. TEMP_SVN_TEMP=/root/SVN/SVN_TEMP
  34. #Tomcat Root Dir
  35. NETTOMCATDIR="/app/web/Devel.zongzk.com/"
  36. COMTOMCATDIR="/app/web/public.zongzk.com/"



  37. #Var
  38. SVNENTERPRISE="svn://${IPADDR}${ENTERPRISESVNDIR}"
  39. SVNPUBLIC="svn://${IPADDR}${PUBLICSVNDIR}"

  40. #test
  41. if [ ! -e $TEMP_SVN_ENTERPRISE ]
  42. then
  43.         mkdir -p $TEMP_SVN_ENTERPRISE
  44. fi

  45. if [ ! -e $TEMP_SVN_PUBLIC ]
  46. then
  47.         mkdir -p $TEMP_SVN_PUBLIC
  48. fi

  49. if [ ! -e $TEMP_SVN_TEMP ]
  50. then
  51.         mkdir -p $TEMP_SVN_TEMP
  52. fi


  53. #main
  54. if ping -c 1 ${IPADDR} &>/dev/null
  55. then
  56.         read -p "请输入需要更新的站点(net/com) : " var
  57.         case $var in
  58.         help)
  59.                 echo "Please input such as public or devel !!"
  60.         ;;
  61.         devel|net)
  62.                 NEWSVNDIR=$TEMP_SVN_ENTERPRISE
  63.                 echo "初始化中......."
  64.                 num
  65.                 if svn checkout $SVNENTERPRISE $TEMP_SVN_ENTERPRISE --username=$USER --password $PASS
  66.                 then
  67.                         echo "同步成功!"
  68.                 else
  69.                         echo "认证失败!!"
  70.                         exit 88
  71.                 fi
  72.         ;;
  73.         public|com)
  74.                 NEWSVNDIR=$TEMP_SVN_PUBLIC
  75.                 echo "初始化中......."
  76.                 num
  77.                 if svn checkout $SVNPUBLIC $TEMP_SVN_PUBLIC --username=$USER --password $PASS
  78.                 then
  79.                         echo "同步成功!"
  80.                 else
  81.                         echo "认证失败!"
  82.                         exit 88
  83.                 fi
  84.         ;;
  85.         *)
  86.                 echo "Please input such as public or devel !!"
  87.         ;;
  88.         esac
  89. else
  90.         echo "$IPADDR Not connected"
  91. fi

  92. if cp -ra $NEWSVNDIR/* $TEMP_SVN_TEMP
  93. then
  94.         find $TEMP_SVN_TEMP -name .svn -exec rm -rf {} \; &>/dev/null
  95.         if [ "${NEWSVNDIR}" = "${TEMP_SVN_ENTERPRISE}" ]
  96.         then
  97.                 /usr/bin/rsync -avzPl --delete --password-file=/etc/rsyncd/rsyncd.password rsync@192.168.101.101::xxxxxx ${NETTOMCATDIR}/ROOT &>/dev/null
  98.                 /bin/cp -ra ${NETTOMCATDIR}/classes ${NETTOMCATDIR}/ROOT/WEB-INF/classes
  99.                 /bin/cp -ra ${NETTOMCATDIR}/upload ${NETTOMCATDIR}/ROOT/upload
  100.                 elif [ "${NEWSVNDIR}" = "${TEMP_SVN_PUBLIC}" ]
  101.                 then
  102.                         /usr/bin/rsync -avzPl --delete --password-file=/etc/rsyncd/rsyncd.password rsync@192.168.101.101::xxxxxxx ${COMTOMCATDIR}/ROOT &>/dev/null
  103.                         /bin/cp -ra ${COMTOMCATDIR}/classes ${COMTOMCATDIR}/ROOT/WEB-INF/classes
  104.                         /bin/cp -ra ${COMTOMCATDIR}/upload ${COMTOMCATDIR}/ROOT/upload
  105.                 fi
  106.         fi
  107. rm -rf $TEMP_SVN_TEMP
  108. chown tomcat.app /app/web -R
阅读(1864) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~