This commit is contained in:
anonymous 2021-04-07 21:29:09 +08:00
parent a371bf4e90
commit 103456dfca
3 changed files with 17 additions and 22 deletions

View File

@ -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

View File

@ -46,11 +46,6 @@ combine_one () {
done
}
## 申明全部变量,$1all/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

View File

@ -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