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 #判断为空则返回