From 103456dfca534aeb804a1f5dc23b563197ce4c1b Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 7 Apr 2021 21:29:09 +0800 Subject: [PATCH] dev --- shell/share.sh | 22 +++++++++------------- shell/task.sh | 11 ++--------- shell/update.sh | 6 ++++++ 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/shell/share.sh b/shell/share.sh index 8cec108d..6c943133 100644 --- a/shell/share.sh +++ b/shell/share.sh @@ -50,16 +50,22 @@ original_name=( ## 导入配置文件不校验 import_config_no_check () { [ -f $file_cookie ] && . $file_cookie - [ -f $file_sharecode ] && . $file_sharecode [ -f $file_config_user ] && . $file_config_user } ## 导入配置文件并校验,$1:任务名称 import_config_and_check () { import_config_no_check $1 - if [[ -z ${Cookie1} ]]; then - echo -e "请先在配置好Cookie...\n" + if [[ ! -s $file_cookie ]]; then + echo -e "请先配置好Cookie...\n" exit 1 + else + user_sum=0 + for line in $(cat $file_cookie); do + let user_sum++ + [[ $user_sum -gt $((3 * 5)) ]] && break + eval Cookie${user_sum}="\"$line\"" + done fi } @@ -72,16 +78,6 @@ notify () { fi } -## 统计用户数量 -count_user_sum () { - user_sum=0 - for line in $(cat $file_cookie); do - let user_sum++ - [[ $user_sum -gt $((3 * 5)) ]] && break - eval Cookie${user_sum}="\"$line\"" - done -} - ## 创建目录,$1:目录的绝对路径 make_dir () { local dir=$1 diff --git a/shell/task.sh b/shell/task.sh index cf92080e..561152f1 100644 --- a/shell/task.sh +++ b/shell/task.sh @@ -46,11 +46,6 @@ combine_one () { done } -## 申明全部变量,$1:all/Cookie编号 -export_all_env () { - [[ $type == all ]] && combine_all || combine_one $type -} - ## 选择python3还是node define_program () { [[ $p1 == *.js ]] && which_program="node" @@ -116,9 +111,8 @@ run_normal () { if [ -f $p1 ]; then import_config_and_check "$p1" update_crontab - count_user_sum define_program - export_all_env all + combine_all [[ $# -eq 1 ]] && random_delay log_time=$(date "+%Y-%m-%d-%H-%M-%S") log_path="$dir_log/$p1/$log_time.log" @@ -138,7 +132,6 @@ run_concurrent () { if [ -f $p1 ]; then import_config_and_check "$p1" update_crontab - count_user_sum define_program make_dir $dir_log/$p1 log_time=$(date "+%Y-%m-%d-%H-%M-%S.%N") @@ -147,7 +140,7 @@ run_concurrent () { for num in ${TempBlockCookie}; do [[ $user_num -eq $num ]] && continue 2 done - export_all_env $user_num + combine_one $user_num log_path="$dir_log/$p1/${log_time}_${user_num}.log" $which_program $p1 &>$log_path & done diff --git a/shell/update.sh b/shell/update.sh index d60a3c24..c94d7405 100644 --- a/shell/update.sh +++ b/shell/update.sh @@ -263,6 +263,10 @@ update_own_repo () { echo -e "\n更新${array_own_repo_path[i]}失败,请检查原因...\n" fi done + for ((i=0; i<${#array_own_scripts_path[*]}; i++)); do + diff_and_copy "$dir_sample/sendNotify.js" "${array_own_scripts_path[i]}/sendNotify.js" + diff_and_copy "$dir_sample/jdCookie.js" "${array_own_scripts_path[i]}/jdCookie.js" + done } ## 更新所有 raw 文件 @@ -283,6 +287,8 @@ update_own_raw () { [ -f "$dir_raw/${raw_file_name[$i]}.new" ] && rm -f "$dir_raw/${raw_file_name[$i]}.new" fi done + diff_and_copy "$dir_sample/sendNotify.js" "$dir_raw/sendNotify.js" + diff_and_copy "$dir_sample/jdCookie.js" "$dir_raw/jdCookie.js" } ## 调用用户自定义的extra.sh