@yibo
2015-07-09T04:41:26.000000Z
字数 1441
阅读 865
bash
#!/bin/bash# sh deployjiemo.sh projects... @BRANCHremote_shell_dir=/root/shellproject_path=/Users/yibo/IdeaProjects/jiemokerberos_principal=zhaoyibo@DIANDIAN.COMproject_branch=defaultif [ $# == 0 ];thenecho "请输入project names:"echo "Usage: [$0 projects... @BRANCH] OR [$0 all @BRANCH]"exitelsePROJECTS="$*";fi# 判断最后一个参数是否是以@开头,是则将其设为BRANCHtest=`echo ${!#} | egrep '^@.+$'`if [ -n "$test" ];thenproject_branch=${!#:1}fiecho "use the [$project_branch] BRANCH"# 验证一下kerberosklist >/dev/null 2>&1status=$?while [ "$status" -ne "0" ]dokinit $kerberos_principalstatus=$?done# 是否重新部署componentecho -n "re-deploy jiemo-component? (y/n)"read confirmif [ "$confirm" == 'y' ];thencd $project_path/jiemo-componentmvn clean deploy -Uif [ "$?" -ne "0" ];thenecho "jiemo-component编译错误"exit 2fifiif [[ "$PROJECTS" =~ "all" ]];thenssh 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;"elseif [[ "$PROJECTS" =~ "admin" ]]; thenssh root@10.10.5.11 "sh $remote_shell_dir/jiemo-admin-rebuild.sh $project_branch"fiif [[ "$PROJECTS" =~ "api" ]]; thenssh root@10.10.5.11 "sh $remote_shell_dir/jiemo-api-rebuild.sh $project_branch"fiif [[ "$PROJECTS" =~ "runner" ]]; thenssh root@10.10.5.11 "sh $remote_shell_dir/java-rebuild.sh jiemo-runner $project_branch"fiif [[ "$PROJECTS" =~ "event" ]]; thenssh root@10.10.5.11 "sh $remote_shell_dir/java-rebuild.sh jiemo-event $project_branch;killjiemoevent"fifi