0.8大版本更新

This commit is contained in:
juewuy
2020-08-06 17:17:05 +08:00
parent 345ebee3d3
commit 61ae2e3899
6 changed files with 265 additions and 381 deletions

View File

@@ -8,11 +8,13 @@ echo "** by Juewuy **"
echo "***********************************************"
getconfig(){
#版本号
clashfm=0.8.0
#更新服务器地址
update_url="https://juewuy.xyz/clash"
#文件路径
cpath=$clashdir #clash目录地址
sed -i "/^cpath\=*/ccpath\=$cpath" /etc/init.d/clash #同步service文件中的clash路径
ccfg=$cpath/mark
yaml=$cpath/config.yaml
ccfg=$clashdir/mark
yaml=$clashdir/config.yaml
#检查标识文件
if [ ! -f "$ccfg" ]; then
echo mark文件不存在正在创建
@@ -22,7 +24,8 @@ EOF
fi
source $ccfg
#获取自启状态
if [ $auto_start = true ] > /dev/null 2>&1; then
#if [ $auto_start = true ] > /dev/null 2>&1; then
if [ -f /etc/rc.d/*clash ]; then
auto="\033[32m已设置开机启动\033[0m"
auto1="禁用clash开机启动"
else
@@ -60,186 +63,29 @@ echo -e "Clash服务"$run""$auto""
if [ $status -gt 0 ];then
echo -e "当前内存占用:\033[44m"$VmRSS"\033[0m已运行\033[46;30m"$day"\033[44;37m"$time"\033[0m"
fi
#安装clash核心
if [ ! -f $clashdir/clash ];then
echo -e "\033[31m没有找到核心文件请先下载clash核心\033[0m"
source $clashdir/getdate.sh
getcore
fi
}
clashstart(){
getyaml(){
source $ccfg
#前后端订阅服务器地址索引,可在此处添加!
Server=`sed -n ""$server_link"p"<<EOF
subconverter-web.now.sh
subcon.py6.pw
api.dler.io
api.wcc.best
EOF`
Config=`sed -n ""$rule_link"p"<<EOF
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online.ini
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_MultiMode.ini
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_AdblockPlus.ini
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_AdblockPlus.ini
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoReject.ini
EOF`
Https="https://$Server/sub?target=clashr&new_name=true&url=$Url&insert=false&config=$Config"
echo -----------------------------------------------
echo 正在连接服务器获取配置文件…………链接地址为:
echo -e "\033[4;32m$Https\033[0m"
echo 可以手动复制该链接到浏览器打开并查看数据是否正常!
echo -e "\033[36m-----------------------------------------------"
echo -e "| |"
echo -e "| 需要一点时间,请耐心等待! |"
echo -e "| \033[0m如长时间没有数据请用ctrl+c退出 |"
echo -e "-----------------------------------------------\033[0m"
#获取在线yaml文件
yamlnew=$yaml.new
rm $yamlnew > /dev/null 2>&1
result=$(curl -w %{http_code} -kLo $yamlnew $Https)
if [ "$result" != "200" ];then
echo -----------------------------------------------
echo -e "\033[31m配置文件获取失败\033[0m"
echo -----------------------------------------------
echo
read -p "是否更换后端地址后重试?[1/0] > " res
if [ "$res" = '1' ]; then
sed -i '/server_link=*/'d $ccfg
if [ "$server_link" = '4' ]; then
server_link=0
fi
server_link=$(($server_link + 1))
#echo $server_link
sed -i "5i\server_link=$server_link" $ccfg
getyaml
fi
exit;
else
if cat $yamlnew | grep ', server:' >/dev/null;then
##########需要变更的配置###########
redir='redir-port: 7892'
external='external-controller: 0.0.0.0:9999'
dns='dns: {enable: true, listen: 0.0.0.0:1053, fake-ip-range: 198.18.0.1/16, enhanced-mode: fake-ip, nameserver: [114.114.114.114, 127.0.0.1:53], fallback: [tcp://1.0.0.1, tls://dns.google:853]}'
tun='tun: {enable: false, stack: system}'
exper='experimental: {ignore-resolve-fail: true, interface-name: en0}'
###################################
#预删除需要添加的项目
sed -i '/redir-port:*/'d $yamlnew
sed -i '/external-controller:*/'d $yamlnew
sed -i '/dns:*/'d $yamlnew
sed -i '/tun:*/'d $yamlnew
sed -i '/experimental:*/'d $yamlnew
#添加配置
sed -i "2a$redir" $yamlnew
sed -i "6a$external" $yamlnew
sed -i "7a$dns" $yamlnew
sed -i "8a$tun" $yamlnew
sed -i "9a$exper" $yamlnew
if [ "$skip_cert" != "未开启" ];then
sed -i "10,99s/sni: \S*/\1skip-cert-verify: true}/" $yamlnew #跳过trojan本地证书验证
sed -i '10,99s/}}/}, skip-cert-verify: true}/' $yamlnew #跳过v2+ssl本地证书验证
fi
sed -i '/rules:/a \ - DOMAIN-SUFFIX,clash.razord.top,🎯 全球直连' $yamlnew
#替换文件
mv $yaml $yaml.bak
mv $yamlnew $yaml
echo 配置文件已生成正在重启clash使其生效
#重启clash服务
/etc/init.d/clash stop
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];then
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];then
echo -----------------------------------------------
echo -e "\033[32mclash服务已启动\033[0m"
echo 可以使用 http://clash.razord.top IP为网关IP端口为9999管理clash内置规则
clashsh
else
echo -e "可以使用\033[30;47m http://clash.razord.top \033[0m管理clash内置规则"
host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';)
echo -e "Host地址:\033[30;46m $host \033[0m端口:\033[30;46m 9999 \033[0m"
else
echo -----------------------------------------------
echo -e "\033[31mclash服务启动失败请检查配置文件\033[0m"
clashsh
fi
exit;
else
echo -----------------------------------------------
echo -e "\033[33m囧囧囧 获取到了配置文件,但格式似乎不对 囧囧囧\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sed -n '1,20p' $yamlnew
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m请检查如上配置文件信息:\033[0m"
echo -----------------------------------------------
fi
exit;
fi
exit
}
getlink(){
#设置输入循环
i=1
while [ $i -le 9 ]
do
echo -----------------------------------------------
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -----------------------------------------------
echo -e "\033[33m支持批量导入\033[30;46m Http/Https/Clash \033[0;33m等格式的订阅链接"
echo -e "支持批量导入\033[30;42m Vmess/SSR/SS/Trojan/Sock5 \033[0;33m等格式的节点链接"
echo -e "\033[36m多个较短的链接可以用\033[30;47m | \033[0;36m分隔以一次性输入"
echo -e "多个较长的链接请尽量分多次输入,可支持多达\033[30;47m 9 \033[0;36m次输入"
echo -e "\033[31;47m注意SSR/SS不支持\033[30;47mchacha20加密 \033[0m"
echo -e "\033[44;37m直接输入回车以结束输入并开始导入链接\033[0m"
echo -e "\033[33m 0 返回上级目录!\033[0m"
echo -----------------------------------------------
read -p "请输入第"$i"个链接 > " url
test=$(echo $url | grep "://")
url=`echo ${url/\ \(*\)/''}` #删除恶心的超链接内容
url=`echo ${url/*\&url\=/""}` #将clash完整链接还原成单一链接
url=`echo ${url/\&config\=*/""}` #将clash完整链接还原成单一链接
url=`echo ${url//\&/\%26}` #将分隔符 & 替换成urlcode%26
if [[ "$test" != "" ]];then
if [[ -z $Url ]];then
Url="$url"
else
Url="$Url"\|"$url"
fi
i=$(($i+1))
elif [ -z $url ];then
if [ -n $Url ];then
echo -----------------------------------------------
echo -e 请检查输入的链接是否正确:
echo -e "\033[4m$Url\033[0m"
read -p "确认导入配置文件原配置文件将被更名为config.bak![1/0] > " res
if [ "$res" = '1' ]; then
#将用户链接写入mark
sed -i '/Url=*/'d $ccfg
sed -i "6i\Url=\'$Url\'" $ccfg
#获取在线yaml文件
getyaml
exit;
fi
clashlink
fi
elif [[ $url == 0 ]];then
clashlink
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的订阅/分享链接!!!\033[0m"
fi
done
echo -----------------------------------------------
echo 输入太多啦,可能会导致订阅失败!
echo "多个较短的链接请尽量用“|”分隔以一次性输入!"
echo -e "请检查输入的链接是否正确:\033[4m$Url\033[0m"
read -p "确认导入配置文件原配置文件将被更名为config.bak![1/0] > " res
if [ "$res" = '1' ]; then
#将用户链接写入mark
sed -i '/Url=*/'d $ccfg
sed -i "6i\Url=\'$Url\'" $ccfg
#获取在线yaml文件
getyaml
exit;
else
echo -----------------------------------------------
echo 操作已取消!返回上级菜单!
clashlink
fi
clashlink
}
}
clashlink(){
#获取订阅规则
if [ ! -n "$rule_link" ]; then
@@ -250,18 +96,19 @@ fi
#获取后端服务器地址
if [ ! -n "$server_link" ]; then
sed -i '/server_link=*/'d $ccfg
sed -i "5i\server_link=3" $ccfg
server_link=3
sed -i "5i\server_link=1" $ccfg
server_link=1
fi
echo -----------------------------------------------
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[32m 欢迎使用订阅功能!\033[0m"
echo -e 1 输入订阅链接
echo -e 2 选取规则模版
echo -e 3择后端地址
echo -e 4 还原配置文件
echo -e 5 手动更新订阅
echo -e 6 设置自动更新(未完成)
echo -e 1 输入节点/订阅链接
echo -e 2 输入完整clash规则链接
echo -e 3取代理规则模版
echo -e 4 选择配置生成服务器
echo -e 5 还原配置文件
echo -e 6 手动更新订阅
echo -e 7 设置自动更新(未完成)
echo -e 0 返回上级菜单
read -p "请输入对应数字 > " num
if [ -z $num ];then
@@ -281,8 +128,25 @@ elif [[ $num == 1 ]];then
echo -e "\033[31m链接已清空\033[0m"
fi
fi
source $clashdir/getdate.sh
getlink
elif [[ $num == 2 ]];then
if [ -n "$Url" ];then
echo -----------------------------------------------
echo -e "\033[33m检测到已记录的订阅链接\033[0m"
echo -e "\033[4;32m$Url\033[0m"
echo -----------------------------------------------
read -p "清空链接/追加导入?[1/0] > " res
if [ "$res" = '1' ]; then
Url=""
echo -----------------------------------------------
echo -e "\033[31m链接已清空\033[0m"
fi
fi
source $clashdir/getdate.sh
getlink2
elif [[ $num == 3 ]];then
echo -----------------------------------------------
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo 当前使用规则为:$rule_link
@@ -305,14 +169,17 @@ elif [[ $num == 2 ]];then
echo -e "\033[32m设置成功返回上级菜单\033[0m"
clashlink
fi
elif [[ $num == 3 ]];then
elif [[ $num == 4 ]];then
echo -----------------------------------------------
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo 当前使用后端为:$server_link
echo 1 subconverter-web.now.sh
echo 2 subcon.py6.pw
echo 3 api.dler.io
echo 4 api.wcc.best
echo 2 subconverter.herokuapp.com
echo 3 subcon.py6.pw
echo 4 api.dler.io
echo 5 api.wcc.best
echo 6 skapi.cool
echo 7 subconvert.dreamcloud.pw
echo 0 返回上级菜单
read -p "请输入对应数字 > " num
if [ -z $num ];then
@@ -330,7 +197,7 @@ elif [[ $num == 3 ]];then
echo -e "\033[32m设置成功返回上级菜单\033[0m"
clashlink
fi
elif [[ $num == 4 ]];then
elif [[ $num == 5 ]];then
yamlbak=$yaml.bak
if [ ! -f "$yaml".bak ];then
echo -----------------------------------------------
@@ -349,7 +216,7 @@ elif [[ $num == 4 ]];then
fi
fi
clashsh
elif [[ $num == 5 ]];then
elif [[ $num == 6 ]];then
if [ ! -n "$Url" ];then
echo -----------------------------------------------
echo 没有找到你的订阅链接!请先输入链接!
@@ -362,6 +229,7 @@ elif [[ $num == 5 ]];then
echo -----------------------------------------------
read -p "确认更新配置文件?[1/0] > " res
if [ "$res" = '1' ]; then
source $clashdir/getdate.sh
getyaml
fi
clashlink
@@ -384,17 +252,20 @@ if [ ! -n "$common_ports" ]; then
sed -i "2i\common_ports=未开启" $ccfg
common_ports=未开启
fi
if [ ! -n "$dns_mod" ]; then
sed -i "2i\dns_mod=redir_host" $ccfg
dns_mod=redir_host
fi
#
echo -----------------------------------------------
echo -e "\033[33m欢迎使用高级模式菜单\033[0m"
echo 1 切换代理模式Tun/Redir
echo 2 跳过本地证书验证(用于解决自建节点出现证书验证错误):$skip_cert
echo 3 只代理常用端口用于屏蔽P2P流量$common_ports
echo 4 更新clash核心文件施工中
echo 5 更新GeoIP数据库施工中
echo 6 更新管理脚本(施工中)
echo 9 卸载clash
echo 0 返回上级菜单
echo -e "\033[32m修改配置后请手动重启clash服务\033[0m"
echo -e "1 切换运行模式: \033[32m$redir_mod\033[0m"
echo -e "2 切换DNS运行模式 \033[32m$dns_mod\033[0m"
echo -e "3 跳过本地证书验证:\033[32m$skip_cert\033[0m ————解决节点证书验证错误"
echo -e "4 只代理常用端口: \033[32m$common_ports\033[0m ————用于屏蔽P2P流量"
echo -e "9 重启clash服务"
echo -e "0 返回上级菜单 \033[0m"
read -p "请输入对应数字 > " num
if [[ $num -le 9 ]] > /dev/null 2>&1; then
if [[ $num == 0 ]]; then
@@ -403,7 +274,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
elif [[ $num == 1 ]]; then
echo -----------------------------------------------
echo -e "当前代理模式为:\033[47;30m $redir_mod \033[0m"
echo -e "\033[33m切换模式时会重启clash服务,可能会导致短时间的网络中断\033[0m"
echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m"
echo "1 Tun模式 支持UDP转发且延迟低"
echo " 但CPU及内存占用更高"
echo " 适合外服游戏用户"
@@ -411,108 +282,135 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo " 但不支持UDP流量转发"
echo " 日常使用推荐此模式"
echo 0 返回上级菜单
read -p "请输入对应数字 > " num
if [[ $num == 0 ]]; then
clashadv
elif [[ $num == 1 ]]; then
redir_mod=Tun模式
elif [[ $num == 2 ]]; then
redir_mod=Redir模式
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
clashadv
fi
sed -i '/redir_mod*/'d $ccfg
sed -i "1i\redir_mod=$redir_mod" $ccfg
echo -----------------------------------------------
echo -e "\033[33m已设为 $redir_mod \033[0m"
clashadv
elif [[ $num == 2 ]]; then
echo -----------------------------------------------
echo -e "当前DNS运行模式为\033[47;30m $dns_mod \033[0m"
echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m"
echo "1 fake-ip模式 响应速度更快"
echo " 但可能和部分软件有冲突"
echo "2 redir_host模式使用稳定兼容性好"
echo " 响应速度略慢"
echo 0 返回上级菜单
read -p "请输入对应数字 > " num
if [[ $num == 0 ]]; then
clashadv
clashadv
elif [[ $num == 1 ]]; then
if [[ $redir_mod = "Redir模式" ]]; then
sed -i '/redir_mod*/'d $ccfg
sed -i "2i\redir_mod=Tun模式" $ccfg #修改redir_mod标记
sed -i '5,20s/tun: {enable: false/tun: {enable: true/' $yaml #修改配置文件
if [ $status -gt 0 ];then > /dev/null 2>&1
echo -----------------------------------------------
echo -e "\033[33m正在重启clash进程……\033[0m"
/etc/init.d/clash stop > /dev/null 2>&1
fi
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];then
echo -----------------------------------------------
echo -e "\033[32mclash服务已启动\033[0m"
echo -e "\033[33mclash已成功切换为\033[47;34m Tun模式! \033[0m"
echo -e 可以使用 "\033[32mhttp://clash.razord.top\033[0m"IP为网关IP端口为9999管理clash内置规则
clashsh
else
echo -----------------------------------------------
echo -e "\033[31mclash服务启动失败请检查配置文件\033[0m"
clashsh
fi
else
echo -----------------------------------------------
echo -e "\033[33m当前已经处于Tun模式无需重复设置\033[0m"
clashadv
fi
dns_mod='fake-ip'
elif [[ $num == 2 ]]; then
if [[ $redir_mod = "Tun模式" ]]; then
sed -i '/redir_mod*/'d $ccfg
sed -i "2i\redir_mod=Redir模式" $ccfg #修改redir_mod标记
sed -i '5,20s/tun: {enable: true/tun: {enable: false/' $yaml #修改配置文件
if [ $status -gt 0 ];then
echo -----------------------------------------------
echo -e "\033[33m正在重启clash进程……\033[0m"
/etc/init.d/clash stop > /dev/null 2>&1
fi
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];then
echo -----------------------------------------------
echo -e "\033[32mclash服务已启动\033[0m"
echo -e "\033[33mclash已成功切换为\033[47;34m Redir模式! \033[0m"
echo -e 可以使用 "\033[32mhttp://clash.razord.top\033[0m"IP为网关IP端口为9999管理clash内置规则
clashsh
else
echo -----------------------------------------------
echo -e "\033[31mclash服务启动失败请检查配置文件\033[0m"
clashsh
fi
else
echo -----------------------------------------------
echo -e "\033[33m当前已经处于Redir模式无需重复设置\033[0m"
clashadv
fi
dns_mod='redir_host'
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
clashadv
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
clashadv
fi
elif [[ $num == 2 ]]; then
sed -i '/skip_cert*/'d $ccfg
echo -----------------------------------------------
if [ "$skip_cert" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\skip_cert=已开启" $ccfg
echo -e "\033[33m已设为开启跳过本地证书验证\033[0m"
skip_cert=已开启
else
/etc/init.d/clash enable
sed -i "1i\skip_cert=未开启" $ccfg
echo -e "\033[33m已设为禁止跳过本地证书验证\033[0m"
skip_cert=未开启
fi
sed -i '/dns_mod*/'d $ccfg
sed -i "1i\dns_mod=$dns_mod" $ccfg
echo -----------------------------------------------
echo -e "\033[33m已设为 $dns_mod 模式!!\033[0m"
clashadv
elif [[ $num == 3 ]]; then
sed -i '/skip_cert*/'d $ccfg
echo -----------------------------------------------
if [ "$skip_cert" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\skip_cert=已开启" $ccfg
echo -e "\033[33m已设为开启跳过本地证书验证\033[0m"
skip_cert=已开启
else
/etc/init.d/clash enable
sed -i "1i\skip_cert=未开启" $ccfg
echo -e "\033[33m已设为禁止跳过本地证书验证\033[0m"
skip_cert=未开启
fi
clashadv
elif [[ $num == 4 ]]; then
sed -i '/common_ports*/'d $ccfg
echo -----------------------------------------------
if [ "$common_ports" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\common_ports=已开启" $ccfg
echo -e "\033[33m已设为仅代理22,53,587,465,995,993,143,80,443等常用端口\033[0m"
common_ports=已开启
else
/etc/init.d/clash enable
sed -i "1i\common_ports=未开启" $ccfg
echo -e "\033[33m已设为代理全部端口\033[0m"
common_ports=未开启
fi
if [ "$common_ports" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\common_ports=已开启" $ccfg
echo -e "\033[33m已设为仅代理22,53,587,465,995,993,143,80,443等常用端口\033[0m"
common_ports=已开启
else
/etc/init.d/clash enable
sed -i "1i\common_ports=未开启" $ccfg
echo -e "\033[33m已设为代理全部端口\033[0m"
common_ports=未开启
fi
clashadv
elif [[ $num == 9 ]]; then
if [ $status -gt 0 ];then
echo -----------------------------------------------
/etc/init.d/clash stop
echo -e "\033[31mClash服务已停止\033[0m"
fi
clashstart
clashsh
else
echo -e "\033[31m暂未支持的选项\033[0m"
clashadv
fi
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
clashsh
fi
exit;
}
update(){
echo -----------------------------------------------
echo -e "\033[33m欢迎使用更新功能\033[0m"
echo -e "感谢:\033[32mClash \033[0m作者\033[36m Dreamacro\033[0m 项目地址:\033[32mhttps://github.com/Dreamacro/clash\033[0m"
echo -e "感谢:\033[32mClashR \033[0m作者\033[36m BROBIRD\033[0m 项目地址:\033[32mhttps://github.com/BROBIRD/clash\033[0m"
echo -e "感谢:\033[32mtun2socks \033[0m作者\033[36m eycorsican\033[0m 项目地址:\033[32mhttps://github.com/eycorsican/go-tun2socks\033[0m"
echo -e "感谢:\033[32m更多的帮助过我的人\033[0m"
echo -----------------------------------------------
echo 1 更新管理脚本
echo 2 更新\替换clash核心文件
echo 3 更新GeoIP数据库施工中
echo 9 卸载clash
echo 0 返回上级菜单
read -p "请输入对应数字 > " num
if [[ $num -le 9 ]] > /dev/null 2>&1; then
if [[ $num == 0 ]]; then
clashsh
elif [[ $num == 1 ]]; then
source $clashdir/getdate.sh
getsh
elif [[ $num == 2 ]]; then
source $clashdir/getdate.sh
getcore
elif [[ $num == 3 ]]; then
source $clashdir/getdate.sh
getgeo
elif [[ $num == 9 ]]; then
read -p "确认卸载clash警告该操作不可逆[1/0] " res
if [ "$res" = '1' ]; then
/etc/init.d/clash disable
/etc/init.d/clash stop
rm -rf $cpath
rm -rf $clashdir
rm -rf /etc/init.d/clash
rm -rf $csh
sed -i '/alias clash=*/'d /etc/profile
@@ -522,7 +420,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
exit;
else
echo -e "\033[31m暂未支持的选项\033[0m"
clashadv
update
fi
else
echo -----------------------------------------------
@@ -535,77 +433,54 @@ clashsh(){
#############################
getconfig
#############################
echo 1 启动/重启clash服务
echo 2 测试代理服务器连通性
echo 3 停止clash服务
echo 4 $auto1
echo 5 设置定时任务(施工中)
echo 6 使用链接导入节点/订阅
echo 7 高级设置
echo 8 测试菜单
echo 0 退出脚本
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 " 6 导入\033[32m节点/订阅\033[0m链接"
echo -e " 8 \033[36m测试菜单\033[0m"
echo -e " 9 \033[32m更新\033[0m脚本及相关文件"
echo -e " 0 \033[35m退出\033[0m脚本"
read -p "请输入对应数字 > " num
if [[ $num -le 8 ]] > /dev/null 2>&1; then
if [[ $num -le 9 ]] > /dev/null 2>&1; then
if [[ $num == 0 ]]; then
exit;
exit;
elif [[ $num == 1 ]]; then
if [ ! -f "$yaml" ];then
echo -----------------------------------------------
echo -e "\033[31m没有找到配置文件请先导入节点/订阅链接!\033[0m"
clashlink
echo -----------------------------------------------
echo -e "\033[31m没有找到配置文件请先导入节点/订阅链接!\033[0m"
clashlink
fi
if [ $status -gt 0 ];then
echo -----------------------------------------------
/etc/init.d/clash stop > /dev/null 2>&1
echo -e "\033[31mClash服务已停止\033[0m"
echo -----------------------------------------------
/etc/init.d/clash stop > /dev/null 2>&1
echo -e "\033[31mClash服务已停止\033[0m"
fi
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];then
echo -----------------------------------------------
echo -e "\033[32mclash服务已启动\033[0m"
echo 可以使用 http://clash.razord.top IP为网关IP端口为9999管理clash内置规则
clashsh
else
echo -----------------------------------------------
echo -e "\033[31mclash服务启动失败请检查配置文件\033[0m"
clashsh
fi
exit;
clashstart
clashsh
elif [[ $num == 2 ]]; then
echo 注意:测试结果不保证一定准确!
delay=`curl -kx socks5://127.0.0.1:7891 -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
echo -----------------------------------------------
if [ `echo ${#delay}` -gt 1 ];then
echo -e "\033[32m连接成功响应时间为"$delay" ms\033[0m"
else
echo -e "\033[31m连接超时请重试或检查节点配置\033[0m"
fi
clashsh
clashadv
elif [[ $num == 3 ]]; then
/etc/init.d/clash stop > /dev/null 2>&1
echo -----------------------------------------------
echo -e "\033[31mClash服务已停止\033[0m"
echo -----------------------------------------------
exit;
/etc/init.d/clash stop > /dev/null 2>&1
echo -----------------------------------------------
echo -e "\033[31mClash服务已停止\033[0m"
echo -----------------------------------------------
exit;
elif [[ $num == 4 ]]; then
sed -i '/auto_start*/'d $ccfg
echo -----------------------------------------------
if [ $auto_start = true ] > /dev/null 2>&1; then
/etc/init.d/clash disable
sed -i "1i\auto_start=false" $ccfg
echo -e "\033[33m已禁止Clash开机启动\033[0m"
else
/etc/init.d/clash enable
sed -i "1i\auto_start=true" $ccfg
echo -e "\033[32m已设置Clash开机启动\033[0m"
fi
clashsh
echo -----------------------------------------------
if [ "$auto1" = "允许clash开机启动" ]; then
/etc/init.d/clash enable
echo -e "\033[32m已设置Clash开机启动\033[0m"
else
/etc/init.d/clash disable
echo -e "\033[33m已禁止Clash开机启动\033[0m"
fi
clashsh
elif [[ $num == 5 ]]; then
echo -----------------------------------------------
@@ -615,64 +490,77 @@ 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
elif [[ $num == 6 ]]; then
clashlink
clashlink
elif [[ $num == 7 ]]; then
clashadv
elif [[ $num == 8 ]]; then
echo -----------------------------------------------
echo -e "\033[31m这里是隐藏的测试命令菜单\033[0m"
echo -e "\033[31m这里是测试命令菜单\033[0m"
echo 1 不能正常运行时手动运行clash查看报错信息
echo 2 查看系统53端口占用
echo 3 测试ssl加密aes-128-gcm跑分
echo 4 查看iptables端口转发详情
echo 5 查看config.yaml前40行
echo 6 测试代理服务器连通性
echo 0 返回上级目录!
read -p "请输入对应数字 > " num
if [[ $num == 0 ]]; then
clashsh
elif [[ $num == 1 ]]; then
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"
$cpath/clash -d $cpath & { sleep 3 ; kill $! & }
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"
exit;
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"
$clashdir/clash -d $clashdir & { sleep 3 ; kill $! & }
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"
exit;
elif [[ $num == 2 ]]; then
echo -----------------------------------------------
netstat -ntulp |grep 53
echo -----------------------------------------------
exit;
echo -----------------------------------------------
netstat -ntulp |grep 53
echo -----------------------------------------------
exit;
elif [[ $num == 3 ]]; then
echo -----------------------------------------------
openssl speed -multi 4 -evp aes-128-gcm
echo -----------------------------------------------
exit;
echo -----------------------------------------------
openssl speed -multi 4 -evp aes-128-gcm
echo -----------------------------------------------
exit;
elif [[ $num == 4 ]]; then
echo -----------------------------------------------
iptables -t nat -L PREROUTING --line-numbers
echo -----------------------------------------------
exit;
echo -----------------------------------------------
iptables -t nat -L PREROUTING --line-numbers
echo -----------------------------------------------
exit;
elif [[ $num == 5 ]]; then
echo -----------------------------------------------
sed -n '1,40p' $yaml
echo -----------------------------------------------
exit;
echo -----------------------------------------------
sed -n '1,40p' $yaml
echo -----------------------------------------------
exit;
elif [[ $num == 6 ]]; then
echo 注意:测试结果不保证一定准确!
delay=`curl -kx socks5://127.0.0.1:7891 -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
echo -----------------------------------------------
if [ `echo ${#delay}` -gt 1 ];then
echo -e "\033[32m连接成功响应时间为"$delay" ms\033[0m"
else
echo -e "\033[31m连接超时请重试或检查节点配置\033[0m"
fi
clashsh
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
clashsh
fi
elif [[ $num == 9 ]]; then
update
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
clashadv
fi
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
fi
exit 1
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
fi
exit 1
}