2020-09-13 19:33:39 +08:00
|
|
|
|
#!/bin/bash
|
2020-08-06 17:20:45 +08:00
|
|
|
|
# Copyright (C) Juewuy
|
|
|
|
|
|
2020-10-28 11:09:26 +08:00
|
|
|
|
#导入订阅、配置文件相关
|
2020-08-24 19:39:50 +08:00
|
|
|
|
linkconfig(){
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo 当前使用规则为:$rule_link
|
|
|
|
|
echo 1 ACL4SSR通用版无去广告(推荐)
|
|
|
|
|
echo 2 ACL4SSR精简全能版(推荐)
|
|
|
|
|
echo 3 ACL4SSR通用版+去广告加强
|
|
|
|
|
echo 4 ACL4SSR精简版+去广告加强
|
|
|
|
|
echo 5 ACL4SSR重度全分组+奈飞分流
|
|
|
|
|
echo 6 ACL4SSR重度全分组+去广告加强
|
|
|
|
|
echo 7 洞主规则精简版(推荐)
|
|
|
|
|
echo 8 洞主规则重度完整版
|
|
|
|
|
echo 9 神机规则高级版
|
|
|
|
|
echo 10 神机规则-回国专用
|
|
|
|
|
echo 11 李哥规则-墙洞专用
|
|
|
|
|
echo 12 基础规则-仅Geoip CN+Final
|
|
|
|
|
echo 13 网易云解锁-仅规则分组
|
2021-02-08 16:01:22 +08:00
|
|
|
|
echo 14 ACL4SSR重度全分组+谷歌优化
|
2021-04-19 12:10:09 +08:00
|
|
|
|
echo 15 ACL4SSR通用版+LM-Firefly游戏规则
|
|
|
|
|
echo 16 ACL4SSR精简版+LM-Firefly游戏规则
|
|
|
|
|
echo 17 ACL4SSR重度+LM-Firefly游戏规则
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo 0 返回上级菜单
|
|
|
|
|
read -p "请输入对应数字 > " num
|
2021-04-28 15:11:39 +08:00
|
|
|
|
if [ -z "$num" ] || [ "$num" -gt 17 ];then
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 0 ];then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo
|
2021-04-19 12:10:09 +08:00
|
|
|
|
elif [ "$num" -le 17 ];then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
#将对应标记值写入mark
|
|
|
|
|
rule_link=$num
|
2020-10-27 09:40:58 +08:00
|
|
|
|
setconfig rule_link $rule_link
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[32m设置成功!返回上级菜单\033[0m"
|
|
|
|
|
fi
|
2020-08-24 19:39:50 +08:00
|
|
|
|
}
|
|
|
|
|
linkserver(){
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "\033[36m以下为互联网采集的第三方服务器,具体安全性请自行斟酌!\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo 当前使用后端为:$server_link
|
|
|
|
|
echo 1 subcon.dlj.tf
|
2021-04-19 12:10:09 +08:00
|
|
|
|
echo 2 api.dler.io
|
|
|
|
|
echo 3 api.wcc.best
|
2021-12-20 20:33:31 +08:00
|
|
|
|
echo 4 sub.id9.cc
|
|
|
|
|
echo 5 sub.shellclash.ga
|
2020-08-24 19:39:50 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo 0 返回上级菜单
|
|
|
|
|
read -p "请输入对应数字 > " num
|
2020-10-23 19:08:35 +08:00
|
|
|
|
if [ -z "$num" ] || [ "$num" -gt 5 ];then
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 0 ];then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" -le 5 ];then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
#将对应标记值写入mark
|
|
|
|
|
server_link=$num
|
2020-10-27 09:40:58 +08:00
|
|
|
|
setconfig server_link $server_link
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[32m设置成功!返回上级菜单\033[0m"
|
|
|
|
|
fi
|
2020-10-14 17:22:13 +08:00
|
|
|
|
}
|
2020-10-23 07:23:38 +08:00
|
|
|
|
linkfilter(){
|
|
|
|
|
[ -z "$exclude" ] && exclude="未设置"
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
|
|
|
|
echo -e "\033[33m当前过滤关键字:\033[47;30m$exclude\033[0m"
|
2020-08-24 19:39:50 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[33m匹配关键字的节点会在导入时被【屏蔽】!!!\033[0m"
|
|
|
|
|
echo -e "多个关键字可以用\033[30;47m | \033[0m号分隔"
|
|
|
|
|
echo -e "\033[32m支持正则表达式\033[0m,空格请使用\033[30;47m + \033[0m号替代"
|
2020-09-08 18:12:18 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e " 000 \033[31m删除\033[0m关键字"
|
|
|
|
|
echo -e " 回车 取消输入并返回上级菜单"
|
2020-08-24 19:39:50 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
read -p "请输入关键字 > " exclude
|
2020-12-11 22:17:29 +08:00
|
|
|
|
if [ "$exclude" = '000' ]; then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
exclude=''
|
|
|
|
|
echo -e "\033[31m 已删除节点过滤关键字!!!\033[0m"
|
2020-08-24 19:39:50 +08:00
|
|
|
|
fi
|
2020-10-27 09:40:58 +08:00
|
|
|
|
setconfig exclude \'$exclude\'
|
2020-08-24 19:39:50 +08:00
|
|
|
|
}
|
2020-10-23 07:23:38 +08:00
|
|
|
|
linkfilter2(){
|
|
|
|
|
[ -z "$include" ] && include="未设置"
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
|
|
|
|
echo -e "\033[33m当前筛选关键字:\033[47;30m$include\033[0m"
|
2020-08-09 13:51:37 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[33m仅有匹配关键字的节点才会被【导入】!!!\033[0m"
|
|
|
|
|
echo -e "多个关键字可以用\033[30;47m | \033[0m号分隔"
|
|
|
|
|
echo -e "\033[32m支持正则表达式\033[0m,空格请使用\033[30;47m + \033[0m号替代"
|
2020-08-18 20:30:05 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e " 000 \033[31m删除\033[0m关键字"
|
|
|
|
|
echo -e " 回车 取消输入并返回上级菜单"
|
2020-08-09 13:51:37 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
read -p "请输入关键字 > " include
|
2020-12-11 22:17:29 +08:00
|
|
|
|
if [ "$include" = '000' ]; then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
include=''
|
|
|
|
|
echo -e "\033[31m 已删除节点匹配关键字!!!\033[0m"
|
2020-08-06 17:20:45 +08:00
|
|
|
|
fi
|
2020-10-27 09:40:58 +08:00
|
|
|
|
setconfig include \'$include\'
|
2020-10-23 07:23:38 +08:00
|
|
|
|
}
|
2020-12-11 22:17:29 +08:00
|
|
|
|
getyaml(){
|
|
|
|
|
$clashdir/start.sh getyaml
|
|
|
|
|
if [ "$?" = 0 ];then
|
|
|
|
|
if [ "$inuserguide" != 1 ];then
|
|
|
|
|
read -p "是否启动clash服务以使配置文件生效?(1/0) > " res
|
2020-12-13 12:39:25 +08:00
|
|
|
|
[ "$res" = 1 ] && clashstart || clashsh
|
|
|
|
|
exit;
|
2020-10-07 11:21:05 +08:00
|
|
|
|
fi
|
2020-10-23 07:23:38 +08:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
getlink(){
|
|
|
|
|
#设置输入循环
|
|
|
|
|
i=1
|
|
|
|
|
while [ $i -le 99 ]
|
|
|
|
|
do
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[44m 遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "\033[33m本功能依赖第三方在线subconverter服务实现,脚本本身不提供任何代理服务!\033[0m"
|
|
|
|
|
echo -e "\033[31m严禁使用本脚本从事任何非法活动,否则一切后果请自负!\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "支持批量(<=99)导入订阅链接、分享链接"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e " 1 \033[36m开始生成配置文件\033[0m(原文件将被备份)"
|
|
|
|
|
echo -e " 2 设置\033[31m节点过滤\033[0m关键字 \033[47;30m$exclude\033[0m"
|
|
|
|
|
echo -e " 3 设置\033[32m节点筛选\033[0m关键字 \033[47;30m$include\033[0m"
|
|
|
|
|
echo -e " 4 选取在线\033[33m配置规则模版\033[0m"
|
|
|
|
|
echo -e " 5 \033[0m选取在线生成服务器\033[0m"
|
|
|
|
|
echo -e " 0 \033[31m撤销输入并返回上级菜单\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-13 12:39:25 +08:00
|
|
|
|
read -p "请直接输入第${i}个链接或对应数字选项 > " link
|
|
|
|
|
test=$(echo $link | grep "://")
|
|
|
|
|
link=`echo ${link/\ \(*\)/''}` #删除恶心的超链接内容
|
|
|
|
|
link=`echo ${link/*\&url\=/""}` #将clash完整链接还原成单一链接
|
|
|
|
|
link=`echo ${link/\&config\=*/""}` #将clash完整链接还原成单一链接
|
|
|
|
|
link=`echo ${link//\&/\%26}` #将分隔符 & 替换成urlcode:%26
|
2020-10-23 19:08:35 +08:00
|
|
|
|
if [ -n "$test" ];then
|
2020-12-13 12:39:25 +08:00
|
|
|
|
if [ -z "$Url_link" ];then
|
|
|
|
|
Url_link="$link"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
else
|
2020-12-13 12:39:25 +08:00
|
|
|
|
Url_link="$Url_link"\|"$link"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
fi
|
|
|
|
|
i=$((i+1))
|
2020-12-11 22:17:29 +08:00
|
|
|
|
|
2020-12-13 12:39:25 +08:00
|
|
|
|
elif [ "$link" = '1' ]; then
|
|
|
|
|
if [ -n "$Url_link" ];then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
i=100
|
|
|
|
|
#将用户链接写入mark
|
|
|
|
|
sed -i '/Https=*/'d $ccfg
|
2020-12-13 12:39:25 +08:00
|
|
|
|
setconfig Url \'$Url_link\'
|
2020-12-11 22:17:29 +08:00
|
|
|
|
Https=""
|
|
|
|
|
#获取在线yaml文件
|
|
|
|
|
getyaml
|
|
|
|
|
else
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[31m请先输入订阅或分享链接!\033[0m"
|
|
|
|
|
sleep 1
|
|
|
|
|
fi
|
|
|
|
|
|
2020-12-13 12:39:25 +08:00
|
|
|
|
elif [ "$link" = '2' ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
linkfilter
|
|
|
|
|
|
2020-12-13 12:39:25 +08:00
|
|
|
|
elif [ "$link" = '3' ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
linkfilter2
|
|
|
|
|
|
2020-12-13 12:39:25 +08:00
|
|
|
|
elif [ "$link" = '4' ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
linkconfig
|
|
|
|
|
|
2020-12-13 12:39:25 +08:00
|
|
|
|
elif [ "$link" = '5' ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
linkserver
|
|
|
|
|
|
2020-12-13 12:39:25 +08:00
|
|
|
|
elif [ "$link" = 0 ];then
|
|
|
|
|
Url_link=""
|
2020-12-12 10:27:03 +08:00
|
|
|
|
i=100
|
2020-12-11 22:17:29 +08:00
|
|
|
|
|
2020-10-23 07:23:38 +08:00
|
|
|
|
else
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "\033[31m请输入正确的链接或者数字!\033[0m"
|
|
|
|
|
sleep 1
|
2020-10-23 07:23:38 +08:00
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
getlink2(){
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[33m仅限导入完整clash配置文件链接!!!\033[0m"
|
2022-01-02 20:39:18 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[31m有流媒体需求,请使用\033[32m6-1在线生成配置文件功能!!!\033[0m"
|
|
|
|
|
echo -e "\033[31m如不了解机制,请使用\033[32m6-1在线生成配置文件功能!!!\033[0m"
|
|
|
|
|
echo -e "\033[31m如遇任何问题,请使用\033[32m6-1在线生成配置文件功能!!!\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[33m0 返回上级菜单\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
2020-12-13 12:39:25 +08:00
|
|
|
|
read -p "请输入完整链接 > " link
|
|
|
|
|
test=$(echo $link | grep -iE "tp.*://" )
|
|
|
|
|
link=`echo ${link/\ \(*\)/''}` #删除恶心的超链接内容
|
2021-06-17 20:08:04 +08:00
|
|
|
|
link=`echo ${link//\&/\%26}` #将分隔符 & 替换成urlcode:%26
|
2020-12-13 12:39:25 +08:00
|
|
|
|
if [ -n "$link" -a -n "$test" ];then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e 请检查输入的链接是否正确:
|
2020-12-13 12:39:25 +08:00
|
|
|
|
echo -e "\033[4;32m$link\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
read -p "确认导入配置文件?原配置文件将被更名为config.yaml.bak![1/0] > " res
|
|
|
|
|
if [ "$res" = '1' ]; then
|
|
|
|
|
#将用户链接写入mark
|
|
|
|
|
sed -i '/Url=*/'d $ccfg
|
2020-12-13 12:39:25 +08:00
|
|
|
|
setconfig Https \'$link\'
|
2020-10-23 07:23:38 +08:00
|
|
|
|
#获取在线yaml文件
|
2020-12-11 22:17:29 +08:00
|
|
|
|
getyaml
|
2020-12-13 12:39:25 +08:00
|
|
|
|
else
|
|
|
|
|
getlink2
|
2020-10-23 07:23:38 +08:00
|
|
|
|
fi
|
2020-12-13 12:39:25 +08:00
|
|
|
|
elif [ "$link" = 0 ];then
|
|
|
|
|
i=
|
2020-10-23 07:23:38 +08:00
|
|
|
|
else
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[31m请输入正确的配置文件链接地址!!!\033[0m"
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "\033[33m仅支持http、https、ftp以及ftps链接!\033[0m"
|
2020-12-12 10:27:03 +08:00
|
|
|
|
sleep 1
|
2020-12-13 12:39:25 +08:00
|
|
|
|
getlink2
|
2020-10-23 07:23:38 +08:00
|
|
|
|
fi
|
2020-08-06 17:20:45 +08:00
|
|
|
|
}
|
2020-10-23 19:08:35 +08:00
|
|
|
|
clashlink(){
|
2020-10-27 09:40:58 +08:00
|
|
|
|
[ -z "$rule_link" ] && rule_link=1
|
|
|
|
|
[ -z "$server_link" ] && server_link=1
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "\033[30;47m 欢迎使用导入配置文件功能!\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e " 1 在线\033[32m生成Clash配置文件\033[0m"
|
|
|
|
|
echo -e " 2 导入\033[33mClash配置文件链接\033[0m"
|
|
|
|
|
echo -e " 3 \033[36m还原\033[0m配置文件"
|
|
|
|
|
echo -e " 4 \033[33m更新\033[0m配置文件"
|
|
|
|
|
echo -e " 5 设置\033[36m自动更新\033[0m"
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
[ "$inuserguide" = 1 ] || echo -e " 0 返回上级菜单"
|
2020-10-23 19:08:35 +08:00
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ -z "$num" ];then
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-12-11 22:17:29 +08:00
|
|
|
|
elif [ "$num" = 0 ];then
|
|
|
|
|
i=
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 1 ];then
|
|
|
|
|
if [ -n "$Url" ];then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-13 12:39:25 +08:00
|
|
|
|
echo -e "\033[33m检测到已记录的链接内容:\033[0m"
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "\033[4;32m$Url\033[0m"
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
read -p "清空链接/追加导入?[1/0] > " res
|
|
|
|
|
if [ "$res" = '1' ]; then
|
2020-12-13 12:39:25 +08:00
|
|
|
|
Url_link=""
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "\033[31m链接已清空!\033[0m"
|
2020-12-13 12:39:25 +08:00
|
|
|
|
else
|
|
|
|
|
Url_link=$Url
|
2020-10-23 19:08:35 +08:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
getlink
|
|
|
|
|
|
|
|
|
|
elif [ "$num" = 2 ];then
|
|
|
|
|
getlink2
|
|
|
|
|
|
|
|
|
|
elif [ "$num" = 3 ];then
|
|
|
|
|
yamlbak=$yaml.bak
|
|
|
|
|
if [ ! -f "$yaml".bak ];then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "\033[31m没有找到配置文件的备份!\033[0m"
|
2020-12-12 10:27:03 +08:00
|
|
|
|
clashlink
|
2020-10-23 19:08:35 +08:00
|
|
|
|
else
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e 备份文件共有"\033[32m`wc -l < $yamlbak`\033[0m"行内容,当前文件共有"\033[32m`wc -l < $yaml`\033[0m"行内容
|
|
|
|
|
read -p "确认还原配置文件?此操作不可逆![1/0] > " res
|
|
|
|
|
if [ "$res" = '1' ]; then
|
|
|
|
|
mv $yamlbak $yaml
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "\033[32m配置文件已还原!请手动重启clash服务!\033[0m"
|
2020-12-12 10:27:03 +08:00
|
|
|
|
sleep 1
|
2020-10-23 19:08:35 +08:00
|
|
|
|
else
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "\033[31m操作已取消!返回上级菜单!\033[0m"
|
2020-12-12 10:27:03 +08:00
|
|
|
|
clashlink
|
2020-10-23 19:08:35 +08:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2020-12-11 22:17:29 +08:00
|
|
|
|
elif [ "$num" = 4 ];then
|
2020-10-23 19:08:35 +08:00
|
|
|
|
if [ -z "$Url" -a -z "$Https" ];then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "\033[31m没有找到你的配置文件/订阅链接!请先输入链接!\033[0m"
|
|
|
|
|
sleep 1
|
2020-10-23 19:08:35 +08:00
|
|
|
|
clashlink
|
|
|
|
|
else
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "\033[33m当前系统记录的链接为:\033[0m"
|
2020-11-15 13:01:29 +08:00
|
|
|
|
echo -e "\033[4;32m$Url$Https\033[0m"
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
read -p "确认更新配置文件?[1/0] > " res
|
|
|
|
|
if [ "$res" = '1' ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
getyaml
|
2020-12-12 10:27:03 +08:00
|
|
|
|
else
|
|
|
|
|
clashlink
|
2020-10-23 19:08:35 +08:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2020-12-11 22:17:29 +08:00
|
|
|
|
elif [ "$num" = 5 ];then
|
2020-10-23 19:08:35 +08:00
|
|
|
|
clashcron
|
|
|
|
|
else
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 19:08:35 +08:00
|
|
|
|
fi
|
|
|
|
|
}
|
2020-10-28 11:09:26 +08:00
|
|
|
|
#下载更新相关
|
2020-09-21 23:51:03 +08:00
|
|
|
|
gettar(){
|
2021-06-19 15:23:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/clashfm.tar.gz $tarurl
|
|
|
|
|
[ "$?" = "1" ] && echo "文件下载失败!" && exit 1
|
2021-07-11 01:03:43 +08:00
|
|
|
|
$clashdir/start.sh stop
|
2020-08-09 13:51:37 +08:00
|
|
|
|
#解压
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-08-09 13:51:37 +08:00
|
|
|
|
echo 开始解压文件!
|
2020-08-10 20:46:10 +08:00
|
|
|
|
mkdir -p $clashdir > /dev/null
|
2020-09-21 23:51:03 +08:00
|
|
|
|
tar -zxvf '/tmp/clashfm.tar.gz' -C $clashdir/
|
2020-10-28 13:49:45 +08:00
|
|
|
|
[ $? -ne 0 ] && echo "文件解压失败!" && rm -rf /tmp/clashfm.tar.gz && exit 1
|
2020-09-21 23:51:03 +08:00
|
|
|
|
#初始化文件目录
|
|
|
|
|
[ -f "$clashdir/mark" ] || echo '#标识clash运行状态的文件,不明勿动!' > $clashdir/mark
|
2020-09-18 21:09:06 +08:00
|
|
|
|
#判断系统类型写入不同的启动文件
|
2020-09-20 17:57:21 +08:00
|
|
|
|
if [ -f /etc/rc.common ];then
|
2020-09-21 23:51:03 +08:00
|
|
|
|
#设为init.d方式启动
|
|
|
|
|
mv $clashdir/clashservice /etc/init.d/clash
|
|
|
|
|
chmod 777 /etc/init.d/clash
|
2020-09-18 21:09:06 +08:00
|
|
|
|
else
|
2020-10-27 09:40:58 +08:00
|
|
|
|
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
|
|
|
|
|
[ -w /usr/lib/systemd/system ] && sysdir=/usr/lib/systemd/system
|
2020-09-20 17:57:21 +08:00
|
|
|
|
if [ -n "$sysdir" ];then
|
2020-09-21 23:51:03 +08:00
|
|
|
|
#设为systemd方式启动
|
|
|
|
|
mv $clashdir/clash.service $sysdir/clash.service
|
|
|
|
|
sed -i "s%/etc/clash%$clashdir%g" $sysdir/clash.service
|
|
|
|
|
systemctl daemon-reload
|
2020-09-20 17:57:21 +08:00
|
|
|
|
else
|
2020-09-21 23:51:03 +08:00
|
|
|
|
#设为保守模式启动
|
2020-09-20 17:57:21 +08:00
|
|
|
|
sed -i '/start_old=*/'d $clashdir/mark
|
2020-10-27 09:40:58 +08:00
|
|
|
|
echo start_old=已开启 >> $clashdir/mark
|
2020-09-20 17:57:21 +08:00
|
|
|
|
fi
|
2020-09-18 21:09:06 +08:00
|
|
|
|
fi
|
2020-09-19 16:46:22 +08:00
|
|
|
|
#修饰文件及版本号
|
2021-07-11 01:03:43 +08:00
|
|
|
|
shtype=sh && [ -n "$(ls -l /bin/sh|grep -oE 'dash|show|bash')" ] && shtype=bash
|
2021-03-19 22:03:09 +08:00
|
|
|
|
sed -i "s|/bin/sh|/bin/$shtype|" $clashdir/start.sh
|
2020-09-19 16:46:22 +08:00
|
|
|
|
chmod 777 $clashdir/start.sh
|
2020-09-21 23:51:03 +08:00
|
|
|
|
sed -i '/versionsh_l=*/'d $clashdir/mark
|
2020-10-27 09:40:58 +08:00
|
|
|
|
echo versionsh_l=$release_new >> $clashdir/mark
|
2021-06-05 19:17:26 +08:00
|
|
|
|
#设置环境变量
|
|
|
|
|
[ -w /opt/etc/profile ] && profile=/opt/etc/profile
|
|
|
|
|
[ -w /jffs/configs/profile.add ] && profile=/jffs/configs/profile.add
|
2020-10-24 21:13:06 +08:00
|
|
|
|
[ -w ~/.bashrc ] && profile=~/.bashrc
|
|
|
|
|
[ -w /etc/profile ] && profile=/etc/profile
|
2021-03-19 22:03:09 +08:00
|
|
|
|
if [ -n "$profile" ];then
|
|
|
|
|
sed -i '/alias clash=*/'d $profile
|
|
|
|
|
echo "alias clash=\"$shtype $clashdir/clash.sh\"" >> $profile #设置快捷命令环境变量
|
|
|
|
|
sed -i '/export clashdir=*/'d $profile
|
|
|
|
|
echo "export clashdir=\"$clashdir\"" >> $profile #设置clash路径环境变量
|
|
|
|
|
else
|
|
|
|
|
echo 无法写入环境变量!请检查安装权限!
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2021-06-05 19:17:26 +08:00
|
|
|
|
#华硕/Padavan额外设置
|
|
|
|
|
[ -n "$systype" ] && sed -i '/ShellClash初始化/'d $initdir && echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
2020-08-09 13:51:37 +08:00
|
|
|
|
#删除临时文件
|
|
|
|
|
rm -rf /tmp/clashfm.tar.gz
|
2020-09-21 23:51:03 +08:00
|
|
|
|
rm -rf $clashdir/clashservice
|
|
|
|
|
rm -rf $clashdir/clash.service
|
|
|
|
|
}
|
|
|
|
|
getsh(){
|
2020-08-09 13:51:37 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "当前脚本版本为:\033[33m $versionsh_l \033[0m"
|
|
|
|
|
echo -e "最新脚本版本为:\033[32m $release_new \033[0m"
|
2021-07-11 01:03:43 +08:00
|
|
|
|
echo -e "注意更新时会停止clash服务!"
|
2020-08-09 13:51:37 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
read -p "是否更新脚本?[1/0] > " res
|
|
|
|
|
if [ "$res" = '1' ]; then
|
|
|
|
|
tarurl=$update_url/bin/clashfm.tar.gz
|
|
|
|
|
#下载更新
|
|
|
|
|
gettar
|
|
|
|
|
#提示
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[32m管理脚本更新成功!\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
exit;
|
|
|
|
|
fi
|
2020-08-06 17:20:45 +08:00
|
|
|
|
}
|
2020-10-30 16:21:09 +08:00
|
|
|
|
getcpucore(){
|
|
|
|
|
cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
|
|
|
|
|
[ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="armv5"
|
|
|
|
|
[ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && cpucore="armv7"
|
|
|
|
|
[ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="armv8"
|
|
|
|
|
[ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="386"
|
|
|
|
|
[ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="amd64"
|
|
|
|
|
if [ -n "$(echo $cputype | grep -E "linux.*mips.*")" ];then
|
2020-12-13 21:22:41 +08:00
|
|
|
|
mipstype=$(echo -n I | hexdump -o 2>/dev/null | awk '{ print substr($2,6,1); exit}') #通过判断大小端判断mips或mipsle
|
|
|
|
|
[ "$mipstype" = "0" ] && cpucore="mips-softfloat" || cpucore="mipsle-softfloat"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
fi
|
|
|
|
|
[ -n "$cpucore" ] && setconfig cpucore $cpucore
|
|
|
|
|
}
|
2020-11-01 11:38:26 +08:00
|
|
|
|
setcpucore(){
|
2020-12-13 21:22:41 +08:00
|
|
|
|
cpucore_list="armv5 armv7 armv8 386 amd64 mipsle-softfloat mipsle-hardfloat mips-softfloat"
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[31m仅适合脚本无法正确识别核心或核心无法正常运行时使用!\033[0m"
|
|
|
|
|
echo -e "当前可供在线下载的处理器架构为:"
|
2020-12-13 21:22:41 +08:00
|
|
|
|
echo $cpucore_list | awk -F " " '{for(i=1;i<=NF;i++) {print i" "$i }}'
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -e "如果您的CPU架构未在以上列表中,请运行【uname -a】命令,并复制好返回信息"
|
|
|
|
|
echo -e "之后前往 t.me/clashfm 群提交或 github.com/juewuy/ShellClash 提交issue"
|
|
|
|
|
echo -----------------------------------------------
|
2020-12-13 21:22:41 +08:00
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
setcpucore=$(echo $cpucore_list | awk '{print $"'"$num"'"}' )
|
|
|
|
|
if [ -z "$setcpucore" ];then
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -e "\033[31m请输入正确的处理器架构!\033[0m"
|
|
|
|
|
sleep 1
|
|
|
|
|
cpucore=""
|
|
|
|
|
else
|
2020-12-13 21:22:41 +08:00
|
|
|
|
cpucore=$setcpucore
|
2020-11-01 11:38:26 +08:00
|
|
|
|
setconfig cpucore $cpucore
|
|
|
|
|
fi
|
|
|
|
|
}
|
2020-08-06 17:20:45 +08:00
|
|
|
|
getcore(){
|
2020-10-30 16:21:09 +08:00
|
|
|
|
[ -z "$clashcore" ] && clashcore=clashpre
|
|
|
|
|
[ -z "$cpucore" ] && getcpucore
|
|
|
|
|
#生成链接
|
|
|
|
|
corelink="$update_url/bin/$clashcore/clash-linux-$cpucore"
|
|
|
|
|
#获取在线clash核心文件
|
2020-12-13 16:40:19 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo 正在在线获取clash核心文件……
|
2021-06-19 15:23:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/clash.new $corelink
|
|
|
|
|
if [ "$?" = "1" ];then
|
2020-12-13 16:40:19 +08:00
|
|
|
|
echo -e "\033[31m核心文件下载失败!\033[0m"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
else
|
2020-12-13 16:40:19 +08:00
|
|
|
|
echo -e "\033[32m$clashcore核心下载成功!\033[0m"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
mv -f /tmp/clash.new $bindir/clash
|
2021-08-30 17:49:33 +08:00
|
|
|
|
chmod 777 $bindir/clash #授予权限
|
2020-12-13 16:40:19 +08:00
|
|
|
|
setconfig clashcore $clashcore
|
|
|
|
|
setconfig clashv $version
|
|
|
|
|
fi
|
2020-10-30 16:21:09 +08:00
|
|
|
|
}
|
|
|
|
|
setcore(){
|
2020-10-23 07:23:38 +08:00
|
|
|
|
#获取核心及版本信息
|
|
|
|
|
[ ! -f $clashdir/clash ] && clashcore="未安装核心"
|
|
|
|
|
###
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-30 16:21:09 +08:00
|
|
|
|
[ -z "$cpucore" ] && getcpucore
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "当前clash核心:\033[47;30m $clashcore \033[46;30m$clashv\033[0m"
|
|
|
|
|
echo -e "当前系统处理器架构:\033[32m $cpucore \033[0m"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
echo -e "\033[33m请选择需要使用的核心版本!\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo "1 clash: 稳定,内存占用小,推荐!"
|
|
|
|
|
echo "(官方正式版) 不支持Tun模式、混合模式"
|
|
|
|
|
echo
|
|
|
|
|
echo "2 clashpre: 支持Tun模式、混合模式"
|
|
|
|
|
echo "(高级预览版) 内存占用更高"
|
|
|
|
|
echo
|
2021-08-30 17:49:33 +08:00
|
|
|
|
echo "3 clash.net: 支持vless/xtls"
|
|
|
|
|
echo "(.net定制版) 未测试,可能不稳定"
|
|
|
|
|
echo
|
|
|
|
|
echo "4 手动指定处理器架构"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo 0 返回上级菜单
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ -z "$num" ]; then
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 0 ]; then
|
2020-12-13 16:40:19 +08:00
|
|
|
|
i=
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 1 ]; then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
clashcore=clash
|
|
|
|
|
version=$clash_v
|
2020-12-13 16:40:19 +08:00
|
|
|
|
getcore
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 2 ]; then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
clashcore=clashpre
|
|
|
|
|
version=$clashpre_v
|
2020-12-13 16:40:19 +08:00
|
|
|
|
getcore
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 3 ]; then
|
2021-08-30 17:49:33 +08:00
|
|
|
|
clashcore=clash.net
|
2021-08-30 18:00:09 +08:00
|
|
|
|
version=$clashnet_v
|
2021-08-30 17:49:33 +08:00
|
|
|
|
getcore
|
|
|
|
|
elif [ "$num" = 4 ]; then
|
2020-11-01 11:38:26 +08:00
|
|
|
|
setcpucore
|
2020-10-30 16:21:09 +08:00
|
|
|
|
setcore
|
2020-10-23 07:23:38 +08:00
|
|
|
|
else
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 07:23:38 +08:00
|
|
|
|
update
|
2020-10-14 17:22:13 +08:00
|
|
|
|
fi
|
2020-08-06 17:20:45 +08:00
|
|
|
|
}
|
|
|
|
|
getgeo(){
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo 正在从服务器获取数据库文件…………
|
2021-06-19 15:23:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/$geoname $update_url/bin/$geotype
|
|
|
|
|
if [ "$?" = "1" ];then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[31m文件下载失败!\033[0m"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
exit 1
|
|
|
|
|
else
|
2021-06-13 19:28:19 +08:00
|
|
|
|
mv -f /tmp/$geoname $bindir/$geoname
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2021-06-13 19:28:19 +08:00
|
|
|
|
echo -e "\033[32mGeoIP/CN_IP数据库文件下载成功!\033[0m"
|
2020-12-13 22:12:52 +08:00
|
|
|
|
Geo_v=$GeoIP_v
|
2020-12-11 22:17:29 +08:00
|
|
|
|
setconfig Geo_v $GeoIP_v
|
|
|
|
|
setconfig geotype $geotype
|
2020-08-07 19:18:14 +08:00
|
|
|
|
fi
|
|
|
|
|
}
|
2020-12-11 22:17:29 +08:00
|
|
|
|
setgeo(){
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
[ "$geotype" = "Country.mmdb" ] && geo_type=全球版 || geo_type=精简版
|
|
|
|
|
[ -n "$geo_type" ] && echo -e "当前使用的是\033[47;30m$geo_type数据库\033[0m"
|
2021-06-16 18:55:14 +08:00
|
|
|
|
echo -e "\033[36m请选择需要更新/切换的GeoIP/CN_IP数据库:\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
2021-12-18 20:14:03 +08:00
|
|
|
|
echo -e " 1 由\033[32malecthw\033[0m提供的全球版GeoIP数据库(约6mb)"
|
|
|
|
|
echo -e " 2 由\033[32mHackl0us\033[0m提供的精简版CN-IP数据库(约0.2mb)"
|
|
|
|
|
echo -e " 3 由\033[32m17mon\033[0m提供的CN-IP文件(需启用CN_IP绕过内核功能,约0.2mb)"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo " 0 返回上级菜单"
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
read -p "请输入对应数字 > " num
|
2020-12-11 22:17:29 +08:00
|
|
|
|
if [ "$num" = '1' ]; then
|
|
|
|
|
geotype=Country.mmdb
|
2021-06-13 19:28:19 +08:00
|
|
|
|
geoname=Country.mmdb
|
2020-12-11 22:17:29 +08:00
|
|
|
|
getgeo
|
2020-10-23 07:23:38 +08:00
|
|
|
|
elif [ "$num" = '2' ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
geotype=cn_mini.mmdb
|
2021-06-13 19:28:19 +08:00
|
|
|
|
geoname=Country.mmdb
|
|
|
|
|
getgeo
|
2021-06-16 18:55:14 +08:00
|
|
|
|
elif [ "$num" = '3' ]; then
|
|
|
|
|
if [ "$cn_ip_route" = "已开启" ]; then
|
|
|
|
|
geotype=china_ip_list.txt
|
|
|
|
|
geoname=cn_ip.txt
|
|
|
|
|
getgeo
|
|
|
|
|
else
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[31m未开启绕过内核功能,无需更新CN-IP文件!!\033[0m"
|
|
|
|
|
sleep 1
|
|
|
|
|
fi
|
2020-10-23 07:23:38 +08:00
|
|
|
|
else
|
|
|
|
|
update
|
2020-08-09 13:51:37 +08:00
|
|
|
|
fi
|
2020-12-11 22:17:29 +08:00
|
|
|
|
}
|
|
|
|
|
getdb(){
|
2020-11-22 15:40:31 +08:00
|
|
|
|
#下载及安装
|
|
|
|
|
if [ -d /www/clash -o -d $clashdir/ui ];then
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[31m检测到您已经安装过本地面板了!\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
read -p "是否覆盖安装?[1/0] > " res
|
2020-12-11 22:17:29 +08:00
|
|
|
|
if [ "$res" = 1 ]; then
|
2020-11-22 15:40:31 +08:00
|
|
|
|
rm -rf /www/clash
|
|
|
|
|
rm -rf $clashdir/ui
|
2022-01-02 23:38:35 +08:00
|
|
|
|
rm -rf $bindir/ui
|
2020-10-23 07:23:38 +08:00
|
|
|
|
fi
|
2020-11-22 15:40:31 +08:00
|
|
|
|
fi
|
|
|
|
|
dblink="${update_url}/bin/${db_type}.tar.gz"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo 正在连接服务器获取安装文件…………
|
2021-06-19 15:23:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/clashdb.tar.gz $dblink
|
|
|
|
|
if [ "$?" = "1" ];then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-11-22 15:40:31 +08:00
|
|
|
|
echo -e "\033[31m文件下载失败!\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
setdb
|
2020-11-22 15:40:31 +08:00
|
|
|
|
else
|
|
|
|
|
echo -e "\033[33m下载成功,正在解压文件!\033[0m"
|
|
|
|
|
mkdir -p $dbdir > /dev/null
|
|
|
|
|
tar -zxvf "/tmp/clashdb.tar.gz" -C $dbdir > /dev/null
|
2021-01-23 16:00:45 +08:00
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
|
tar -zxvf "/tmp/clashdb.tar.gz" --no-same-permissions -C $dbdir > /dev/null
|
|
|
|
|
[ $? -ne 0 ] && echo "文件解压失败!" && rm -rf /tmp/clashfm.tar.gz && exit 1
|
|
|
|
|
fi
|
2020-11-22 15:40:31 +08:00
|
|
|
|
#修改默认host和端口
|
|
|
|
|
if [ "$db_type" = "clashdb" ];then
|
2021-01-23 16:00:45 +08:00
|
|
|
|
sed -i "s/127.0.0.1/${host}/g" $dbdir/assets/*.js
|
|
|
|
|
sed -i "s/9090/${db_port}/g" $dbdir/assets/*.js
|
2020-10-23 07:23:38 +08:00
|
|
|
|
else
|
2021-03-13 19:08:47 +08:00
|
|
|
|
sed -i "s/127.0.0.1:9090/${host}:${db_port}/g" $dbdir/*.html
|
2020-11-22 15:40:31 +08:00
|
|
|
|
#sed -i "s/7892/${db_port}/g" $dbdir/app*.js
|
2020-10-23 07:23:38 +08:00
|
|
|
|
fi
|
2020-11-22 15:40:31 +08:00
|
|
|
|
#如果clash在运行则重启clash服务
|
|
|
|
|
[ "$dbdir" != "/www/clash" ] && [ -n "$PID" ] && $clashdir/start.sh restart
|
|
|
|
|
#写入配置文件
|
|
|
|
|
setconfig hostdir \'$hostdir\'
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[32m面板安装成功!\033[0m"
|
|
|
|
|
echo -e "\033[36m请使用\033[32;4mhttp://$host$hostdir\033[0;36m访问面板\033[0m"
|
|
|
|
|
rm -rf /tmp/clashdb.tar.gz
|
|
|
|
|
sleep 1
|
|
|
|
|
fi
|
2020-08-06 17:20:45 +08:00
|
|
|
|
}
|
2020-12-11 22:17:29 +08:00
|
|
|
|
setdb(){
|
|
|
|
|
dbdir(){
|
2020-12-11 22:26:07 +08:00
|
|
|
|
if [ -w /www -a -n "$(pidof nginx)" ];then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "请选择面板\033[33m安装目录:\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e " 1 在$clashdir/ui目录安装"
|
2021-01-29 15:11:35 +08:00
|
|
|
|
echo -e " 2 在/www/clash目录安装"
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo " 0 返回上级菜单"
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
|
|
|
|
|
if [ "$num" = '1' ]; then
|
|
|
|
|
dbdir=$clashdir/ui
|
|
|
|
|
hostdir=":$db_port/ui"
|
|
|
|
|
elif [ "$num" = '2' ]; then
|
|
|
|
|
dbdir=/www/clash
|
|
|
|
|
hostdir='/clash'
|
|
|
|
|
else
|
|
|
|
|
setdb
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
dbdir=$clashdir/ui
|
|
|
|
|
hostdir=":$db_port/ui"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-09 13:03:42 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "\033[36m安装本地版dashboard管理面板\033[0m"
|
|
|
|
|
echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m"
|
2020-12-09 13:03:42 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "请选择面板\033[33m安装类型:\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e " 1 安装\033[32m官方面板\033[0m(约500kb)"
|
|
|
|
|
echo -e " 2 安装\033[32mYacd面板\033[0m(约1.1mb)"
|
|
|
|
|
echo -e " 3 卸载\033[33m本地面板\033[0m"
|
|
|
|
|
echo " 0 返回上级菜单"
|
|
|
|
|
read -p "请输入对应数字 > " num
|
2020-12-09 13:03:42 +08:00
|
|
|
|
|
2020-12-11 22:17:29 +08:00
|
|
|
|
if [ "$num" = '1' ]; then
|
|
|
|
|
db_type=clashdb
|
|
|
|
|
dbdir
|
|
|
|
|
getdb
|
|
|
|
|
elif [ "$num" = '2' ]; then
|
|
|
|
|
db_type=yacd
|
|
|
|
|
dbdir
|
|
|
|
|
getdb
|
|
|
|
|
elif [ "$num" = '3' ]; then
|
|
|
|
|
read -p "确认卸载本地面板?(1/0) > " res
|
|
|
|
|
if [ "$res" = 1 ];then
|
|
|
|
|
rm -rf /www/clash
|
|
|
|
|
rm -rf $clashdir/ui
|
2022-01-02 23:38:35 +08:00
|
|
|
|
rm -rf $bindir/ui
|
2020-12-09 13:03:42 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e "\033[31m面板已经卸载!\033[0m"
|
2020-12-09 13:03:42 +08:00
|
|
|
|
sleep 1
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
errornum
|
|
|
|
|
fi
|
2020-12-11 22:17:29 +08:00
|
|
|
|
}
|
|
|
|
|
getcrt(){
|
2020-12-14 16:38:14 +08:00
|
|
|
|
crtlink="${update_url}/bin/ca-certificates.crt"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo 正在连接服务器获取安装文件…………
|
2021-06-19 15:23:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/ca-certificates.crt $crtlink
|
|
|
|
|
if [ "$?" = "1" ];then
|
2020-12-09 13:03:42 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-14 16:38:14 +08:00
|
|
|
|
echo -e "\033[31m文件下载失败!\033[0m"
|
|
|
|
|
else
|
2020-12-09 13:03:42 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-14 16:38:14 +08:00
|
|
|
|
mv -f /tmp/ca-certificates.crt $crtdir
|
2021-06-19 15:23:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/ssl_test https://baidu.com echooff rediron skipceroff
|
|
|
|
|
if [ "$?" = "1" ];then
|
2021-04-15 16:50:56 +08:00
|
|
|
|
export CURL_CA_BUNDLE=$crtdir
|
|
|
|
|
echo "export CURL_CA_BUNDLE=$crtdir" >> /etc/profile
|
|
|
|
|
fi
|
|
|
|
|
rm -rf /tmp/ssl_test
|
2020-12-14 16:38:14 +08:00
|
|
|
|
echo -e "\033[32m证书安装成功!\033[0m"
|
|
|
|
|
sleep 1
|
2020-12-09 13:03:42 +08:00
|
|
|
|
fi
|
|
|
|
|
}
|
2020-12-11 22:17:29 +08:00
|
|
|
|
setcrt(){
|
2020-12-18 12:58:41 +08:00
|
|
|
|
openssldir=$(openssl version -a 2>&1 | grep OPENSSLDIR | awk -F "\"" '{print $2}')
|
|
|
|
|
if [ -n "$openssldir" ];then
|
|
|
|
|
crtdir="$openssldir/certs/ca-certificates.crt"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[36m安装/更新本地根证书文件(ca-certificates.crt)\033[0m"
|
|
|
|
|
echo -e "\033[33m用于解决证书校验错误,x509报错等问题\033[0m"
|
2020-12-21 11:55:43 +08:00
|
|
|
|
echo -e "\033[31m无上述问题的设备请勿使用!\033[0m"
|
2020-12-18 12:58:41 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-21 11:55:43 +08:00
|
|
|
|
[ -f "$crtdir" ] && echo -e "\033[33m检测到系统已经安装根证书文件了!\033[0m\n-----------------------------------------------"
|
2020-12-18 12:58:41 +08:00
|
|
|
|
read -p "确认安装?(1/0) > " res
|
2020-12-11 22:17:29 +08:00
|
|
|
|
|
2020-12-18 12:58:41 +08:00
|
|
|
|
if [ -z "$res" ];then
|
|
|
|
|
errornum
|
|
|
|
|
elif [ "$res" = '0' ]; then
|
|
|
|
|
i=
|
|
|
|
|
elif [ "$res" = '1' ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
getcrt
|
|
|
|
|
else
|
2020-12-18 12:58:41 +08:00
|
|
|
|
errornum
|
2020-12-11 22:17:29 +08:00
|
|
|
|
fi
|
|
|
|
|
else
|
2020-12-18 12:58:41 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[33m设备可能尚未安装openssl,无法安装证书文件!\033[0m"
|
|
|
|
|
sleep 1
|
2020-12-11 22:17:29 +08:00
|
|
|
|
fi
|
|
|
|
|
}
|
2020-08-10 20:24:28 +08:00
|
|
|
|
setserver(){
|
2020-12-13 16:40:19 +08:00
|
|
|
|
saveserver(){
|
|
|
|
|
#写入mark文件
|
|
|
|
|
setconfig update_url \'$update_url\'
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[32m源地址更新成功!\033[0m"
|
|
|
|
|
release_new=""
|
|
|
|
|
}
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2021-06-20 21:43:41 +08:00
|
|
|
|
echo -e "\033[30;47m切换ShellClash版本及更新源地址\033[0m"
|
|
|
|
|
echo -e "当前源地址:\033[4;32m$update_url\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e " 1 \033[32m正式版\033[0m&Jsdelivr-CDN源(推荐)"
|
|
|
|
|
echo -e " 2 \033[36m测试版\033[0m&Jsdelivr-CDN源"
|
|
|
|
|
echo -e " 3 \033[36m测试版\033[0m&Github源(需开启clash服务)"
|
2021-12-20 20:33:31 +08:00
|
|
|
|
[ -z "$(curl -V 2>/dev/null)" ] && [ -n "$(wget -V 2>&1 | grep BusyBox)" ] && echo -e " 4 \033[33mHttp专用源\033[0m"
|
2021-06-20 21:43:41 +08:00
|
|
|
|
echo -e " 5 自定义源地址(用于本地源或自建源)"
|
|
|
|
|
echo -e " 6 \033[31m版本回退\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e " 0 返回上级菜单"
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ -z "$num" ]; then
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 1 ]; then
|
2021-06-20 21:43:41 +08:00
|
|
|
|
update_url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash'
|
2020-12-13 16:40:19 +08:00
|
|
|
|
saveserver
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 2 ]; then
|
2021-06-20 21:43:41 +08:00
|
|
|
|
update_url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master'
|
2020-12-13 16:40:19 +08:00
|
|
|
|
saveserver
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 3 ]; then
|
2020-10-24 09:54:14 +08:00
|
|
|
|
update_url='https://raw.githubusercontent.com/juewuy/ShellClash/master'
|
2020-12-13 16:40:19 +08:00
|
|
|
|
saveserver
|
2021-06-20 21:43:41 +08:00
|
|
|
|
elif [ "$num" = 4 ]; then
|
2021-12-20 20:33:31 +08:00
|
|
|
|
update_url='http://shellclash.ga'
|
2021-06-20 21:43:41 +08:00
|
|
|
|
saveserver
|
2020-10-24 09:54:14 +08:00
|
|
|
|
elif [ "$num" = 5 ]; then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
read -p "请输入个人源路径 > " update_url
|
|
|
|
|
if [ -z "$update_url" ];then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[31m取消输入,返回上级菜单\033[0m"
|
2020-12-13 16:40:19 +08:00
|
|
|
|
else
|
|
|
|
|
saveserver
|
2020-10-23 07:23:38 +08:00
|
|
|
|
fi
|
2020-11-07 12:08:31 +08:00
|
|
|
|
elif [ "$num" = 6 ]; then
|
|
|
|
|
echo -----------------------------------------------
|
2021-06-19 15:23:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/clashrelease https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master/bin/release_version echooff rediroff 2>/tmp/clashrelease
|
2021-06-20 21:43:41 +08:00
|
|
|
|
echo -e "\033[31m请选择想要回退至的release版本:\033[0m"
|
2020-11-07 12:08:31 +08:00
|
|
|
|
cat /tmp/clashrelease | awk '{print " "NR" "$1}'
|
|
|
|
|
echo -e " 0 返回上级菜单"
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ -z "$num" -o "$num" = 0 ]; then
|
|
|
|
|
setserver
|
|
|
|
|
elif [ $num -le $(cat /tmp/clashrelease | awk 'END{print NR}') 2>/dev/null ]; then
|
|
|
|
|
release_version=$(cat /tmp/clashrelease | awk '{print $1}' | sed -n "$num"p)
|
|
|
|
|
update_url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash@$release_version"
|
2020-12-13 16:40:19 +08:00
|
|
|
|
saveserver
|
2020-11-07 12:08:31 +08:00
|
|
|
|
else
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[31m输入有误,请重新输入!\033[0m"
|
|
|
|
|
fi
|
|
|
|
|
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 9 ]; then
|
2021-06-20 21:43:41 +08:00
|
|
|
|
update_url='http://192.168.123.90:8080/ShellClash'
|
2020-10-23 07:23:38 +08:00
|
|
|
|
else
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-08-11 10:17:00 +08:00
|
|
|
|
fi
|
2020-10-23 07:23:38 +08:00
|
|
|
|
}
|
2020-10-23 19:08:35 +08:00
|
|
|
|
checkupdate(){
|
|
|
|
|
if [ -z "$release_new" ];then
|
|
|
|
|
if [ "$update_url" = "https://cdn.jsdelivr.net/gh/juewuy/ShellClash" ];then
|
2021-06-20 01:15:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/clashversion $update_url@master/bin/release_version echoon rediroff 2>/tmp/clashrelease
|
|
|
|
|
[ "$?" = "0" ] && release_new=$(cat /tmp/clashversion | head -1)
|
2020-10-23 19:08:35 +08:00
|
|
|
|
update_url=$update_url@$release_new
|
2021-06-20 01:15:20 +08:00
|
|
|
|
fi
|
2021-06-19 15:23:20 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/clashversion $update_url/bin/version echooff
|
2021-06-20 01:15:20 +08:00
|
|
|
|
[ "$?" = "0" ] && release_new=$(cat /tmp/clashversion | grep versionsh | awk -F'=' '{ print $2 }')
|
|
|
|
|
[ -n "$release_new" ] &&source /tmp/clashversion || echo -e "\033[31m检查更新失败!请检查网络连接或切换安装源!\033[0m"
|
2020-10-24 09:54:14 +08:00
|
|
|
|
rm -rf /tmp/clashversion
|
2020-10-23 19:08:35 +08:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
update(){
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -ne "\033[32m正在检查更新!\033[0m\r"
|
2020-10-23 19:08:35 +08:00
|
|
|
|
checkupdate
|
|
|
|
|
[ "$clashcore" = "clash" ] && clash_n=$clash_v || clash_n=$clashpre_v
|
2021-08-30 18:03:37 +08:00
|
|
|
|
[ "$clashcore" = "clashpre" ] && clash_n=$clashpre_v
|
|
|
|
|
[ "$clashcore" = "clash.net" ] && clash_n=$clashnet_v
|
2020-12-11 22:17:29 +08:00
|
|
|
|
clash_v=$($bindir/clash -v 2>/dev/null | awk '{print $2}')
|
|
|
|
|
[ -z "$clash_v" ] && clash_v=$clashv
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "\033[30;47m欢迎使用更新功能:\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e " 1 更新\033[36m管理脚本 \033[33m$versionsh_l\033[0m > \033[32m$versionsh\033[0m"
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -e " 2 切换\033[33mclash核心 \033[33m$clash_v\033[0m > \033[32m$clash_n\033[0m"
|
2021-06-16 18:55:14 +08:00
|
|
|
|
echo -e " 3 更新\033[32mGeoIP/CN-IP \033[33m$Geo_v\033[0m > \033[32m$GeoIP_v\033[0m"
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e " 4 安装本地\033[35mDashboard\033[0m面板"
|
2020-12-09 13:03:42 +08:00
|
|
|
|
echo -e " 5 安装/更新本地\033[33m根证书文件\033[0m"
|
|
|
|
|
echo -e " 6 查看\033[32mPAC\033[0m自动代理配置"
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -----------------------------------------------
|
2021-06-20 21:43:41 +08:00
|
|
|
|
echo -e " 7 切换\033[36m安装源\033[0m及\033[36m安装版本\033[0m"
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e " 8 鸣谢"
|
|
|
|
|
echo -e " 9 \033[31m卸载\033[34mShellClash\033[0m"
|
|
|
|
|
echo -e " 0 返回上级菜单"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ -z "$num" ]; then
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 0 ]; then
|
2020-12-13 21:22:41 +08:00
|
|
|
|
i=
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 1 ]; then
|
|
|
|
|
getsh
|
2020-10-24 20:09:49 +08:00
|
|
|
|
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 2 ]; then
|
2020-11-01 11:38:26 +08:00
|
|
|
|
setcore
|
2020-10-24 20:09:49 +08:00
|
|
|
|
update
|
|
|
|
|
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 3 ]; then
|
2020-11-01 11:38:26 +08:00
|
|
|
|
setgeo
|
2020-10-23 19:08:35 +08:00
|
|
|
|
update
|
|
|
|
|
|
|
|
|
|
elif [ "$num" = 4 ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
setdb
|
2020-10-24 20:09:49 +08:00
|
|
|
|
update
|
2020-11-12 14:20:01 +08:00
|
|
|
|
|
|
|
|
|
elif [ "$num" = 5 ]; then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
setcrt
|
2020-12-09 13:03:42 +08:00
|
|
|
|
update
|
|
|
|
|
|
|
|
|
|
elif [ "$num" = 6 ]; then
|
2020-11-12 14:20:01 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "PAC配置链接为:\033[30;47m http://$host:$db_port/ui/pac \033[0m"
|
|
|
|
|
echo -e "PAC的使用教程请参考:\033[4;32mhttps://juewuy.github.io/ehRUeewcv\033[0m"
|
|
|
|
|
sleep 2
|
|
|
|
|
update
|
|
|
|
|
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 7 ]; then
|
|
|
|
|
setserver
|
2020-12-13 16:40:19 +08:00
|
|
|
|
update
|
2020-10-23 19:08:35 +08:00
|
|
|
|
|
|
|
|
|
elif [ "$num" = 8 ]; then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "感谢:\033[32mClash \033[0m作者\033[36m Dreamacro\033[0m 项目地址:\033[32mhttps://github.com/Dreamacro/clash\033[0m"
|
|
|
|
|
echo -e "感谢:\033[32msubconverter \033[0m作者\033[36m tindy2013\033[0m 项目地址:\033[32mhttps://github.com/tindy2013/subconverter\033[0m"
|
|
|
|
|
echo -e "感谢:\033[32malecthw提供的GeoIP数据库\033[0m 项目地址:\033[32mhttps://github.com/alecthw/mmdb_china_ip_list\033[0m"
|
2021-06-16 18:55:14 +08:00
|
|
|
|
echo -e "感谢:\033[32mHackl0us提供的GeoIP精简数据库\033[0m 项目地址:\033[32mhttps://github.com/Hackl0us/GeoIP2-CN\033[0m"
|
|
|
|
|
echo -e "感谢:\033[32m17mon提供的CN-IP列表\033[0m 项目地址:\033[32mhttps://github.com/17mon/china_ip_list\033[0m"
|
2020-10-23 19:08:35 +08:00
|
|
|
|
echo -e "感谢:\033[32myacd \033[0m作者\033[36m haishanh\033[0m 项目地址:\033[32mhttps://github.com/haishanh/yacd\033[0m"
|
|
|
|
|
echo -e "感谢:\033[32m更多的帮助过我的人!\033[0m"
|
|
|
|
|
sleep 2
|
|
|
|
|
update
|
|
|
|
|
|
|
|
|
|
elif [ "$num" = 9 ]; then
|
2021-06-20 00:56:11 +08:00
|
|
|
|
$0 -u
|
2020-10-23 19:08:35 +08:00
|
|
|
|
update
|
|
|
|
|
else
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 19:08:35 +08:00
|
|
|
|
fi
|
|
|
|
|
}
|
2020-10-28 11:09:26 +08:00
|
|
|
|
#新手引导
|
2020-10-23 07:23:38 +08:00
|
|
|
|
userguide(){
|
2020-10-30 16:21:09 +08:00
|
|
|
|
whichmod(){
|
|
|
|
|
echo -----------------------------------------------
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -e "\033[33m是否需要代理UDP流量(主要用于游戏)? \033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
2021-06-19 12:04:19 +08:00
|
|
|
|
echo -e " 1 \033[33m不代理UDP流量\033[0m(可能会导致一部分外服游戏/应用无法连接)"
|
2021-04-19 12:10:09 +08:00
|
|
|
|
ip tuntap >/dev/null 2>&1 && [ "$?" = 0 ] && \
|
2020-12-13 16:40:19 +08:00
|
|
|
|
echo -e " 2 \033[32m使用Tun虚拟网卡\033[0m代理UDP流量(更低的延迟但更多的CPU消耗)" || \
|
2020-12-03 13:06:40 +08:00
|
|
|
|
echo -e " - \033[0m使用Tun模式(你的设备不支持此模式,如为虚拟机运行请调整虚拟网卡设置)\033[0m"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
[ -n "$(iptables -j TPROXY 2>&1 | grep 'on-port')" ] && \
|
2020-12-13 16:40:19 +08:00
|
|
|
|
echo -e " 3 \033[32m使用Tproxy模式\033[0m代理UDP流量(较低CPU消耗但相对高的延迟)"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ -z "$num" ] || [ "$num" -gt 4 ];then
|
|
|
|
|
errornum
|
|
|
|
|
whichmod
|
|
|
|
|
elif [ "$num" = 1 ];then
|
|
|
|
|
setconfig redir_mod "Redir模式"
|
|
|
|
|
setconfig clashcore "clash"
|
|
|
|
|
elif [ "$num" = 2 ];then
|
|
|
|
|
setconfig redir_mod "混合模式"
|
|
|
|
|
setconfig clashcore "clashpre"
|
|
|
|
|
elif [ "$num" = 3 ];then
|
|
|
|
|
setconfig redir_mod "Redir模式"
|
|
|
|
|
setconfig clashcore "clash"
|
|
|
|
|
setconfig tproxy_mod "已开启"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
forwhat(){
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[30;46m 欢迎使用ShellClash新手引导! \033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -e "\033[33m请先选择你的使用环境: \033[0m"
|
|
|
|
|
echo -e "\033[0m(你之后依然可以在设置中更改各种配置)\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
2021-06-19 12:04:19 +08:00
|
|
|
|
echo -e " 1 \033[32m主路由或旁路由\033[0m"
|
2021-05-29 16:50:55 +08:00
|
|
|
|
echo -e " 2 \033[36mLinux本机代理\033[0m"
|
2021-08-30 17:49:33 +08:00
|
|
|
|
[ -f "$ccfg.bak" ] && echo -e " 3 \033[33m还原之前备份的设置\033[0m"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ -z "$num" ] || [ "$num" -gt 4 ];then
|
|
|
|
|
errornum
|
|
|
|
|
forwhat
|
|
|
|
|
elif [ "$num" = 1 ];then
|
|
|
|
|
whichmod
|
2021-06-22 11:29:49 +08:00
|
|
|
|
#检测IP转发
|
|
|
|
|
if [ "$(cat /proc/sys/net/ipv4/ip_forward)" = "0" ];then
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[33m检测到你的设备尚未开启ip转发,局域网设备将无法正常连接网络,是否立即开启?\033[0m"
|
|
|
|
|
read -p "是否开启?(1/0) > " res
|
|
|
|
|
[ "$res" = 1 ] && echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
|
|
|
|
|
[ "$?" = 0 ] && /etc/init.d/procps restart && echo "已成功开启ipv4转发,如未正常开启,请手动重启设备!" || echo "开启失败!请自行谷歌查找当前设备的开启方法!"
|
|
|
|
|
fi
|
2021-05-29 16:50:55 +08:00
|
|
|
|
elif [ "$num" = 2 ];then
|
2020-10-30 16:21:09 +08:00
|
|
|
|
setconfig redir_mod "纯净模式"
|
|
|
|
|
setconfig clashcore "clash"
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-30 16:21:09 +08:00
|
|
|
|
echo -e "\033[36m请选择设置本机代理的方式\033[0m"
|
2021-06-16 18:55:14 +08:00
|
|
|
|
echo -e " 1 使用\033[32m环境变量\033[0m方式配置(不支持部分应用)"
|
|
|
|
|
echo -e " 2 使用\033[32miptables增强模式\033[0m配置(不支持OpenWrt)"
|
|
|
|
|
echo -e " 0 稍后设置"
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ "$num" = 1 ]; then
|
|
|
|
|
local_proxy=已开启
|
|
|
|
|
local_type=环境变量
|
|
|
|
|
elif [ "$num" = 2 ]; then
|
|
|
|
|
local_proxy=已开启
|
|
|
|
|
local_type=iptables增强模式
|
|
|
|
|
fi
|
|
|
|
|
setconfig local_proxy $local_proxy
|
|
|
|
|
setconfig local_type $local_type
|
2021-08-30 17:49:33 +08:00
|
|
|
|
elif [ "$num" = 3 ];then
|
|
|
|
|
mv -f $ccfg.bak $ccfg
|
|
|
|
|
echo -e "\033[32m脚本设置已还原!\033[0m"
|
|
|
|
|
echo -e "\033[33m请重新启动脚本!\033[0m"
|
|
|
|
|
exit 0
|
2020-10-30 16:21:09 +08:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
forwhat
|
2020-12-11 22:17:29 +08:00
|
|
|
|
#检测小内存模式
|
2020-10-30 16:21:09 +08:00
|
|
|
|
dir_size=$(df $clashdir | awk '{print $4}' | sed 1d)
|
|
|
|
|
if [ "$dir_size" -lt 10240 ];then
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-30 16:21:09 +08:00
|
|
|
|
echo -e "\033[33m检测到你的安装目录空间不足10M,是否开启小闪存模式?\033[0m"
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -e "\033[0m开启后核心及数据库文件将被下载到内存中,这将占用一部分内存空间\033[0m"
|
|
|
|
|
echo -e "\033[0m每次开机后首次运行clash时都会自动的重新下载相关文件\033[0m"
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-30 16:21:09 +08:00
|
|
|
|
read -p "是否开启?(1/0) > " res
|
2020-12-11 22:17:29 +08:00
|
|
|
|
[ "$res" = 1 ] && setconfig bindir "/tmp/clash_$USER"
|
2020-10-30 16:21:09 +08:00
|
|
|
|
fi
|
2020-12-11 22:17:29 +08:00
|
|
|
|
#下载本地面板
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[33m安装本地Dashboard面板,可以更快捷的管理clash内置规则!\033[0m"
|
2020-12-11 22:17:29 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-30 16:21:09 +08:00
|
|
|
|
read -p "需要安装本地Dashboard面板吗?(1/0) > " res
|
2020-12-21 11:55:43 +08:00
|
|
|
|
[ "$res" = 1 ] && checkupdate && setdb
|
2020-12-11 22:17:29 +08:00
|
|
|
|
#检测及下载根证书
|
|
|
|
|
if [ -d /etc/ssl/certs -a ! -f '/etc/ssl/certs/ca-certificates.crt' ];then
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[33m当前设备未找到根证书文件\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
read -p "是否下载并安装根证书?(1/0) > " res
|
2020-12-21 11:55:43 +08:00
|
|
|
|
[ "$res" = 1 ] && checkupdate && getcrt
|
2020-12-11 22:17:29 +08:00
|
|
|
|
fi
|
2021-03-13 18:06:38 +08:00
|
|
|
|
#设置加密DNS
|
2021-06-22 13:42:39 +08:00
|
|
|
|
$clashdir/start.sh webget /tmp/ssl_test https://www.baidu.com echooff rediron skipceroff
|
2021-06-19 15:23:20 +08:00
|
|
|
|
if [ "$?" = "0" ];then
|
2021-03-13 18:06:38 +08:00
|
|
|
|
dns_nameserver='https://223.5.5.5/dns-query, https://doh.pub/dns-query, tls://dns.rubyfish.cn:853'
|
|
|
|
|
dns_fallback='https://1.0.0.1/dns-query, https://8.8.4.4/dns-query, https://doh.opendns.com/dns-query'
|
|
|
|
|
setconfig dns_nameserver \'"$dns_nameserver"\'
|
|
|
|
|
setconfig dns_fallback \'"$dns_fallback"\'
|
|
|
|
|
fi
|
|
|
|
|
rm -rf /tmp/ssl_test
|
2020-12-11 22:17:29 +08:00
|
|
|
|
#提示导入订阅或者配置文件
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[32m是否导入配置文件?\033[0m(这是运行前的最后一步)"
|
|
|
|
|
echo -e "\033[0m你必须拥有一份yaml格式的配置文件才能运行clash服务!\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
read -p "现在开始导入?(1/0) > " res
|
|
|
|
|
[ "$res" = 1 ] && inuserguide=1 && clashlink && inuserguide=""
|
|
|
|
|
#回到主界面
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo -e "\033[36m很好!现在只需要执行启动就可以愉快的使用了!\033[0m"
|
2020-11-01 11:38:26 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-12-11 22:17:29 +08:00
|
|
|
|
read -p "立即启动clash服务?(1/0) > " res
|
|
|
|
|
[ "$res" = 1 ] && clashstart && sleep 2
|
2020-11-01 11:38:26 +08:00
|
|
|
|
clashsh
|
2020-10-23 07:23:38 +08:00
|
|
|
|
}
|
2020-10-28 11:09:26 +08:00
|
|
|
|
#测试菜单
|
2020-10-23 07:23:38 +08:00
|
|
|
|
testcommand(){
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "\033[30;47m这里是测试命令菜单\033[0m"
|
|
|
|
|
echo -e "\033[33m如遇问题尽量运行相应命令后截图发群\033[0m"
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo " 1 查看clash运行时的报错信息"
|
|
|
|
|
echo " 2 查看系统DNS端口(:53)占用 "
|
|
|
|
|
echo " 3 测试ssl加密(aes-128-gcm)跑分"
|
|
|
|
|
echo " 4 查看iptables端口转发详情"
|
|
|
|
|
echo " 5 查看config.yaml前40行"
|
|
|
|
|
echo " 6 测试代理服务器连通性(google.tw)"
|
|
|
|
|
echo " 7 重新进入新手引导"
|
2020-10-24 09:54:14 +08:00
|
|
|
|
echo " 9 查看后台脚本运行日志"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
echo " 0 返回上级目录!"
|
|
|
|
|
read -p "请输入对应数字 > " num
|
|
|
|
|
if [ -z "$num" ]; then
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 07:23:38 +08:00
|
|
|
|
clashsh
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 0 ]; then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
clashsh
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 1 ]; then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
$clashdir/start.sh stop
|
|
|
|
|
echo -----------------------------------------------
|
2021-07-17 22:26:41 +08:00
|
|
|
|
[ -x $clashdir/clash ] && $clashdir/clash -t -d $clashdir
|
2020-10-27 09:40:58 +08:00
|
|
|
|
[ "$?" = 0 ] && testover=32m测试通过!|| testover=31m出现错误!请截图后到TG群询问!!!
|
|
|
|
|
echo -e "\033[$testover\033[0m"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
exit;
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 2 ]; then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
netstat -ntulp |grep 53
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
echo -e "可以使用\033[44m netstat -ntulp |grep xxx \033[0m来查询任意(xxx)端口"
|
|
|
|
|
exit;
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 3 ]; then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
openssl speed -multi 4 -evp aes-128-gcm
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
exit;
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 4 ]; then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
iptables -t nat -L PREROUTING --line-numbers
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
iptables -t nat -L clash --line-numbers
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
iptables -t nat -L clash_dns --line-numbers
|
2020-11-05 14:54:52 +08:00
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
ip6tables -t nat -L PREROUTING --line-numbers
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
ip6tables -t nat -L clashv6 --line-numbers
|
|
|
|
|
echo -----------------------------------------------
|
|
|
|
|
ip6tables -t nat -L clashv6_dns --line-numbers
|
2020-10-23 07:23:38 +08:00
|
|
|
|
exit;
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 5 ]; then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
sed -n '1,40p' $yaml
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
exit;
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 6 ]; then
|
2020-10-24 21:13:06 +08:00
|
|
|
|
echo "注意:依赖curl(不支持wget),且测试结果不保证一定准确!"
|
2020-10-23 07:23:38 +08:00
|
|
|
|
delay=`curl -kx ${authentication}@127.0.0.1:$mix_port -o /dev/null -s -w '%{time_starttransfer}' 'https://google.tw' & { sleep 3 ; kill $! & }` > /dev/null 2>&1
|
|
|
|
|
delay=`echo |awk "{print $delay*1000}"` > /dev/null 2>&1
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-23 07:23:38 +08:00
|
|
|
|
if [ `echo ${#delay}` -gt 1 ];then
|
|
|
|
|
echo -e "\033[32m连接成功!响应时间为:"$delay" ms\033[0m"
|
|
|
|
|
else
|
|
|
|
|
echo -e "\033[31m连接超时!请重试或检查节点配置!\033[0m"
|
|
|
|
|
fi
|
|
|
|
|
clashsh
|
2020-10-23 19:08:35 +08:00
|
|
|
|
elif [ "$num" = 7 ]; then
|
2020-10-23 07:23:38 +08:00
|
|
|
|
userguide
|
2020-10-24 09:54:14 +08:00
|
|
|
|
elif [ "$num" = 9 ]; then
|
2020-10-25 10:01:58 +08:00
|
|
|
|
echo -----------------------------------------------
|
2020-10-24 09:54:14 +08:00
|
|
|
|
cat $clashdir/log
|
|
|
|
|
exit;
|
2020-10-23 07:23:38 +08:00
|
|
|
|
else
|
2020-10-28 11:09:26 +08:00
|
|
|
|
errornum
|
2020-10-23 07:23:38 +08:00
|
|
|
|
clashsh
|
|
|
|
|
fi
|
2021-06-22 13:42:39 +08:00
|
|
|
|
}
|