[关闭]
@yibo 2015-07-09T04:41:26.000000Z 字数 1441 阅读 784

部署脚本

bash


  1. #!/bin/bash
  2. # sh deployjiemo.sh projects... @BRANCH
  3. remote_shell_dir=/root/shell
  4. project_path=/Users/yibo/IdeaProjects/jiemo
  5. kerberos_principal=zhaoyibo@DIANDIAN.COM
  6. project_branch=default
  7. if [ $# == 0 ];then
  8. echo "请输入project names:"
  9. echo "Usage: [$0 projects... @BRANCH] OR [$0 all @BRANCH]"
  10. exit
  11. else
  12. PROJECTS="$*";
  13. fi
  14. # 判断最后一个参数是否是以@开头,是则将其设为BRANCH
  15. test=`echo ${!#} | egrep '^@.+$'`
  16. if [ -n "$test" ];then
  17. project_branch=${!#:1}
  18. fi
  19. echo "use the [$project_branch] BRANCH"
  20. # 验证一下kerberos
  21. klist >/dev/null 2>&1
  22. status=$?
  23. while [ "$status" -ne "0" ]
  24. do
  25. kinit $kerberos_principal
  26. status=$?
  27. done
  28. # 是否重新部署component
  29. echo -n "re-deploy jiemo-component? (y/n)"
  30. read confirm
  31. if [ "$confirm" == 'y' ];then
  32. cd $project_path/jiemo-component
  33. mvn clean deploy -U
  34. if [ "$?" -ne "0" ];then
  35. echo "jiemo-component编译错误"
  36. exit 2
  37. fi
  38. fi
  39. if [[ "$PROJECTS" =~ "all" ]];then
  40. ssh root@10.10.5.11 "cd $remote_shell_dir;sh jiemo-admin-rebuild.sh $project_branch;sh jiemo-api-rebuild.sh $project_branch;sh java-rebuild.sh jiemo-runner $project_branch;sh java-rebuild.sh jiemo-event $project_branch;killjiemoevent;"
  41. else
  42. if [[ "$PROJECTS" =~ "admin" ]]; then
  43. ssh root@10.10.5.11 "sh $remote_shell_dir/jiemo-admin-rebuild.sh $project_branch"
  44. fi
  45. if [[ "$PROJECTS" =~ "api" ]]; then
  46. ssh root@10.10.5.11 "sh $remote_shell_dir/jiemo-api-rebuild.sh $project_branch"
  47. fi
  48. if [[ "$PROJECTS" =~ "runner" ]]; then
  49. ssh root@10.10.5.11 "sh $remote_shell_dir/java-rebuild.sh jiemo-runner $project_branch"
  50. fi
  51. if [[ "$PROJECTS" =~ "event" ]]; then
  52. ssh root@10.10.5.11 "sh $remote_shell_dir/java-rebuild.sh jiemo-event $project_branch;killjiemoevent"
  53. fi
  54. fi
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注