各种开发脚本备份

My Personal Vim & Bash Setting in OceanBase/AntFin/Alibaba

Note:本文内容已做适当脱敏

vimrc

bash 复制代码
"  call plug#begin('~/.vim/plugins')
"  Plug 'tomasr/molokai'
"  Plug 'octol/vim-cpp-enhanced-highlight'
"  Plug 'vim-airline/vim-airline'
"  "Plug 'Valloric/YouCompleteMe'
"  Plug 'luochen1990/rainbow'
"  Plug 'jiangmiao/auto-pairs'
"  Plug 'derekwyatt/vim-fswitch'
"  Plug 'tpope/vim-fugitive'
"  Plug 'scrooloose/nerdtree'
"  Plug 'neoclide/coc.nvim', {'branch': 'release'}
"  Plug 'm-pilia/vim-ccls'
"  Plug 'junegunn/fzf', {'dir': '~/.fzf','do': './install --all'}
"  Plug 'junegunn/fzf.vim' " needed for previews
"  Plug 'antoinemadec/coc-fzf'
"  "Plug 'jackguo380/vim-lsp-cxx-highlight'
"  "Plug 'scrooloose/nerdcommenter'
"  Plug 'skywind3000/vim-terminal-help'
"  call plug#end()

call plug#begin('~/.vim/plugins')
  Plug 'octol/vim-cpp-enhanced-highlight'
  " Plug 'scrooloose/syntastic'
call plug#end()


if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
   set fileencodings=utf-8,latin1,gbk
endif

"
" added by xiaochu
"
set nocompatible        " Use Vim defaults (much better!)
syntax on
set noeb
set autoindent
set cindent
set tags=tags;/
" set cino=g0:0,N-s
set hlsearch
set incsearch
" set cursorline


filetype on
filetype plugin on
filetype indent on

"set cursorcolumn
"set cursorline
"hi cursorline guibg=green guifg=black
"nmap <F8> :TlistToggle<CR><C-w><C-w>
nmap <F8> :TlistToggle<CR>
let Tlist_Close_On_Select = 1
let Tlist_Use_Right_Window = 0
let Tlist_GainFocus_On_ToggleOpen = 1

" end add by xiaochu
"


set bs=indent,eol,start         " allow backspacing over everything in insert mode
"set ai                 " always set autoindenting on
"set backup             " keep a backup file
set viminfo='20,\"50    " read/write a .viminfo file, don't store more
                        " than 50 lines of registers
set history=50          " keep 50 lines of command line history
set ruler               " show the cursor position all the time

" Only do this part when compiled with support for autocommands
if has("autocmd")
  augroup redhat
    " In text files, always limit the width of text to 78 characters
    autocmd BufRead *.txt set tw=78
    " When editing a file, always jump to the last cursor position
    autocmd BufReadPost *
    \ if line("'\"") > 0 && line ("'\"") <= line("$") |
    \   exe "normal! g'\"" |
    \ endif
  augroup END
endif


if 0 && has("cscope") && filereadable("/usr/bin/cscope")
   set csprg=/usr/bin/cscope
   set csto=0
   set cst
   set nocsverb
   " add any database in current directory
   if filereadable("cscope.out")
      cs add cscope.out
   " else add database pointed to by environment
   elseif $CSCOPE_DB != ""
      cs add $CSCOPE_DB
   endif
   set csverb
endif

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif

if &term=="xterm"
     set t_Co=8
     set t_Sb=m
     set t_Sf=m
endif
set shiftwidth=2
set sts=2
set tabstop=2
set expandtab

" 状态栏
set laststatus=2      " 总是显示状态栏
highlight StatusLine cterm=bold ctermfg=yellow ctermbg=blue
" 获取当前路径,将$HOME转化为~
set statusline=[%n]\ %f%m%r%h\ \ \ %l:%p%%
" autocmd FileType c,h,cpp autocmd BufWritePre <buffer> :%s/\s\+$//e

" Hightlight end of line whitespace.
au BufRead,BufNewFile *.c,*.cpp,*.h,*.py,*.sql match Error /\%100v.\%101v./
au BufRead,BufNewFile *.c,*.cpp,*.h,*.py,*.sql 2match Error /\s\+$/

command ML exec "make " . expand("%:r") . ".o"
hi  Comment  ctermfg=6


nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au BufRead,BufNewFile *.ipp set filetype=cpp

execute pathogen#infect()
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
" let g:syntastic_check_on_open = 1
" let g:syntastic_check_on_wq = 1
" let g:syntastic_cpp_check_header = 1
" let g:syntastic_cpp_remove_include_errors = 0
" let g:syntastic_cpp_compiler = 'clang++'
" let g:syntastic_cpp_config_file='/home/xiaochu.yh/.syntastic_cpp_config_file'

let g:CCTreeCscopeDb = "~/cscope.out"
let g:CCTreeRecursiveDepth = 8
let g:CCTreeMinVisibleDepth = 8
let g:CCTreeDisplayMode = 2

set noendofline binary

autocmd FileType python set expandtab
let g:go_version_warning = 0
set expandtab

bashrc

bash 复制代码
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# Maven
export MAVEN_HOME=/home/raywill/apache-maven-3.2.5
export LD_LIBRARY_PATH=/lib64/:/usr/lib64/:$LD_LIBRARY_PATH
export LD_RUN_PATH=/usr/local/lib:$LD_RUN_PATH

#export TBLIB_ROOT=/opt/csr/common
#export EASY_ROOT=/usr
#export EASY_LIB_PATH=/usr/lib64
#export DRC_ROOT=/home/ds
#export EDITOR=/bin/true

_vix2_home()
{
  $p = `ob flow | head -n 6  | grep 'Work Directory' | cut -d ":" -f 2,2`;
}

function http()
{
  echo http://$(hostname -i):39411/
  python -m SimpleHTTPServer 39411
}


#function fm {
#  ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
#  BR=${ref#refs/heads/};
#  GH=${1:0:10}
#  git log --ancestry-path --merges --reverse ${GH}..HEAD | head -n 23
#  #git log ${GH}..${BR} --ancestry-path --merges | tac | grep "Merge:" -B20 -A2 | head -n 23 |  tac
#}

function vid {
P1=$1
P2=$2
FILE=`echo $P1 | awk -F':' '{if (NF==1) print "'$P1'"; else print $1}' | awk -F'/' '{print $(NF)}'`
PARAM=`echo $P1 | awk -F':' '{if (NF==1) print "'$P2'"; else printf("+%s",$2)}'`
echo $FILE
echo $PARAM;
[ $(find `ob flow | head -n 6 | grep 'Work Directory' | cut -d ":" -f 2,2`/deps -name $FILE -type f | wc -l) == 1 ] && vim $(find `ob flow | head -n 6 | grep 'Work Directory' | cut -d ":" -f 2,2`/deps -name $FILE -type f | head -1) $PARAM  || find `ob flow | head -n 6 | grep 'Work Directory' | cut -d ":" -f 2,2`/deps -name $FILE -type f;
}

function vix {
P1=$1
P2=$2
FILE=`echo $P1 | awk -F':' '{if (NF==1) print "'$P1'"; else print $1}' | awk -F'/' '{print $(NF)}'`
PARAM=`echo $P1 | awk -F':' '{if (NF==1) print "'$P2'"; else printf("+%s",$2)}'`
echo $FILE
echo $PARAM;
[ $(find `ob flow | head -n 6 | grep 'Work Directory' | cut -d ":" -f 2,2`/src -name $FILE -type f | wc -l) == 1 ] && vim $(find `ob flow | head -n 6 | grep 'Work Directory' | cut -d ":" -f 2,2`/src -name $FILE -type f | head -1) $PARAM  || find `ob flow | head -n 6 | grep 'Work Directory' | cut -d ":" -f 2,2`/src -name $FILE -type f;
}

#function vix { [ $(find `ob flow | grep 'Work Directory' | cut -d ":" -f 2,2`/src -name `echo $1 | awk -F'/' '{print $(NF)}'` -type f | wc -l) == 1 ] && vim $(find `ob flow | grep 'Work Directory' | cut -d ":" -f 2,2`/src -name `echo $1 | awk -F'/' '{print $(NF)}'` -type f | head -1) $PARAM  || find `ob flow | grep 'Work Directory' | cut -d ":" -f 2,2`/src -name `echo $1 | awk -F'/' '{print $(NF)}'` -type f; }
function vic { [ $(find `ob flow | head -n 6  | grep 'Work Directory' | cut -d ":" -f 2,2`/tools/deploy/mysql_test -name $1 -type f | wc -l) == 1 ] && vim $(find `ob flow | head -n 6  | grep 'Work Directory' | cut -d ":" -f 2,2`/tools/deploy/mysql_test -name $1 -type f | head -1) $2 || find `ob flow | head -n 6  | grep 'Work Directory' | cut -d ":" -f 2,2`/tools/deploy/mysql_test/ -name $1 -type f; }

_vix()
{
    local list;
    local cur prev exe;
    exe=${COMP_WORDS[0]};
    cur=${COMP_WORDS[COMP_CWORD]};
    prev=${COMP_WORDS[COMP_CWORD - 1]};
    list=$(find `ob flow | head -n 6  | grep 'Work Directory' | cut -d ":" -f 2,2`/src -type f \( -name "*.cpp" -or -name "*.h" -or -name "*.test" -or -name "*.result" \) -name "$cur*" -exec basename {} \;);
    COMPREPLY=($(compgen -W "$list" -- ${cur}))
    return 0;
}
_vic()
{
    local list;
    local cur prev exe;
    exe=${COMP_WORDS[0]};
    cur=${COMP_WORDS[COMP_CWORD]};
    prev=${COMP_WORDS[COMP_CWORD - 1]};
    list=$(find `ob flow | head -n 6  | grep 'Work Directory' | cut -d ":" -f 2,2`/tools/deploy/mysql_test -type f \(  -name "*.test" -or -name "*.result" \) -name "$cur*" -exec basename {} \;);
    COMPREPLY=($(compgen -W "$list" -- ${cur}))
    return 0;
}
complete -F _vix vix
complete -F _vic vic




function vim2 {
P1=$1
P2=$2
FILE=`echo $P1 | awk -F':' '{if (NF==1) print "'$P1'"; else print $1}'`
PARAM=`echo $P1 | awk -F':' '{if (NF==1) print "'$P2'"; else printf("+%s",$2)}'`
echo $FILE
echo $PARAM;
/usr/bin/vim $FILE $PARAM;
}

alias vim=vim2

export GREP_OPTIONS="-I --color  --exclude-dir=\.svn --exclude=*\.svn* --exclude-dir=\.deps --exclude=\.deps --exclude=\.svn --exclude=*\.o --exclude=tags --exclude=*.o"

function git_branch {
    ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
    echo "("${ref#refs/heads/}") ";
}

function review()
{
  # usage: review issue/11111111
  #set -e
  if [[ "finish" == "$1" ]]
  then
    echo "cleanup and reset to master";
    ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
    branch=${ref#refs/heads/};
    git clean -df;
    git reset --hard;
    git checkout master;
    git branch -D $branch;
    return
  fi


  if [[ -n $(git diff --stat)  ]]
  then
    echo 'please commit local changes first'
    return
  fi

  git pl;
  echo "switch to origin/$1"
  git checkout -b review_branch_$1 origin/$1;
  git reset $(git log --author=obdev --pretty=format:%H | head -n 1)
  echo ""
  echo "set origin/$1 changes to uncommited status, use git diff to review"
}

PS1="[\[\e[1;35m\]\u \[\e[1;32m\]\w\[\e[0m\]] \[\e[0m\]\[\e[1;36m\]\$(git_branch)\[\e[0;33m\]\$"

alias cdde='cd ./tools/deploy/'
alias cdsrc='cd ~/cleanob/oceanbase/src'
alias cdrs='cd ~/cleanob/oceanbase/src/rootserver'
alias cdpx='cd ~/px/src/sql/engine/px'
alias cdseq='cd ~/cleanob/oceanbase/src/'
alias grpe='grep'
export REVIEWBOARD_URL=http://review.alibaba-inc.com/

#/tmpfs/raywill
export MAKE_ARGS=-j18
export CONFIGURE_ARGS="--enable-strip-ut=yes --enable-buildtime=no"

export OLD_DEPLOY=1



MANPATH=$MANPATH:$HOME/share/man
alias ak='ob farm'
alias akbusy="condor_status -af:h WorkerRole Activity name RemoteUser -sort 'strcat(WorkerRole,Machine)' | column -t | grep -v ^undefined"
alias akglobal="ak status -g --limit 100"
alias akg="ak status -g --limit 80"
alias akj="ak status -j"
alias aks="ak status --limit 30"
OB_FLOW_WORK_DIR=/data/1/raywill
set bell-style none
alias gitpl="git pull --rebase; ob-make"
alias of="ob flow"
alias offeature="ob flow feature refresh --rebase"
alias cherrypick="echo ob flow cherry-pick review_id issue_url target_branch -n name"
alias getmaster="mkdir -p bin/;wget http://127.1:8877/observer.master-7u -O bin/observer; strip -g bin/observer; chmod +x bin/*"
alias getmaster2="mkdir -p bin/;wget http://127.1:8877/observer.master-7u -O bin/observer; chmod +x bin/*"
alias getproxy="mkdir -p bin/; wget http://127.1:8877/obproxy.release -O bin/obproxy; chmod +x bin/*"
alias getobs14x="mkdir -p bin/;wget http://127.1:8877/observer.1_4_x_release-7u -O bin/observer; chmod +x bin/*"
alias getobs225="mkdir -p bin/;wget http://127.1:8877/observer.2_2_5_release-7u -O bin/observer; chmod +x bin/*"
alias getobs223="mkdir -p bin/;wget http://127.1:8877/observer.2_2_3_release-7u -O bin/observer; chmod +x bin/*"
alias getobs226="mkdir -p bin/;wget http://127.1:8877/observer.2_2_6_release-7u -O bin/observer; chmod +x bin/*"
alias getobs22x="mkdir -p bin/;wget http://127.1:8877/observer.2_2_x_release-7u -O bin/observer; chmod +x bin/*"
alias getobs30x="mkdir -p bin/;wget http://127.1:8877/observer.3_0_x_release-7u -O bin/observer; chmod +x bin/*"
alias getobs31x="mkdir -p bin/;wget http://127.1:8877/observer.3_1_x_release-7u -O bin/observer; chmod +x bin/*"
alias getobs32x="mkdir -p bin/;wget http://127.1:8877/observer.3_2_x_release-7u -O bin/observer; chmod +x bin/*"
alias getobs323="mkdir -p bin/;wget http://127.1:8877/observer.3_2_3_release-7u -O bin/observer; chmod +x bin/*"
alias getobs33x="mkdir -p bin/;wget http://127.1:8877/observer.3_3_x_release-7u -O bin/observer; strip -g bin/observer; chmod +x bin/*"
alias getobs41x="mkdir -p bin/;wget http://127.1:8877/observer.4_1_0_release-7u -O bin/observer; strip -g bin/observer; chmod +x bin/*"
alias getobs42x="mkdir -p bin/;wget http://127.1:8877/observer.4_2_x_release-7u -O bin/observer; strip -g bin/observer; chmod +x bin/*"
alias getobsos="mkdir -p bin/;wget http://127.1:8877/observer.3.1_opensource_release-7u -O bin/observer; strip -g bin/observer; chmod +x bin/*"
alias getconfig="cp ~/config2.py ."
alias getobs="mkdir -p bin/; cp -v ../../build_debug/src/observer/observer bin/observer; chmod +x bin/*; strip -g bin/observer"
alias getobsasan="mkdir -p bin/; cp -v ../../build_debug_asan/src/observer/observer bin/observer; chmod +x bin/*; strip -g bin/observer"
alias getobsrel="mkdir -p bin/; cp -v ../../build_release/src/observer/observer bin/observer; chmod +x bin/*; strip -g bin/observer"
alias getobs2="mkdir -p bin/; cp -v ../../build_debug/src/observer/observer bin/observer; chmod +x bin/*"
alias getobsrel2="mkdir -p bin/; cp -v ../../build_release/src/observer/observer bin/observer; chmod +x bin/*"
alias buildobs="r;./build.sh init; ./build.sh; cd build_debug; ob-make"
alias buildobsrel="r;./build.sh init; ./build.sh release; cd build_release; ob-make"
alias ob2reboot="d; getconfig; getobs; getproxy; ./copy.sh -l; ./deploy.py ob2.reboot"
alias ob2rebootrel="d; getconfig; ./copy.sh -l; getobsrel; getproxy; ./deploy.py ob2.reboot"
alias ob1reboot="d; getconfig; getobs; getproxy; ./deploy.py ob1.reboot"
alias htop="~/htop.sh"
alias ob2.reboot="./deploy.py ob2.reboot"
alias ob2.restart="./deploy.py ob2.restart"
alias ob2.mysqltest="./deploy.py ob2.mysqltest disable-reboot "
alias ob2.obs0.mysqltest="./deploy.py ob2.obs0.mysqltest disable-reboot "
alias ob2.obs1.mysqltest="./deploy.py ob2.obs1.mysqltest disable-reboot "
alias ob2.proxy0.mysqltest="./deploy.py ob2.proxy0.mysqltest disable-reboot "
alias mf="find . | grep "
alias ak.retry="sh ~/tools/scripts/retry.sh"
alias ak.list="sh ~/tools/scripts/list.sh"
alias of.cd=". ~/tools/scripts/of.cd.sh"
alias backup=". ~/tools/scripts/backup.sh"

function d { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/tools/deploy); }
function dep { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/deps); }
function s { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src); }
function sess { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/share/system_variable); }
function se { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/sql/session); }
function cg { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/sql/code_generator); }
function pdml { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/sql/engine/pdml); }
function opt { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/sql/optimizer); }
function opti { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/sql/optimizer); }
function px { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/sql/engine/px); }
function exp { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/sql/engine/expr); }
function obs { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/observer/mysql); }
function dtl { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src/sql/dtl); }
function bd { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/build_debug); }
function r { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/); }
function br { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/build_release); }
function suite { cd $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/tools/deploy/mysql_test/test_suite/$1/t); }
function ct { r; /usr/bin/ctags -R $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/src) $(echo `ob flow | head -n 9  | grep 'Work Directory' | cut -d ":" -f 2,2`/deps); cd -; }

alias mon="python /home/raywill/tools/mon.py/mon.py  -h 100.88.108.16 -P 19800 -uTPCUSER@tpc  -Dtpcuser "
alias tpch="ssh  -o ServerAliveInterval=30  tpch@47.100.19.242"

[ -f ~/.fzf.bash ] && source ~/.fzf.bash

export OBDEV_ROOT=/usr/local/obdev
export NLS_LANG=AMERICAN
export NLS_DATE_FORMAT=YYYY-MM


function fm {
  GH=$1
	git log --ancestry-path --merges --reverse ${GH}..HEAD | head -n 200 |  awk '{if($0 ~ /^commit /) { cnt++; if (cnt == 2) exit; } else print}'
}

export PATH=~/pha-all/arcanist/bin/:$PATH
export FLINK_HOME=/home/raywill/flink/flink-1.15.3

scripts

bash 复制代码
[raywill ~/tools/scripts] $ls
add_header.sh  backup.sh  htop.sh  list.sh  of.cd.sh  retry.sh

[raywill ~/tools/scripts] $cat *
HEADER=`cat<<EOF
--disable_query_log
--error 0,1064
alter session force parallel dml parallel 3;
--error 0,900
set _force_parallel_dml_dop = 3;
--enable_query_log

EOF
`

echo "$HEADER" > tmp

function update_dir(){
  for file in `ls $1/*.test` #注意此处这是两个反引号,表示运行系统命令
    do
       cat tmp $file > tmp2
       mv tmp2 $file
       echo $file
    done
}
#读取第一个参数
update_dir $1
#read_dir $1


# 本工具用于将文件放到 http 服务中
if [[ $# -ne 2 ]]
then
  echo "Invalid arguments. example:"
  echo "backup src/observer/observer observer-sess-asan"
  return
fi

scp $1 raywill@127.1:/share/public/raywill/share/$2
echo raywill@127.1:/share/public/raywill/share/$2
echo "http://s.oceanbase.icu/raywill/share/$2"
echo "wget http://127.1/raywill/share/$2 -O bin/observer; chmod +x bin/observer"
top -d 10 -H -b -n1 | awk 'NR>6 { total += $9; CNT[substr($12, 0, 8)] +=1;  SUM[substr($12, 0, 8)] += $9} END { for (name in SUM) { if (SUM[name] > 0 && SUM[name] < 1000000) {printf "%s\t%s\t%s\n", CNT[name], name, SUM[name];} } printf "total=%s\n", total; }'
#!/bash/sh

# name: easyfarm
# author: raywill


function git_branch {
    ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
    echo ${ref#refs/heads/};
}

if [ $# -gt 0 ]; then
  result=$(echo $1 | grep "/")
  if [[ "$result" != "" ]]
  then
    branch=$1
  else
    if [[ "$1" == "-j" ]]
    then
      let line="1"
    else
      v=$1
      let line=${v#"-j"}
    fi
    branch=`ak status | grep farm | awk -F'|' '{ if (NR=='$line') print $4; }'`
  fi
else
  branch=$(git_branch)
fi

item=`ak status | grep $branch | awk -F'|' 'NR==1{print $7}'`
ak_log_path=`ak status | grep 'Directory' | awk -F': ' 'NR==1{print $1}'`
ak_log_id=`ak status | grep $branch | awk -F'|' 'NR==1{print $6}'`
echo "Branch:" $branch
echo "Id:" $ak_log_id
echo "AK Path:" $ak_log_path

if [ "x" = "x$ak_log_path" ]; then
  echo "Invalid branch name $branch!"
else
  echo =============================
  cd $ak_log_path
  echo Compatible Test Error:
  grep 'deploy failed' compat.output
  echo Mysqltest Error:
  grep '| FAILED |' mysqltest.output.* | awk '{print $1 $2}'
  echo List:
  grep '| FAILED |' mysqltest.output.* | awk '{print $2}' | xargs | sed 's/ /,/g'
  echo =============================
fi
# 本工具用于把 OceanBase 多个开发分支按照时间顺序显示出来
#files=$(ls -l -t /data/1/raywill/ | awk -F ' ' '{print $6"."$7,"\t", $9}')

if [[ $# -eq 1 ]]
then
REPLY=*$1*
else
REPLY=*
fi

retry=true

while $retry
do
  files=$(cd /data/1/raywill/ && ls -d -l -t  $REPLY | awk -F ' ' '{print $9}')
  options=($files)
  if [[ ${#options[@]} -eq 0 ]]
  then
    REPLY=*
    files=$(cd /data/1/raywill/ && ls -d -l -t  $REPLY | awk -F ' ' '{print $9}')
    options=($files)
  fi

  PS3='Please enter your choice: '
  select opt in "${options[@]}"
  do
    if [[ x$opt == "x" ]]
    then
      REPLY=*$REPLY*
      clear
      break
    else
      cd /data/1/raywill/$opt
      retry=false
      break
    fi
  done
done


#if [[ $# -eq 1 ]]
#then
#files=$(cd /data/1/raywill/ && ls -d -l -t *$1* | awk -F ' ' '{print $9}')
#else
#files=$(cd /data/1/raywill/ && ls -l -t | awk -F ' ' '{print $9}')
#fi
#PS3='Please enter your choice: '
#options=($files)
#select opt in "${options[@]}"
#do
#cd /data/1/raywill/$opt
#break
#done
#!/bash/sh

# name: easyfarm
# author: raywill


function git_branch {
    ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
    echo ${ref#refs/heads/};
}

if [ $# -gt 0 ]; then
  result=$(echo $1 | grep "/")
  if [[ "$result" != "" ]]
  then
    branch=$1
  else
    if [[ "$1" == "-j" ]]
    then
      let line="1"
    else
      v=$1
      let line=${v#"-j"}
    fi
    branch=`ak status | grep farm | awk -F'|' '{ if (NR=='$line') print $4; }'`
  fi
else
  branch=$(git_branch)
fi

ak_log_id=`ak status | grep $branch | awk -F'|' 'NR==1{print $6}'`
ak_log_path=`ak status | grep $branch | awk -F'|' 'NR==1{print $7}'`
echo "Branch:" $branch
echo "Id:" $ak_log_id
echo "AK Path:" $ak_log_path

if [ "x" = "x$ak_log_path" ]; then
  echo "Invalid branch name $branch!"
else
  echo =============================
  cd $ak_log_path
  echo Compatible Test Error:
  grep 'deploy failed' compat.output
  echo Mysqltest Error:
  grep '| FAILED |' mysqltest.output.* | awk '{print $1 $2}'
  echo List:
  grep '| FAILED |' mysqltest.output.* | awk '{print $2}' | xargs | sed 's/ /,/g'
  echo =============================

  echo Do retry:
  ak retry -f
fi
相关推荐
徐同保15 小时前
vue 在线预览word和excel
vue.js·word·excel
kaixin_啊啊19 小时前
计算机二级office操作技巧——Excel篇
excel
~在杰难逃~1 天前
关于订单信息的Excel数据分析报告
笔记·数据分析·excel·数据分析报告
生产队队长2 天前
SpringBoot2:web开发常用功能实现及原理解析-整合EasyExcel实现Excel导入导出功能
spring boot·excel
麋鹿会飞但不飘2 天前
EasyExcel拿表头(二级表头)爬坑,invokeHeadMap方法
java·spring boot·excel
Eiceblue2 天前
Python 实现Excel XLS和XLSX格式相互转换
vscode·python·pycharm·excel
if时光重来2 天前
springboot项目实现导出excel动态设置表头
spring boot·后端·excel
我是Superman丶2 天前
【工具】Java Excel转图片
java·python·excel
說詤榢2 天前
判断2个excel文件差异的条数
excel
镜花照无眠2 天前
Excel爬虫使用实例-百度热搜
爬虫·excel