diff --git a/scripts/clash.sh b/scripts/clash.sh index 57e846e..6b75c1a 100644 --- a/scripts/clash.sh +++ b/scripts/clash.sh @@ -525,6 +525,83 @@ else fi exit; } +clashcron(){ + + setcron(){ + echo ----------------------------------------------- + echo -e " 输入 1-7 对应\033[36m每周相应天\033[0m运行" + echo -e " 输入 8 设为\033[36m每天定时\033[0m运行" + echo -e " 输入 1,3,6 代表\033[36m每周1,3,6\033[0m运行(注意小写逗号分隔)" + echo -e " 输入 0 返回上级菜单" + read -p "请输入对应数字 > " num + if [ -z $num ]; then + echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + echo -e "\033[31m请输入正确的数字!\033[0m" + setcron + elif [[ $num == 0 ]]; then + clashcron + elif [[ $num == 8 ]]; then + week='*' + echo 已设为每天定时运行! + else + week=$num + echo 已设为每周 $num 运行! + fi + #设置具体时间 + echo ----------------------------------------------- + read -p "请输入小时(0-24) > " num + if [ -z $num ]; then + echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + echo -e "\033[31m请输入正确的数字!\033[0m" + setcron + else + hour=$num + fi + echo ----------------------------------------------- + read -p "请输入分钟(0-60) > " num + if [ -z $num ]; then + echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + echo -e "\033[31m请输入正确的数字!\033[0m" + setcron + else + min=$num + fi + echo ----------------------------------------------- + echo 设定为:每周$week的$hour点$min,$cronname + read -p "是否确认添加?(1/0) > " res + + } +echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +echo -e "\033[30;47m欢迎使用定时任务功能:\033[0m" +echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m" +echo ----------------------------------------------- +echo -e " 1 设置\033[36m定时重启\033[0mclash服务" +echo -e " 2 设置\033[36m定时关闭\033[0mclash服务" +echo -e " 3 设置\033[36m定时开启\033[0mclash服务" +echo -e " 4 设置\033[36m定时更新\033[0m订阅链接" +echo -e " 0 返回上级菜单" +read -p "请输入对应数字 > " num +if [ -z $num ]; then + echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + echo -e "\033[31m请输入正确的数字!\033[0m" + clashsh + +elif [[ $num == 0 ]]; then + clashsh + +elif [[ $num == 1 ]]; then + cronname=重启clash服务 + cronset='/etc/init.d/clash restart' + + + + + + + +fi +} + clashsh(){ ############################# getconfig