~调整安装初始化流程
~优化下载更新流程
~修复下载更新相关bug
This commit is contained in:
juewuy 2020-08-15 10:51:12 +08:00
parent be13387179
commit 5cabf6559e
4 changed files with 37 additions and 30 deletions

Binary file not shown.

View File

@ -1 +1 @@
versionsh=0.9.3
versionsh=0.9.4

View File

@ -4,7 +4,7 @@
getconfig(){
#服务器地址
if [ -z "$update_url" ]; then
update_url=https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi/
update_url=https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi
fi
#文件路径
if [ -z "$clashdir" ];then
@ -79,13 +79,23 @@ if [ ! -f $clashdir/Country.mmdb ];then
echo -e "\033[31m没有找到GeoIP数据库文件请先下载数据库\033[0m"
source $clashdir/getdate.sh
getgeo
clashstart
fi
}
clashstart(){
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [ ! -f "$yaml" ];then
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"
fi
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];then
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -93,9 +103,11 @@ status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
echo -e "可以使用\033[30;47m http://clash.razord.top \033[0m管理内置规则"
echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m 9999 \033[0m"
echo -e "也可前往更新菜单安装本地Dashboard面板连接更稳定\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31mclash服务启动失败请检查配置文件\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fi
}
clashlink(){
@ -566,6 +578,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
elif [[ $num == 3 ]]; then
source $clashdir/getdate.sh
getgeo
update
elif [[ $num == 4 ]]; then
source $clashdir/getdate.sh
@ -749,18 +762,9 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
exit;
elif [[ $num == 1 ]]; then
if [ ! -f "$yaml" ];then
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"
fi
clashstart
clashsh
exit;
elif [[ $num == 2 ]]; then
clashadv

View File

@ -26,6 +26,7 @@ https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_On
EOF`
#如果传来的是Url链接则合成Https链接否则直接使用Https链接
if [ -z $Https ];then
echo $Url
Https="https://$Server/sub?target=clashr&new_name=true&url=$Url&insert=false&config=$Config"
markhttp=1
fi
@ -55,12 +56,13 @@ if [ "$result" != "200" ];then
read -p "是否更换后端地址后重试?[1/0] > " res
if [ "$res" = '1' ]; then
sed -i '/server_link=*/'d $ccfg
if [ "$server_link" = '7' ]; then
if [[ $server_link == 7 ]]; then
server_link=0
fi
server_link=$(($server_link + 1))
#echo $server_link
echo $server_link
sed -i "1i\server_link=$server_link" $ccfg
Https=""
getyaml
fi
#exit;
@ -72,20 +74,20 @@ else
mv $yaml $yaml.bak
fi
mv $yamlnew $yaml
echo 配置文件已生成!正在启clash使其生效
echo 配置文件已生成!正在启clash使其生效
#重启clash服务
/etc/init.d/clash restart
/etc/init.d/clash stop > /dev/null 2>&1
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];then
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32mclash服务已启动\033[0m"
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"
#将用户链接写入mark
#sed -i '/Https=*/'d $ccfg
#sed -i "7i\Https=\'$Https\'" $ccfg
echo -e "可以使用\033[30;47m http://clash.razord.top \033[0m管理内置规则"
echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m 9999 \033[0m"
echo -e "也可前往更新菜单安装本地Dashboard面板连接更稳定\033[0m"
sleep 1
clashsh
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -93,9 +95,11 @@ else
echo -e "\033[31mclash服务启动失败已还原配置文件并重启clash\033[0m"
mv $yaml.bak $yaml
/etc/init.d/clash start
sleep 1
clashsh
else
echo -e "\033[31mclash服务启动失败请利用测试菜单排查问题\033[0m"
sleep 1
clashsh
fi
fi
@ -153,6 +157,7 @@ do
sed -i '/Url=*/'d $ccfg
sed -i '/Https=*/'d $ccfg
sed -i "6i\Url=\'$Url\'" $ccfg
Https=""
#获取在线yaml文件
getyaml
fi
@ -278,7 +283,7 @@ clashcore_n=$clashcore
cpucore=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
[ -n "$(echo $cpucore | grep -E "linux.*aarch64.*")" ] && cpucore="armv8"
[ -n "$(echo $cpucore | grep -E "linux.*armv7.*")" ] && cpucore="armv7"
[ -n "$(echo $cpucore | grep -E "linux.*armv5.*")" ] && cpucore="armv5"
[ -n "$(echo $cpucore | grep -E "linux.*armv.*")" ] && cpucore="armv5"
[ -n "$(echo $cpucore | grep -E "linux.*mips.*")" ] && cpucore="mipsle-softfloat"
[ -n "$(echo $cpucore | grep -E "linux.*x86.*")" ] && cpucore="386"
###
@ -398,9 +403,7 @@ read -p "请输入对应数字 > " num
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32mGeoIP数据库文件下载成功\033[0m"
update
fi
update
}
getdb(){
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}';)