更新ql repo命令

This commit is contained in:
whyour 2021-05-05 13:13:25 +08:00
parent 9bab07e62a
commit 2fb8b38d7e
2 changed files with 17 additions and 15 deletions

View File

@ -143,6 +143,7 @@ fix_config () {
make_dir $dir_manual_log make_dir $dir_manual_log
make_dir $dir_scripts make_dir $dir_scripts
make_dir $dir_list_tmp make_dir $dir_list_tmp
make_dir $dir_repo
make_dir $dir_raw make_dir $dir_raw
make_dir $dir_update_log make_dir $dir_update_log

View File

@ -170,6 +170,7 @@ update_repo() {
local url="$1" local url="$1"
local path="$2" local path="$2"
local blackword="$3" local blackword="$3"
local dependence="$4"
local urlTmp="${url%*/}" local urlTmp="${url%*/}"
local repoTmp="${urlTmp##*/}" local repoTmp="${urlTmp##*/}"
local repo="${repoTmp%.*}" local repo="${repoTmp%.*}"
@ -178,7 +179,7 @@ update_repo() {
local authorTmp2="${authorTmp1##*:}" local authorTmp2="${authorTmp1##*:}"
local author="${authorTmp2##*.}" local author="${authorTmp2##*.}"
local repo_path="${author}_${repo}" local repo_path="${dir_repo}/${author}_${repo}"
if [ -d ${repo_path}/.git ]; then if [ -d ${repo_path}/.git ]; then
reset_romote_url ${repo_path} ${url} reset_romote_url ${repo_path} ${url}
git_pull_scripts ${repo_path} git_pull_scripts ${repo_path}
@ -191,7 +192,7 @@ update_repo() {
echo -e "\n更新${repo_path}失败,请检查原因...\n" echo -e "\n更新${repo_path}失败,请检查原因...\n"
fi fi
diff_scripts $repo_path $author $path $blackword diff_scripts $repo_path $author $path $blackword $dependence
} }
## 更新所有 raw 文件 ## 更新所有 raw 文件
@ -270,7 +271,7 @@ update_qinglong() {
## 对比脚本 ## 对比脚本
diff_scripts() { diff_scripts() {
gen_list_repo $1 $2 $3 $4 gen_list_repo $1 $2 $3 $4 $5
diff_cron $list_own_scripts $list_own_user $list_own_add $list_own_drop diff_cron $list_own_scripts $list_own_user $list_own_add $list_own_drop
if [ -s $list_own_drop ]; then if [ -s $list_own_drop ]; then
@ -294,24 +295,23 @@ gen_list_repo() {
local author="$2" local author="$2"
local path="$3" local path="$3"
local blackword="$4" local blackword="$4"
local dependence="$4"
rm -f $dir_list_tmp/own*.list >/dev/null 2>&1 rm -f $dir_list_tmp/own*.list >/dev/null 2>&1
cd ${repo_path} cd ${repo_path}
files=$(find . -name "*.js") files=$(find . -name "*.js" | sed 's/^..//')
if [ $path ]; then if [[ -n $path ]]; then
files=$(find . -name "*.js" | egrep $path) files=$(find . -name "*.js" | sed 's/^..//' | egrep $path)
fi fi
if [ $blackword ]; then if [[ -n $blackword ]]; then
files=$(find . -name "*.js" | egrep -v $blackword | egrep $path) files=$(find . -name "*.js" | sed 's/^..//' | egrep -v $blackword | egrep $path)
fi
if [[ -n $dependence ]]; then
find . -name "*.js" | sed 's/^..//' | egrep $dependence | xargs -i cp {} $dir_scripts
fi fi
for file in ${files}; do for file in ${files}; do
filename=$(basename $file) filename=$(basename $file)
local non_scripts=$(echo $filename | egrep jd | egrep -v "jd_") cp -f $file $dir_scripts/${author}_${filename}
if [[ -z $non_scripts ]]; then
cp -f $file $dir_scripts/${filename}
else
cp -f $file $dir_scripts/${author}_${filename}
fi
echo ${author}_${filename} >>$list_own_scripts echo ${author}_${filename} >>$list_own_scripts
done done
grep -E "$cmd_task $author" $list_crontab_user | perl -pe "s|.*ID=(.*) $cmd_task ($author_.*)\.*|\2|" | sort -u >$list_own_user grep -E "$cmd_task $author" $list_crontab_user | perl -pe "s|.*ID=(.*) $cmd_task ($author_.*)\.*|\2|" | sort -u >$list_own_user
@ -345,6 +345,7 @@ main() {
local p2=$2 local p2=$2
local p3=$3 local p3=$3
local p4=$4 local p4=$4
local p4=$5
log_time=$(date "+%Y-%m-%d-%H-%M-%S") log_time=$(date "+%Y-%m-%d-%H-%M-%S")
log_path="$dir_log/update/${log_time}_$p1.log" log_path="$dir_log/update/${log_time}_$p1.log"
case $p1 in case $p1 in
@ -359,7 +360,7 @@ main() {
local name=$(echo "${p2##*/}" | awk -F "." '{print $1}') local name=$(echo "${p2##*/}" | awk -F "." '{print $1}')
log_path="$dir_log/update/${log_time}_$name.log" log_path="$dir_log/update/${log_time}_$name.log"
if [[ -n $p2 ]]; then if [[ -n $p2 ]]; then
update_repo "$p2" "$p3" "$p4" | tee $log_path update_repo "$p2" "$p3" "$p4" "$p5" | tee $log_path
else else
echo -e "命令输入错误...\n" echo -e "命令输入错误...\n"
usage usage