~凡是使用了小米增强启动的设备现在强制开启软固化功能
~优化小米增强启动逻辑,移除了默认启动延迟,加快启动速度
~修复内测源无法正确调用http端口的bug
This commit is contained in:
juewuy
2023-04-28 19:49:11 +08:00
parent f040a0f4b0
commit 3b73ab80cb
4 changed files with 30 additions and 35 deletions

View File

@@ -1600,7 +1600,7 @@ tools(){
} }
#获取设置默认显示 #获取设置默认显示
[ -n "$(cat /etc/crontabs/root 2>&1| grep otapredownload)" ] && mi_update=禁用 || mi_update=启用 [ -n "$(cat /etc/crontabs/root 2>&1| grep otapredownload)" ] && mi_update=禁用 || mi_update=启用
[ "$mi_autoSSH" = "已启用" ] && mi_autoSSH_type=32m已启用 || mi_autoSSH_type=31m未启用 [ "$mi_autoSSH" = "已启用" ] && mi_autoSSH_type=32m已启用 || mi_autoSSH_type=31m未配置
[ -f $clashdir/tun.ko ] && mi_tunfix=32m已启用 || mi_tunfix=31m未启用 [ -f $clashdir/tun.ko ] && mi_tunfix=32m已启用 || mi_tunfix=31m未启用
# #
echo ----------------------------------------------- echo -----------------------------------------------
@@ -1666,9 +1666,6 @@ tools(){
tools tools
elif [ "$num" = 6 ]; then elif [ "$num" = 6 ]; then
if [ "$mi_autoSSH" = "已启用" ];then
mi_autoSSH=禁用
else
if [ "$systype" = "mi_snapshot" ];then if [ "$systype" = "mi_snapshot" ];then
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[33m本功能使用软件命令进行固化不保证100%成功!\033[0m" echo -e "\033[33m本功能使用软件命令进行固化不保证100%成功!\033[0m"
@@ -1682,7 +1679,6 @@ tools(){
else else
echo 不支持的设备! echo 不支持的设备!
fi fi
fi
setconfig mi_autoSSH $mi_autoSSH setconfig mi_autoSSH $mi_autoSSH
setconfig mi_autoSSH_pwd $mi_autoSSH_pwd setconfig mi_autoSSH_pwd $mi_autoSSH_pwd
tools tools

View File

@@ -869,7 +869,7 @@ if [ -z "$release_new" ];then
source /tmp/clashversion 2>/dev/null source /tmp/clashversion 2>/dev/null
else else
echo -e "\033[31m检查更新失败请切换其他安装源\033[0m" echo -e "\033[31m检查更新失败请切换其他安装源\033[0m"
echo -e "\033[36m如全部安装源都无法使用请先运行服务后再使用更新\033[0m" echo -e "\033[36m如全部安装源都无法使用请先运行clash服务后再使用更新功能\033[0m"
sleep 1 sleep 1
setserver setserver
fi fi
@@ -1082,12 +1082,12 @@ userguide(){
fi fi
fi fi
#小米设备软固化 #小米设备软固化
if [ "$systype" = "mi_snapshot" ];then # if [ "$systype" = "mi_snapshot" ];then
echo ----------------------------------------------- # echo -----------------------------------------------
echo -e "\033[33m检测到为小米路由设备启用软固化可防止路由升级后丢失SSH\033[0m" # echo -e "\033[33m检测到为小米路由设备启用软固化可防止路由升级后丢失SSH\033[0m"
read -p "是否启用软固化功能?(1/0) > " res # read -p "是否启用软固化功能?(1/0) > " res
[ "$res" = 1 ] && setconfig mi_autoSSH 已启用 # [ "$res" = 1 ] && setconfig mi_autoSSH 已启用
fi # fi
#提示导入订阅或者配置文件 #提示导入订阅或者配置文件
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[32m是否导入配置文件\033[0m(这是运行前的最后一步)" echo -e "\033[32m是否导入配置文件\033[0m(这是运行前的最后一步)"

View File

@@ -34,27 +34,26 @@ tunfix(){
ln -s $clashdir/tun.ko ${ko_dir}/tun.ko ln -s $clashdir/tun.ko ${ko_dir}/tun.ko
} }
init(){ init(){
#等待启动完成
log_file=$(uci get system.@system[0].log_file)
while [ "$i" -lt 20 ]; do
sleep 3
[ -z "$(grep 'init complete' $log_file)" ] && i=20 || i=$((i + 1))
done
#初始化环境变量 #初始化环境变量
sed -i "/alias clash/d" $profile sed -i "/alias clash/d" $profile
sed -i "/export clashdir/d" $profile sed -i "/export clashdir/d" $profile
echo "alias clash=\"$clashdir/clash.sh\"" >>$profile echo "alias clash=\"$clashdir/clash.sh\"" >>$profile
echo "export clashdir=\"$clashdir\"" >>$profile echo "export clashdir=\"$clashdir\"" >>$profile
#软固化功能 #软固化功能
[ "$(grep 'mi_autoSSH=' $clashdir/mark | awk -F "=" '{print $2}')" = "已启用" ] && autoSSH autoSSH
#设置init.d服务 #设置init.d服务
cp -f $clashdir/clashservice /etc/init.d/clash cp -f $clashdir/clashservice /etc/init.d/clash
chmod 755 /etc/init.d/clash chmod 755 /etc/init.d/clash
#启动服务 #启动服务
if [ ! -f $clashdir/.dis_startup ]; then if [ ! -f $clashdir/.dis_startup ]; then
log_file=$(uci get system.@system[0].log_file)
while [ "$i" -lt 10 ]; do
sleep 5
[ -n "$(grep 'init complete' $log_file)" ] && i=10 || i=$((i + 1))
done
#AX6S/AX6000修复tun功能 #AX6S/AX6000修复tun功能
[ -f $clashdir/tun.ko -a ! -f /lib/modules/4.4.198/tun.ko ] && tunfix [ -f $clashdir/tun.ko ] && tunfix
#启动延迟
sleep 60
#启动服务 #启动服务
/etc/init.d/clash start /etc/init.d/clash start
/etc/init.d/clash enable /etc/init.d/clash enable
@@ -66,7 +65,7 @@ case "$1" in
init) init ;; init) init ;;
*) *)
if [ -z $(pidof clash) ];then if [ -z $(pidof clash) ];then
init init &
else else
sleep 10 sleep 10
$clashdir/start.sh restart $clashdir/start.sh restart

View File

@@ -1377,7 +1377,7 @@ webget)
if [ -n "$(pidof clash)" ];then if [ -n "$(pidof clash)" ];then
getconfig getconfig
[ -n "$authentication" ] && auth="$authentication@" [ -n "$authentication" ] && auth="$authentication@"
export https_proxy="http://${auth}127.0.0.1:$mix_port" export all_proxy="http://${auth}127.0.0.1:$mix_port"
url=$(echo $3 | sed 's#https://fastly.jsdelivr.net/gh/juewuy/ShellClash[@|/]#https://raw.githubusercontent.com/juewuy/ShellClash/#' | sed 's#https://gh.jwsc.eu.org/#https://raw.githubusercontent.com/juewuy/ShellClash/#') url=$(echo $3 | sed 's#https://fastly.jsdelivr.net/gh/juewuy/ShellClash[@|/]#https://raw.githubusercontent.com/juewuy/ShellClash/#' | sed 's#https://gh.jwsc.eu.org/#https://raw.githubusercontent.com/juewuy/ShellClash/#')
else else
url=$(echo $3 | sed 's#https://raw.githubusercontent.com/juewuy/ShellClash/#https://fastly.jsdelivr.net/gh/juewuy/ShellClash@#') url=$(echo $3 | sed 's#https://raw.githubusercontent.com/juewuy/ShellClash/#https://fastly.jsdelivr.net/gh/juewuy/ShellClash@#')
@@ -1390,7 +1390,7 @@ webget)
[ "$5" = "rediroff" ] && redirect='' || redirect='-L' [ "$5" = "rediroff" ] && redirect='' || redirect='-L'
[ "$6" = "skipceroff" ] && certificate='' || certificate='-k' [ "$6" = "skipceroff" ] && certificate='' || certificate='-k'
result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$url") result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$url")
[ "$result" != "200" ] && export https_proxy="" && result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$3") [ "$result" != "200" ] && export all_proxy="" && result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$3")
else else
if wget --version > /dev/null 2>&1;then if wget --version > /dev/null 2>&1;then
[ "$4" = "echooff" ] && progress='-q' || progress='-q --show-progress' [ "$4" = "echooff" ] && progress='-q' || progress='-q --show-progress'