From 4abefccc5b50b83601b017564abb13c4ed891fd9 Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 12 May 2021 22:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E6=97=B6=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=A4=9A=E4=B8=AAql=20repo=E5=91=BD=E4=BB=A4=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E6=AF=94=E5=AF=B9=E9=94=99=E8=AF=AF=EF=BC=8C=E7=8B=AC?= =?UTF-8?q?=E7=AB=8Bql=20extra=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 8 ++++++-- shell/update.sh | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index 5742aa1c..fcd2e582 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -57,7 +57,7 @@ export default class CronService { const tab = new Crontab({ ...doc, ...other }); tab.saved = false; const newDoc = await this.updateDb(tab); - await this.set_crontab(); + await this.set_crontab(this.isSixCron(newDoc)); return newDoc; } @@ -99,6 +99,9 @@ export default class CronService { { command: reg, }, + { + schedule: reg, + }, ], }; } @@ -214,7 +217,7 @@ export default class CronService { { $set: { status: CrontabStatus.disabled } }, { multi: true }, ); - await this.set_crontab(); + await this.set_crontab(true); } public async enabled(ids: string[]) { @@ -223,6 +226,7 @@ export default class CronService { { $set: { status: CrontabStatus.idle } }, { multi: true }, ); + await this.set_crontab(true); } public async log(_id: string) { diff --git a/shell/update.sh b/shell/update.sh index d3aced82..98119f6e 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -223,7 +223,8 @@ run_extra_shell() { ## 脚本用法 usage() { echo -e "本脚本用法:" - echo -e "1. $cmd_update update # 更新青龙,并且运行extra.sh" + echo -e "1. $cmd_update update # 更新并重启青龙" + echo -e "1. $cmd_update extra # 运行自定义脚本" echo -e "3. $cmd_update raw # 更新单个脚本文件" echo -e "4. $cmd_update repo # 更新单个仓库的脚本" echo -e "5. $cmd_update rmlog # 删除旧日志" @@ -266,18 +267,20 @@ update_qinglong() { ## 对比脚本 diff_scripts() { gen_list_repo $1 $2 $3 $4 $5 - diff_cron $list_own_scripts $list_own_user $list_own_add $list_own_drop + local list_add="$dir_list_tmp/${2}_add.list" + local list_drop="$dir_list_tmp/${2}_drop.list" + diff_cron "$dir_list_tmp/${2}_scripts.list" "$dir_list_tmp/${2}_user.list" $list_add $list_drop - if [ -s $list_own_drop ]; then - output_list_add_drop $list_own_drop "失效" + if [ -s $list_drop ]; then + output_list_add_drop $list_drop "失效" if [[ ${AutoDelCron} == true ]]; then - del_cron $list_own_drop $2 + del_cron $list_drop $2 fi fi - if [ -s $list_own_add ]; then - output_list_add_drop $list_own_add "新" + if [ -s $list_add ]; then + output_list_add_drop $list_add "新" if [[ ${AutoAddCron} == true ]]; then - add_cron $list_own_add $2 + add_cron $list_add $2 fi fi } @@ -306,9 +309,9 @@ gen_list_repo() { for file in ${files}; do filename=$(basename $file) cp -f $file $dir_scripts/${author}_${filename} - echo ${author}_${filename} >>$list_own_scripts + echo ${author}_${filename} >>"$dir_list_tmp/${author}_scripts.list" done - grep -E "$cmd_task $author" $list_crontab_user | perl -pe "s|.*ID=(.*) $cmd_task ($author_.*)\.*|\2|" | awk -F " " '{print $1}' | sort -u >$list_own_user + grep -E "$cmd_task $author" $list_crontab_user | perl -pe "s|.*ID=(.*) $cmd_task ($author_.*)\.*|\2|" | awk -F " " '{print $1}' | sort -u >"$dir_list_tmp/${author}_user.list" cd $dir_current } @@ -323,6 +326,8 @@ main() { case $p1 in update) update_qinglong | tee $log_path + ;; + extra) run_extra_shell | tee -a $log_path ;; repo)