From 4949457001bda66943ce51718a49e4180a88043a Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 26 Oct 2022 23:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dql=E5=91=BD=E4=BB=A4=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shell/otask.sh | 13 ++++++++++--- shell/share.sh | 2 +- shell/update.sh | 45 +++++++++++++++++++++++++++++---------------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/shell/otask.sh b/shell/otask.sh index 5aa6c234..b849c511 100644 --- a/shell/otask.sh +++ b/shell/otask.sh @@ -97,7 +97,11 @@ handle_task_before() { [[ $is_macos -eq 0 ]] && check_server - [[ -f $task_error_log_path ]] && cat $task_error_log_path + if [[ -s $task_error_log_path ]]; then + eval cat $task_error_log_path $cmd + eval echo -e "加载 config.sh 出错,请手动检查" $cmd + eval echo $cmd + fi [[ $ID ]] && update_cron "\"$ID\"" "0" "$$" "$log_path" "$begin_timestamp" . $file_task_before "$@" @@ -105,9 +109,12 @@ handle_task_before() { handle_task_after() { . $file_task_after "$@" - local end_time=$(date '+%Y-%m-%d %H:%M:%S') - local end_timestamp=$(date "+%s") + + local etime=$(date "+$time_format") + local end_time=$(format_time "$time_format" "$etime") + local end_timestamp=$(format_timestamp "$time_format" "$etime") local diff_time=$(($end_timestamp - $begin_timestamp)) + [[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time" echo -e "\n\n## 执行结束... $end_time 耗时 $diff_time 秒" echo -e "\n     " diff --git a/shell/share.sh b/shell/share.sh index e53c14fa..95d8d5b3 100755 --- a/shell/share.sh +++ b/shell/share.sh @@ -486,4 +486,4 @@ detect_macos define_cmd fix_config -import_config $1 >$task_error_log_path 2>&1 +import_config $1 2>$task_error_log_path diff --git a/shell/update.sh b/shell/update.sh index 53f579fd..600eab58 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -230,10 +230,10 @@ run_extra_shell() { ## 脚本用法 usage() { - echo -e "本脚本用法:" + echo -e "ql命令使用方法:" echo -e "1. $cmd_update update # 更新并重启青龙" echo -e "2. $cmd_update extra # 运行自定义脚本" - echo -e "3. $cmd_update raw # 更新单个脚本文件" + echo -e "3. $cmd_update raw # 更新单个脚本文件" echo -e "4. $cmd_update repo # 更新单个仓库的脚本" echo -e "5. $cmd_update rmlog # 删除旧日志" echo -e "6. $cmd_update bot # 启动tg-bot" @@ -440,18 +440,26 @@ main() { cmd=">> $file_path 2>&1" [[ "$show_log" == "true" ]] && cmd="" - [[ -f $task_error_log_path ]] && eval cat $task_error_log_path $cmd - - if [[ "$show_log" == "true" ]] && [[ $ID ]]; then - eval echo -e "请移除 -l 参数" $cmd - exit 1 - fi local time_format="%Y-%m-%d %H:%M:%S" local time=$(date "+$time_format") local begin_timestamp=$(format_timestamp "$time_format" "$time") [[ $ID ]] && update_cron "\"$ID\"" "0" "$$" "$log_path" "$begin_timestamp" + local begin_time=$(format_time "$time_format" "$time") + eval echo -e "\#\# 开始执行... $begin_time\\\n" $cmd + + if [[ -s $task_error_log_path ]]; then + eval cat $task_error_log_path $cmd + eval echo -e "加载 config.sh 出错,请手动检查" $cmd + eval echo $cmd + fi + + if [[ "$show_log" == "true" ]] && [[ $ID ]]; then + eval echo -e "请移除 -l 参数" $cmd + exit 1 + fi + case $p1 in update) eval update_qinglong "$2" $cmd @@ -464,7 +472,7 @@ main() { if [[ -n $p2 ]]; then update_repo "$p2" "$p3" "$p4" "$p5" "$p6" "$p7" else - eval echo -e "命令输入错误...\\\n" + eval echo -e "命令输入错误...\\\n" $cmd eval usage $cmd fi ;; @@ -473,7 +481,7 @@ main() { if [[ -n $p2 ]]; then update_raw "$p2" else - eval echo -e "命令输入错误...\\\n" + eval echo -e "命令输入错误...\\\n" $cmd eval usage $cmd fi ;; @@ -488,13 +496,13 @@ main() { ;; resetlet) auth_value=$(cat $file_auth_user | jq '.retries =0' -c) - echo -e "重置登录错误次数成功 \n $auth_value" >>$log_path echo "$auth_value" >$file_auth_user + echo -e "重置登录错误次数成功" $cmd ;; resettfa) auth_value=$(cat $file_auth_user | jq '.twoFactorActivated =false' | jq '.twoFactorActived =false' -c) - echo -e "禁用两步验证成功 \n $auth_value" >>$log_path echo "$auth_value" >$file_auth_user + eval echo -e "禁用两步验证成功" $cmd ;; *) eval echo -e "命令输入错误...\\\n" $cmd @@ -502,11 +510,16 @@ main() { ;; esac + local etime=$(date "+$time_format") + local end_time=$(format_time "$time_format" "$etime") + local end_timestamp=$(format_timestamp "$time_format" "$etime") + local diff_time=$(($end_timestamp - $begin_timestamp)) + eval echo -e "\\\n\#\# 执行结束... $end_time 耗时 $diff_time 秒" $cmd + + [[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time" + eval echo -e "\\\n          " $cmd + if [[ -f $file_path ]]; then - local end_timestamp=$(date "+%s") - local diff_time=$(($end_timestamp - $begin_timestamp)) - [[ $ID ]] && update_cron "\"$ID\"" "1" "" "$log_path" "$begin_timestamp" "$diff_time" - eval echo -e "\\\n          " $cmd cat $file_path fi }