#!/bin/Bash#author by jackluo# file to filter excludefile=(api.md dev.md. git. Gitignore. htaccess. Project readme.md) #定义要copy的目录new_git_code_dir=/data/projects/your own git repository pathProduction_code_dir=/data/projects/you produce the above path/#检查这个字段是否存在这个数组中functionIn_array () {local F=($1) Local A=($2) forIinch${a[*]}; Do#检查是否在在过滤文件中, on the return1, not on the return0 if[[$i = $f]]; Thenreturn1; fi Done}CD $new _git_code_dirEcho "Pull Replace code ..."Start=$(Date+%s) git pullend=$(Date+%s) Time=$ ($end-$start))Echo "Code Pull Complete ... It took $time seconds to finish."#列出目录中所有的文件LISTDIR=`ls$new _git_code_dir 'Echo "start copying code ..."Start=$(Date+%s) forDinch$LISTDIR; Do#检查是不在拷的范围内 In_array"$d" "${excludefile[*]}" if[[ $? =1]] ; ThenContinueElse Echo "being handcuffed $d ..."/bin/CP-A ${new_git_code_dir}/$d ${production_code_dir}fi DoneEnd=$(Date+%s) Time=$ ($end-$start))Echo "Copy Code Complete ... It took $time seconds to finish."Echo "Change directory Permissions ..."ChownFPM:FPM ${production_code_dir}-R &>/dev/NULLEcho "Deployment Complete"
Deployment scripting features on production