From de02f653ea47979274a1fd2749c5000dde34c690 Mon Sep 17 00:00:00 2001 From: juewuy Date: Thu, 4 Jan 2024 19:39:45 +0800 Subject: [PATCH] =?UTF-8?q?v1.8.3b=20~=E8=BF=90=E8=A1=8C=E5=90=8E=E6=AF=8F?= =?UTF-8?q?=E5=88=86=E9=92=9F=E6=89=A7=E8=A1=8C=E7=9A=84=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=89=E5=B0=8F=E6=97=B6=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=20~=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=97=A0=E6=B3=95=E5=85=B3=E9=97=AD=E7=9A=84?= =?UTF-8?q?bug=20~=E4=BF=AE=E5=A4=8D=E5=8D=8E=E7=A1=95/Padavan=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E5=90=8E=E6=89=BE=E4=B8=8D=E5=88=B0crash=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E7=9A=84bug=20~=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/clash.sh | 6 +++--- scripts/start.sh | 10 +++++----- scripts/task.sh | 24 +++++++++++++++++------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/scripts/clash.sh b/scripts/clash.sh index ff8b305..05d5a68 100644 --- a/scripts/clash.sh +++ b/scripts/clash.sh @@ -199,7 +199,7 @@ log_pusher(){ #日志菜单 [ -n "$push_Deer" ] && stat_Deer=32m已启用 || stat_Deer=33m未启用 [ -n "$push_bark" ] && stat_bark=32m已启用 || stat_bark=33m未启用 [ -n "$push_Po" ] && stat_Po=32m已启用 || stat_Po=33m未启用 - [ -n "$task_push" ] && task_push=32m已启用 || task_push=33m未启用 + [ "$task_push" = 1 ] && stat_task=32m已启用 || stat_task=33m未启用 [ -n "$device_name" ] && device_s=32m$device_name || device_s=33m未设置 echo ----------------------------------------------- echo -e " 1 查看\033[36m运行日志\033[0m" @@ -207,7 +207,7 @@ log_pusher(){ #日志菜单 echo -e " 3 PushDeer推送 ——\033[$stat_Deer\033[0m" echo -e " 4 Bark推送-IOS ——\033[$stat_bark\033[0m" echo -e " 5 Passover推送 ——\033[$stat_Po\033[0m" - echo -e " 6 推送任务日志 ——\033[$task_push\033[0m" + echo -e " 6 推送任务日志 ——\033[$stat_task\033[0m" echo -e " 8 设置设备名称 ——\033[$device_s\033[0m" echo -e " 9 清空日志文件" echo ----------------------------------------------- @@ -369,7 +369,7 @@ log_pusher(){ #日志菜单 log_pusher ;; 6) - [ "$task_push" = 1 ] && task_push= || task_push=1 + [ "$task_push" = 1 ] && task_push='' || task_push=1 setconfig task_push $task_push sleep 1 log_pusher diff --git a/scripts/start.sh b/scripts/start.sh index c2a16e0..1983e2d 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -136,7 +136,7 @@ put_save(){ fi } mark_time(){ - echo `date +%s` > $TMPDIR/clash_start_time + echo `date +%s` > $TMPDIR/crash_start_time } getlanip(){ i=1 @@ -1270,7 +1270,7 @@ afstart(){ #读取配置文件 getconfig #延迟启动 - [ ! -f $TMPDIR/clash_start_time ] && [ -n "$start_delay" ] && [ "$start_delay" -gt 0 ] && { + [ ! -f $TMPDIR/crash_start_time ] && [ -n "$start_delay" ] && [ "$start_delay" -gt 0 ] && { logger "clash将延迟$start_delay秒启动" 31 pushoff sleep $start_delay } @@ -1418,11 +1418,11 @@ init) profile=$(cat /etc/profile | grep -oE '\-f.*jffs.*profile' | awk '{print $2}') fi fi - sed -i "/alias clash/d" $profile + sed -i "/alias crash/d" $profile sed -i "/export CRASHDIR/d" $profile - echo "alias clash=\"$CRASHDIR/clash.sh\"" >> $profile + echo "alias crash=\"$CRASHDIR/clash.sh\"" >> $profile echo "export CRASHDIR=\"$CRASHDIR\"" >> $profile - [ -f $CRASHDIR/.dis_startup ] && cronset "clash保守模式守护进程" || $0 start + [ -f $CRASHDIR/.dis_startup ] && cronset "保守模式守护进程" || $0 start ;; getyaml) getconfig diff --git a/scripts/task.sh b/scripts/task.sh index aea937e..650dd1a 100644 --- a/scripts/task.sh +++ b/scripts/task.sh @@ -163,12 +163,13 @@ set_cron(){ sleep 1 } set_service(){ - # 参数1代表要任务类型,参数2代表任务ID,参数3代表任务描述,参数4代表running任务运行间隔 + # 参数1代表要任务类型,参数2代表任务ID,参数3代表任务描述,参数4代表running任务cron时间 task_file=$CRASHDIR/task/$1 [ -s $task_file ] && sed -i "/$3/d" $task_file + #运行时每分钟执行的任务特殊处理 if [ "$1" = "running" ];then - task_txt="$4 * * * * $CRASHDIR/task/task.sh $2 $3" - echo "$task_txt" >> $task_file #运行时每分钟执行的任务特殊处理 + task_txt="$4 $CRASHDIR/task/task.sh $2 $3" + echo "$task_txt" >> $task_file [ -n "$(pidof clash)" ] && cronset "$3" "$task_txt" else echo "$CRASHDIR/task/task.sh $2 $3" >> $task_file @@ -320,9 +321,18 @@ task_type(){ #任务条件选择菜单 7) echo ----------------------------------------------- echo -e " 输入10即每隔10分钟运行一次,1440即每隔24小时运行一次" - read -p "想每隔多少分钟执行一次?(整数) > " num - min="*/$num" - set_service running "$task_id" "运行时每$num分钟$task_name" "$min" + echo -e " 大于60分钟的数值将按小时取整" + read -p "想每隔多少分钟执行一次?(1-1440的整数) > " num + if [ "$num" -lt 60 ];then + min="$num" + cron_time="*/$min * * * *" + time_des="$min分钟" + else + hour="$((num / 60))" + cron_time="* */$hour * * *" + time_des="$hour小时" + fi + set_service running "$task_id" "运行时每$time_des$task_name" "$cron_time" ;; 8) echo -e "该功能会将相关启动代码注入到/etc/init.d/firewall中" @@ -339,7 +349,7 @@ task_manager(){ #任务管理列表 echo ----------------------------------------------- #抽取并生成临时列表 croncmd -l > $TMPDIR/task_cronlist - cat $TMPDIR/task_cronlist $CRASHDIR/task/running | sort -u | grep -oE "task/task.sh .*" | awk -F ' ' '{print $2" "$3}' > $TMPDIR/task_list + cat $TMPDIR/task_cronlist $CRASHDIR/task/running 2>/dev/null | sort -u | grep -oE "task/task.sh .*" | awk -F ' ' '{print $2" "$3}' > $TMPDIR/task_list cat $CRASHDIR/task/bfstart $CRASHDIR/task/afstart $CRASHDIR/task/affirewall 2>/dev/null | awk -F ' ' '{print $2" "$3}' >> $TMPDIR/task_list rm -rf $TMPDIR/task_cronlist #判断为空则返回