Authored by Rong

add

  1 +#/bin/bash
  2 +
  3 +function usage(){
  4 +echo "----------------------------------"
  5 +echo "参数说明:"
  6 +echo "-t : 操作类型"
  7 +echo "-f : 父路径"
  8 +echo "-c : 文件名"
  9 +echo ""
  10 +echo "举例:sh git.sh -t \"reset_pull\" -f /opt/jmeter/script -c test.jmx"
  11 +echo "----------------------------------"
  12 +}
  13 +
  14 +if [[ $# -lt 1 ]];then
  15 +usage
  16 +exit 1
  17 +fi
  18 +
  19 +while getopts "t:f:c:" arg
  20 +do
  21 +case $arg in
  22 +t)
  23 +gittype=$OPTARG
  24 +;;
  25 +f)
  26 +fatherPath=$OPTARG
  27 +;;
  28 +c)
  29 +filename=$OPTARG
  30 +;;
  31 +h)
  32 +usage
  33 +exit 1
  34 +;;
  35 +?)
  36 +echo "未知的参数!"
  37 +exit 1
  38 +;;
  39 +esac
  40 +done
  41 +
  42 +if [[ "$gittype" == "reset_pull" && -n "$fatherPath" ]];then
  43 +cd $fatherPath
  44 +pwd
  45 +git reset --hard origin/master
  46 +git pull
  47 +fi
  48 +
  49 +if [[ "$gittype" == "add_push" && -n "$fatherPath" && -n "$filename" ]];then
  50 +cd $fatherPath
  51 +pwd
  52 +git add $filename
  53 +git commit -m "commit by shell"
  54 +git push
  55 +fi
@@ -7,4 +7,4 @@ ps -ef | grep "yohoPerformanceTestAuto_Job.sh" | grep -v grep | cut -c 9-15 | xa @@ -7,4 +7,4 @@ ps -ef | grep "yohoPerformanceTestAuto_Job.sh" | grep -v grep | cut -c 9-15 | xa
7 if [ "$1" == "stop" ];then 7 if [ "$1" == "stop" ];then
8 exit 8 exit
9 fi 9 fi
10 -${basepath}/yohoPerformanceTestAuto_Job.sh 1>/dev/null 2>&1 & 10 +${basepath}/yohoPerformanceTestAuto_Job.sh $1 1>/dev/null 2>&1 &
@@ -8,7 +8,7 @@ basepath=$(cd `dirname $0`; pwd) @@ -8,7 +8,7 @@ basepath=$(cd `dirname $0`; pwd)
8 8
9 while true 9 while true
10 do 10 do
11 -${basepath}/yohoPerformanceTestAuto_Gor_InfluxDB.sh 11 +${basepath}/yohoPerformanceTestAuto_Gor_InfluxDB.sh $1 1>/dev/null 2>&1
12 12
13 sleep 7 13 sleep 7
14 done 14 done