9 Commits

Author SHA1 Message Date
juewuy
2a60440585 修复bug 2020-08-14 14:56:38 +08:00
juewuy
11e0231506 Merge branch 'master' of https://github.com/juewuy/clash-for-Miwifi 2020-08-13 23:02:16 +08:00
juewuy
0f58916149 v0.9.0
~新增定时任务功能(实验性,欢迎测试)
~修复测试命令时一个报错的小bug
~安装本地面板增加自动挂载/www目录
2020-08-13 23:02:02 +08:00
juewuy
74ba7e2fb7 Update README.md 2020-08-13 22:47:47 +08:00
juewuy
2dee375ac0 Update README.md 2020-08-13 22:46:47 +08:00
juewuy
a0cd5c1b1f Update README.md 2020-08-13 22:46:26 +08:00
juewuy
2ed3c33b24 修改安装源 2020-08-13 22:43:17 +08:00
juewuy
2026fe5adc v0.9.0
~新增定时任务功能(实验性,欢迎测试)
~修复测试命令时一个报错的小bug
2020-08-13 22:38:51 +08:00
juewuy
0e442ce5ad 增加定时任务功能 2020-08-13 19:15:43 +08:00
7 changed files with 154 additions and 20 deletions

View File

@@ -14,6 +14,10 @@
更新日志:
--
* v0.9.0<br>
~新增定时任务功能(实验性,欢迎测试)<br>
~修复测试命令时一个报错的小bug<br>
* v0.8.7<br>
~修复了脚本更新路径不正确的bug<br>
~调整了geoip数据库下载源地址<br>
@@ -61,7 +65,9 @@ ToDo
~~增加屏蔽P2P流量功能~~<br>
~~增加更新功能~~<br>
~~修复redir-host DNS以及IPV6支持~~<br>
~增加定时功能<br>
~~增加定时功能~~<br>
~增加屏蔽局域网设备<br>
~增加更多设备支持<br>
感谢:
--

Binary file not shown.

View File

@@ -1 +1 @@
versionsh=0.8.7
versionsh=0.9.0

View File

@@ -59,7 +59,7 @@ fi
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始解压文件!
mkdir -p $dir/clash > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/ > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#初始化文件目录
mv $dir/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录

View File

@@ -7,7 +7,7 @@ echo "** Clash for Miwifi **"
echo "** by Juewuy **"
echo "***********************************************"
url="https://juewuy.xyz/clash/"
url="https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi/"
result=$(curl -w %{http_code} -skLo /tmp/clashversion $url/bin/version)
[ "$result" != "200" ] && echo "无法连接到服务器!" && exit 1
source /tmp/clashversion
@@ -59,7 +59,7 @@ fi
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始解压文件!
mkdir -p $dir/clash > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/ > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#初始化文件目录
mv $dir/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录

View File

@@ -3,7 +3,7 @@
getconfig(){
#版本号
versionsh_l=0.8.7
versionsh_l=0.9.0
#服务器地址
if [ -z $update_url ]; then
update_url=https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi/
@@ -120,7 +120,6 @@ echo -e " 3 选取\033[33m代理规则\033[0m模版"
echo -e " 4 选择配置生成服务器"
echo -e " 5 \033[36m还原\033[0m配置文件"
echo -e " 6 \033[32m手动更新\033[0m订阅"
echo -e " 7 设置自动更新(未完成)"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z $num ];then
@@ -525,6 +524,136 @@ else
fi
exit;
}
clashcron(){
setcron(){
echo -----------------------------------------------
echo -e " 正在设置:\033[32m$cronname\033[0m定时任务"
echo -e " 输入 1-7 对应\033[33m每周相应天\033[0m运行"
echo -e " 输入 8 设为\033[33m每天定时\033[0m运行"
echo -e " 输入 1,3,6 代表\033[36m每周1,3,6\033[0m运行(注意用小写逗号分隔)"
echo -e " 输入 9 \033[31m删除定时任务\033[0m"
echo -e " 输入 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z $num ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashcron
elif [[ $num == 0 ]]; then
clashcron
elif [[ $num == 9 ]]; then
sed -i /$cronname/d $cronpath
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m定时任务$cronname已删除\033[0m"
clashcron
elif [[ $num == 8 ]]; then
week='*'
week1=每天
echo 已设为每天定时运行!
else
week=$num
week1=每周$week
echo 已设为每周 $num 运行!
fi
#设置具体时间
echo -----------------------------------------------
read -p "请输入小时0-23 > " num
if [ -z $num ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
setcron
elif [ $num -gt 23 ] || [ $num -lt 0 ]; 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
elif [ $num -gt 60 ] || [ $num -lt 0 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
setcron
else
min=$num
fi
echo -----------------------------------------------
echo 将在$week1的$hour点$min分$cronname(旧的任务会被覆盖)
read -p "是否确认添加定时任务?(1/0) > " res
if [ "$res" = '1' ]; then
sed -i /$cronname/d $cronpath
echo "$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname" >> $cronpath
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m定时任务已添加\033[0m"
fi
clashcron
}
checkcron(){
if [ -d /etc/crontabs/ ]; then
cronpath="/etc/crontabs/root"
elif [ -d /var/spool/cron/ ]; then
cronpath="/var/spool/cron/root"
elif [ -d /var/spool/cron/crontabs/ ]; then
cronpath="/var/spool/cron/crontabs/root"
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "找不到定时任务文件,无法添加定时任务!"
clashsh
fi
}
#定时任务菜单
checkcron #检测定时任务文件
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m欢迎使用定时任务功能\033[0m"
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -----------------------------------------------
echo -e "\033[33m当前已经添加的定时任务有\033[36m"
crontab -l | egrep -o '#.*'
echo -e "\033[0m"-----------------------------------------------
echo -e " 1 设置\033[33m定时重启\033[0mclash服务"
echo -e " 2 设置\033[31m定时停止\033[0mclash服务"
echo -e " 3 设置\033[32m定时开启\033[0mclash服务"
echo -e " 4 设置\033[33m定时更新\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'
setcron
elif [[ $num == 2 ]]; then
cronname=停止clash服务
cronset='/etc/init.d/clash stop'
setcron
elif [[ $num == 3 ]]; then
cronname=开启clash服务
cronset='/etc/init.d/clash start'
setcron
elif [[ $num == 4 ]]; then
cronname=更新订阅链接
cronset="source /etc/profile && source $clashdir/getdate.sh && getyaml"
setcron
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashsh
fi
}
clashsh(){
#############################
getconfig
@@ -533,7 +662,7 @@ echo -e " 1 \033[32m启动/重启\033[0mclash服务"
echo -e " 2 clash\033[33m高级设置\033[0m"
echo -e " 3 \033[31m停止\033[0mclash服务"
echo -e " 4 $auto1"
echo -e " 5 设置定时任务(施工中)"
echo -e " 5 设置定时任务"
echo -e " 6 导入\033[32m节点/订阅\033[0m链接"
echo -e " 8 \033[35m测试菜单\033[0m"
echo -e " 9 \033[36m更新/卸载\033[0m"
@@ -579,14 +708,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
clashsh
elif [[ $num == 5 ]]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m正在施工中敬请期待\033[0m"
echo -e "\033[32m正在施工中敬请期待\033[0m"
echo -e "\033[33m正在施工中敬请期待\033[0m"
echo -e "\033[34m正在施工中敬请期待\033[0m"
echo -e "\033[35m正在施工中敬请期待\033[0m"
echo -e "\033[36m正在施工中敬请期待\033[0m"
clashsh
clashcron
elif [[ $num == 6 ]]; then
clashlink
@@ -611,7 +733,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
elif [[ $num == 0 ]]; then
clashsh
elif [[ $num == 1 ]]; then
etc/init.d/clash stop
/etc/init.d/clash stop
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"
$clashdir/clash -d $clashdir & { sleep 3 ; kill $! & }
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"

View File

@@ -2,6 +2,7 @@
# Copyright (C) Juewuy
getyaml(){
ccfg=$clashdir/mark
source $ccfg
#前后端订阅服务器地址索引,可在此处添加!
Server=`sed -n ""$server_link"p"<<EOF
@@ -36,6 +37,7 @@ echo -e "| 需要一点时间,请耐心等待! |"
echo -e "| \033[0m如长时间没有数据请用ctrl+c退出\033[36m |"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0m"
#获取在线yaml文件
yaml=$clashdir/config.yaml
yamlnew=$yaml.new
rm -rf $yamlnew > /dev/null 2>&1
result=$(curl -w %{http_code} -kLo $yamlnew $Https)
@@ -58,7 +60,7 @@ if [ "$result" != "200" ];then
sed -i "1i\server_link=$server_link" $ccfg
getyaml
fi
exit;
#exit;
fi
else
if cat $yamlnew | grep ', server:' >/dev/null;then
@@ -103,9 +105,9 @@ else
echo -e "\033[33m请检查如上配置文件信息:\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fi
exit;
#exit;
fi
exit
#exit
}
getlink(){
#设置输入循环
@@ -425,6 +427,10 @@ if [ "$res" = '1' ]; then
getdb
else
echo -e "\033[33m下载成功正在解压文件\033[0m"
if cat /proc/mounts | grep -q www ;then
echo 检测到/www为只读正在重新挂载
mount -o remount -rw /www
fi
mkdir -p /www/clash > /dev/null
tar -zxvf '/tmp/clashdb.tar.gz' -C /www/clash > /dev/null
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1