v1.5.5
~全面适配ax6s等小米镜像化系统设备 ~重做小米SSH工具,现在支持各类小米路由设备软件固化SSH ~重写开机启动逻辑,现在支持Padavan、梅林及小米镜像化系统
This commit is contained in:
108
scripts/clash.sh
108
scripts/clash.sh
@@ -35,26 +35,19 @@ getconfig(){
|
|||||||
[ -d /www/clash ] && dbdir=/www/clash && hostdir=/clash
|
[ -d /www/clash ] && dbdir=/www/clash && hostdir=/clash
|
||||||
#开机自启检测
|
#开机自启检测
|
||||||
if [ -f /etc/rc.common ];then
|
if [ -f /etc/rc.common ];then
|
||||||
[ -n "$(find /etc/rc.d -name '*clash')" ] && autostart=enable_rc || autostart=disable_rc
|
[ -n "$(find /etc/rc.d -name '*clash')" ] && autostart=enable || autostart=disable
|
||||||
elif [ -w /etc/systemd/system -o -w /usr/lib/systemd/system ];then
|
elif [ -w /etc/systemd/system -o -w /usr/lib/systemd/system ];then
|
||||||
[ -n "$(systemctl is-enabled clash.service 2>&1 | grep enable)" ] && autostart=enable_sys || autostart=disable_sys
|
[ -n "$(systemctl is-enabled clash.service 2>&1 | grep enable)" ] && autostart=enable || autostart=disable
|
||||||
fi
|
fi
|
||||||
#开机自启描述
|
#开机自启描述
|
||||||
if [ "$start_old" = "已开启" ]; then
|
if [ "$autostart" = "disable" -o -f $clashdir/.dis_startup ]; then
|
||||||
auto="\033[32m保守模式\033[0m"
|
|
||||||
auto1="代理本机:\033[36m$local_proxy\033[0m"
|
|
||||||
elif [ "$autostart" = "enable_rc" -o "$autostart" = "enable_sys" ]; then
|
|
||||||
auto="\033[32m已设置开机启动!\033[0m"
|
|
||||||
auto1="\033[36m禁用\033[0mclash开机启动"
|
|
||||||
elif [ "$autostart" = "disable_rc" -o "$autostart" = "disable_sys" ]; then
|
|
||||||
auto="\033[31m未设置开机启动!\033[0m"
|
auto="\033[31m未设置开机启动!\033[0m"
|
||||||
auto1="\033[36m允许\033[0mclash开机启动"
|
auto1="\033[36m允许\033[0mclash开机启动"
|
||||||
else
|
else
|
||||||
auto="\033[32m保守模式\033[0m"
|
auto="\033[32m已设置开机启动!\033[0m"
|
||||||
auto1="代理本机:\033[36m$local_proxy\033[0m"
|
auto1="\033[36m禁用\033[0mclash开机启动"
|
||||||
fi
|
fi
|
||||||
#获取运行模式
|
#获取运行模式
|
||||||
[ -z "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod=Redir模式
|
|
||||||
[ -z "$redir_mod" ] && redir_mod=纯净模式
|
[ -z "$redir_mod" ] && redir_mod=纯净模式
|
||||||
#获取运行状态
|
#获取运行状态
|
||||||
PID=$(pidof clash)
|
PID=$(pidof clash)
|
||||||
@@ -830,6 +823,28 @@ clashadv(){
|
|||||||
errornum
|
errornum
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
i=
|
i=
|
||||||
|
elif [ "$num" = 1 ]; then
|
||||||
|
echo -----------------------------------------------
|
||||||
|
if [ "$start_old" = "未开启" ] > /dev/null 2>&1; then
|
||||||
|
echo -e "\033[33m改为使用保守模式启动clash服务!!\033[0m"
|
||||||
|
echo -e "\033[31m注意:部分设备保守模式可能无法禁用开机启动!!\033[0m"
|
||||||
|
start_old=已开启
|
||||||
|
setconfig start_old $start_old
|
||||||
|
$clashdir/start.sh stop
|
||||||
|
else
|
||||||
|
if [ -f /etc/init.d/clash -o -w /etc/systemd/system -o -w /usr/lib/systemd/system ];then
|
||||||
|
echo -e "\033[32m改为使用默认方式启动clash服务!!\033[0m"
|
||||||
|
$clashdir/start.sh cronset "ShellClash初始化"
|
||||||
|
start_old=未开启
|
||||||
|
setconfig start_old $start_old
|
||||||
|
$clashdir/start.sh stop
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "\033[31m当前设备不支持以其他模式启动!!\033[0m"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
clashadv
|
||||||
|
|
||||||
elif [ "$num" = 2 ]; then
|
elif [ "$num" = 2 ]; then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
@@ -843,31 +858,7 @@ clashadv(){
|
|||||||
ipv6_support=未开启
|
ipv6_support=未开启
|
||||||
fi
|
fi
|
||||||
setconfig ipv6_support $ipv6_support
|
setconfig ipv6_support $ipv6_support
|
||||||
clashadv
|
clashadv
|
||||||
|
|
||||||
elif [ "$num" = 1 ]; then
|
|
||||||
echo -----------------------------------------------
|
|
||||||
if [ "$start_old" = "未开启" ] > /dev/null 2>&1; then
|
|
||||||
echo -e "\033[33m改为使用保守方式启动clash服务!!\033[0m"
|
|
||||||
echo -e "\033[36m此模式兼容性更好但无法禁用开机启动!!\033[0m"
|
|
||||||
start_old=已开启
|
|
||||||
setconfig start_old $start_old
|
|
||||||
$clashdir/start.sh stop
|
|
||||||
sleep 2
|
|
||||||
else
|
|
||||||
if [ -f /etc/init.d/clash -o -w /etc/systemd/system -o -w /usr/lib/systemd/system ];then
|
|
||||||
echo -e "\033[32m改为使用默认方式启动clash服务!!\033[0m"
|
|
||||||
$clashdir/start.sh cronset "ShellClash初始化"
|
|
||||||
start_old=未开启
|
|
||||||
setconfig start_old $start_old
|
|
||||||
$clashdir/start.sh stop
|
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "\033[31m当前设备不支持以其他模式启动!!\033[0m"
|
|
||||||
sleep 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
clashadv
|
|
||||||
|
|
||||||
elif [ "$num" = 3 ]; then
|
elif [ "$num" = 3 ]; then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
@@ -1104,6 +1095,7 @@ tools(){
|
|||||||
[ -z "$ssh_port" ] && ssh_port=10022
|
[ -z "$ssh_port" ] && ssh_port=10022
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[33m此功能仅针对使用Openwrt系统的设备生效,且不依赖clash服务\033[0m"
|
echo -e "\033[33m此功能仅针对使用Openwrt系统的设备生效,且不依赖clash服务\033[0m"
|
||||||
|
echo -e "\033[31m本功能不支持红米AX6S等镜像化系统设备,请勿尝试!\033[0m"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e " 1 \033[32m修改\033[0m外网访问端口:\033[36m$ssh_port\033[0m"
|
echo -e " 1 \033[32m修改\033[0m外网访问端口:\033[36m$ssh_port\033[0m"
|
||||||
echo -e " 2 \033[32m修改\033[0mSSH访问密码(请连续输入2次后回车)"
|
echo -e " 2 \033[32m修改\033[0mSSH访问密码(请连续输入2次后回车)"
|
||||||
@@ -1160,7 +1152,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=启用 || mi_autoSSH=禁用
|
[ "$mi_autoSSH" = "已启用" ] && mi_autoSSH_type=32m已启用 || mi_autoSSH_type=31m未启用
|
||||||
#
|
#
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[30;47m欢迎使用其他工具菜单:\033[0m"
|
echo -e "\033[30;47m欢迎使用其他工具菜单:\033[0m"
|
||||||
@@ -1172,10 +1164,10 @@ tools(){
|
|||||||
[ -f /etc/firewall.user ] && echo -e " 2 \033[32m配置\033[0m外网访问SSH"
|
[ -f /etc/firewall.user ] && echo -e " 2 \033[32m配置\033[0m外网访问SSH"
|
||||||
[ -f /etc/config/ddns -a -d "/etc/ddns" ] && echo -e " 3 配置DDNS服务(需下载相关脚本)"
|
[ -f /etc/config/ddns -a -d "/etc/ddns" ] && echo -e " 3 配置DDNS服务(需下载相关脚本)"
|
||||||
echo -e " 4 \033[32m流媒体预解析\033[0m————用于解决DNS解锁在TV应用上失效的问题"
|
echo -e " 4 \033[32m流媒体预解析\033[0m————用于解决DNS解锁在TV应用上失效的问题"
|
||||||
[ -x /usr/sbin/otapredownload ] && echo -e " 5 \033[33m$mi_update\033[0m小米系统自动更新\n\
|
[ -x /usr/sbin/otapredownload ] && echo -e " 5 \033[33m$mi_update\033[0m小米系统自动更新"
|
||||||
6 \033[33m$mi_autoSSH\033[0m小米设备自动启用SSH(依赖clash服务)"
|
[ -f /usr/sbin/otapredownload ] && echo -e " 6 小米设备软固化SSH ———— \033[$mi_autoSSH_type \033[0m"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e " 0 返回上级菜单 \033[0m"
|
echo -e " 0 返回上级菜单"
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
@@ -1233,13 +1225,14 @@ tools(){
|
|||||||
sleep 1
|
sleep 1
|
||||||
tools
|
tools
|
||||||
|
|
||||||
elif [ -x /usr/sbin/otapredownload ] && [ "$num" = 6 ]; then
|
elif [ -f /usr/sbin/otapredownload ] && [ "$num" = 6 ]; then
|
||||||
[ "$mi_autoSSH" = "禁用" ] && mi_autoSSH=启用 || mi_autoSSH=禁用
|
[ "$mi_autoSSH" = "已启用" ] && mi_autoSSH=禁用 || mi_autoSSH=已启用
|
||||||
setconfig mi_autoSSH $mi_autoSSH
|
setconfig mi_autoSSH $mi_autoSSH
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[32m本功能仅对已固化设备生效!未固化设备请先自行固化SSH!\033[0m"
|
echo -e "\033[33m本功能使用软件命令进行固化不保证100%成功!\033[0m"
|
||||||
echo -e "已\033[33m$mi_autoSSH\033[0m小米路由相关设备升级后自动启用SSH功能!"
|
echo -e "本功能需依赖clash服务,请确保clash为开机启动状态!"
|
||||||
sleep 1
|
echo -e "\033[33m如有问题请加群反馈:\033[36;4mhttps://t.me/clashfm\033[0m"
|
||||||
|
sleep 2
|
||||||
tools
|
tools
|
||||||
else
|
else
|
||||||
errornum
|
errornum
|
||||||
@@ -1422,23 +1415,16 @@ clashsh(){
|
|||||||
|
|
||||||
elif [ "$num" = 4 ]; then
|
elif [ "$num" = 4 ]; then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
if [ "$start_old" = "已开启" ];then
|
if [ "$autostart" = "enable" ]; then
|
||||||
localproxy
|
[ -d /etc/rc.d ] && cd /etc/rc.d && rm -rf *clash > /dev/null 2>&1 && cd - >/dev/null
|
||||||
elif [ "$autostart" = "enable_rc" ]; then
|
type systemctl >/dev/null 2>&1 && systemctl disable clash.service > /dev/null 2>&1
|
||||||
/etc/init.d/clash disable
|
touch $clashdir/.dis_startup
|
||||||
cd /etc/rc.d && rm -rf *clash > /dev/null 2>&1 && cd - >/dev/null
|
|
||||||
echo -e "\033[33m已禁止Clash开机启动!\033[0m"
|
echo -e "\033[33m已禁止Clash开机启动!\033[0m"
|
||||||
elif [ "$autostart" = "disable_rc" ]; then
|
elif [ "$autostart" = "disable" ]; then
|
||||||
/etc/init.d/clash enable
|
[ -f /etc/rc.common ] && /etc/init.d/clash enable
|
||||||
|
type systemctl >/dev/null 2>&1 && systemctl enable clash.service > /dev/null 2>&1
|
||||||
|
rm -rf $clashdir/.dis_startup
|
||||||
echo -e "\033[32m已设置Clash开机启动!\033[0m"
|
echo -e "\033[32m已设置Clash开机启动!\033[0m"
|
||||||
elif [ "$autostart" = "enable_sys" ]; then
|
|
||||||
systemctl disable clash.service > /dev/null 2>&1
|
|
||||||
echo -e "\033[33m已禁止Clash开机启动!\033[0m"
|
|
||||||
elif [ "$autostart" = "disable_sys" ]; then
|
|
||||||
systemctl enable clash.service > /dev/null 2>&1
|
|
||||||
echo -e "\033[32m已设置Clash开机启动!\033[0m"
|
|
||||||
else
|
|
||||||
echo -e "\033[32m当前系统不支持设置开启启动!\033[0m"
|
|
||||||
fi
|
fi
|
||||||
clashsh
|
clashsh
|
||||||
|
|
||||||
|
|||||||
@@ -322,8 +322,8 @@ clashlink(){
|
|||||||
#下载更新相关
|
#下载更新相关
|
||||||
gettar(){
|
gettar(){
|
||||||
$clashdir/start.sh webget /tmp/clashfm.tar.gz $tarurl
|
$clashdir/start.sh webget /tmp/clashfm.tar.gz $tarurl
|
||||||
[ "$?" = "1" ] && echo "文件下载失败!" && exit 1
|
[ "$?" != "0" ] && echo "文件下载失败,请尝试使用其他安装源!" && exit 1
|
||||||
$clashdir/start.sh stop
|
$clashdir/start.sh stop 2>/dev/null
|
||||||
#解压
|
#解压
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo 开始解压文件!
|
echo 开始解压文件!
|
||||||
@@ -335,8 +335,8 @@ gettar(){
|
|||||||
#判断系统类型写入不同的启动文件
|
#判断系统类型写入不同的启动文件
|
||||||
if [ -f /etc/rc.common ];then
|
if [ -f /etc/rc.common ];then
|
||||||
#设为init.d方式启动
|
#设为init.d方式启动
|
||||||
mv $clashdir/clashservice /etc/init.d/clash
|
cp -f $clashdir/clashservice /etc/init.d/clash
|
||||||
chmod 777 /etc/init.d/clash
|
chmod 755 /etc/init.d/clash
|
||||||
else
|
else
|
||||||
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
|
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
|
||||||
[ -w /usr/lib/systemd/system ] && sysdir=/usr/lib/systemd/system
|
[ -w /usr/lib/systemd/system ] && sysdir=/usr/lib/systemd/system
|
||||||
@@ -347,16 +347,16 @@ gettar(){
|
|||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
else
|
else
|
||||||
#设为保守模式启动
|
#设为保守模式启动
|
||||||
sed -i '/start_old=*/'d $clashdir/mark
|
setconfig start_old 已开启
|
||||||
echo start_old=已开启 >> $clashdir/mark
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
#修饰文件及版本号
|
#修饰文件及版本号
|
||||||
shtype=sh && [ -n "$(ls -l /bin/sh|grep -oE 'dash|show|bash')" ] && shtype=bash
|
shtype=sh && [ -n "$(ls -l /bin/sh|grep -oE 'dash|show|bash')" ] && shtype=bash
|
||||||
sed -i "s|/bin/sh|/bin/$shtype|" $clashdir/start.sh
|
sed -i "s|/bin/sh|/bin/$shtype|" $clashdir/start.sh
|
||||||
chmod 777 $clashdir/start.sh
|
chmod 755 $clashdir/start.sh
|
||||||
sed -i '/versionsh_l=*/'d $clashdir/mark
|
setconfig versionsh_l $release_new
|
||||||
echo versionsh_l=$release_new >> $clashdir/mark
|
#设置更新地址
|
||||||
|
[ -n "$url" ] && setconfig update_url $url
|
||||||
#设置环境变量
|
#设置环境变量
|
||||||
[ -w /opt/etc/profile ] && profile=/opt/etc/profile
|
[ -w /opt/etc/profile ] && profile=/opt/etc/profile
|
||||||
[ -w /jffs/configs/profile.add ] && profile=/jffs/configs/profile.add
|
[ -w /jffs/configs/profile.add ] && profile=/jffs/configs/profile.add
|
||||||
@@ -372,10 +372,25 @@ gettar(){
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
#华硕/Padavan额外设置
|
#华硕/Padavan额外设置
|
||||||
[ -n "$systype" ] && sed -i '/ShellClash初始化/'d $initdir && echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
[ -n "$initdir" ] && {
|
||||||
|
sed -i '/ShellClash初始化/'d $initdir && touch $initdir && echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
||||||
|
setconfig initdir $initdir
|
||||||
|
}
|
||||||
|
#小米镜像化OpenWrt额外设置
|
||||||
|
if [ "$systype" = "mi_snapshot" ];then
|
||||||
|
chmod 755 $clashdir/misnap_init.sh
|
||||||
|
uci set firewall.ShellClash=include
|
||||||
|
uci set firewall.ShellClash.type='script'
|
||||||
|
uci set firewall.ShellClash.path='/data/clash/misnap_init.sh'
|
||||||
|
uci set firewall.ShellClash.enabled='1'
|
||||||
|
uci commit firewall
|
||||||
|
setconfig systype $systype
|
||||||
|
else
|
||||||
|
rm -rf $clashdir/misnap_init.sh
|
||||||
|
rm -rf $clashdir/clashservice
|
||||||
|
fi
|
||||||
#删除临时文件
|
#删除临时文件
|
||||||
rm -rf /tmp/clashfm.tar.gz
|
rm -rf /tmp/clashfm.tar.gz
|
||||||
rm -rf $clashdir/clashservice
|
|
||||||
rm -rf $clashdir/clash.service
|
rm -rf $clashdir/clash.service
|
||||||
}
|
}
|
||||||
getsh(){
|
getsh(){
|
||||||
|
|||||||
43
scripts/misnap_init.sh
Normal file
43
scripts/misnap_init.sh
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Copyright (C) Juewuy
|
||||||
|
|
||||||
|
clashdir=/data/clash
|
||||||
|
profile=/etc/profile
|
||||||
|
|
||||||
|
log(){
|
||||||
|
dir=$clashdir/ui/log
|
||||||
|
echo `date`ssh状态获取 >> $dir
|
||||||
|
nvram get telnet_en >> $dir
|
||||||
|
nvram get ssh_en >> $dir
|
||||||
|
nvram get uart_en >> $dir
|
||||||
|
uci -c /usr/share/xiaoqiang get xiaoqiang_version.version.CHANNEL >> $dir
|
||||||
|
grep 'channel=.*' /etc/init.d/dropbear >> $dir
|
||||||
|
/etc/init.d/dropbear enabled
|
||||||
|
echo dropbear自启状态:$? >> $dir
|
||||||
|
}
|
||||||
|
|
||||||
|
#还原SSH秘钥
|
||||||
|
ln -sf $clashdir/dropbear_rsa_host_key /etc/dropbear/dropbear_rsa_host_key
|
||||||
|
|
||||||
|
#h初始化环境变量
|
||||||
|
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
||||||
|
echo "export clashdir=\"$clashdir\"" >> $profile
|
||||||
|
|
||||||
|
#设置init.d服务并启动clash服务
|
||||||
|
ln -sf $clashdir/clashservice /etc/init.d/clash
|
||||||
|
chmod 755 /etc/init.d/clash
|
||||||
|
|
||||||
|
log
|
||||||
|
|
||||||
|
[ -f $clashdir/.dis_startup ] || {
|
||||||
|
log_file=`uci get system.@system[0].log_file`
|
||||||
|
while [ "$i" -lt 10 ];do
|
||||||
|
sleep 3
|
||||||
|
[ -n "$(grep 'init complete' $log_file)" ] && i=10 || i=$((i+1))
|
||||||
|
done
|
||||||
|
/etc/init.d/clash start
|
||||||
|
/etc/init.d/clash enable
|
||||||
|
}
|
||||||
|
|
||||||
|
sleep 10
|
||||||
|
log
|
||||||
@@ -82,14 +82,54 @@ mark_time(){
|
|||||||
sed -i '/start_time*/'d $clashdir/mark
|
sed -i '/start_time*/'d $clashdir/mark
|
||||||
echo start_time=$start_time >> $clashdir/mark
|
echo start_time=$start_time >> $clashdir/mark
|
||||||
}
|
}
|
||||||
|
steaming(){
|
||||||
|
getconfig
|
||||||
|
#设置循环检测clashDNS端口
|
||||||
|
ns_type=$(nslookup -version 2>&1 | grep -io busybox)
|
||||||
|
ns_lookup(){
|
||||||
|
[ -n "$ns_type" ] && \
|
||||||
|
nslookup $1 127.0.0.1:${dns_port} > /dev/null 2>&1 || \
|
||||||
|
nslookup -port=${dns_port} $1 127.0.0.1 > /dev/null 2>&1
|
||||||
|
}
|
||||||
|
while [ "$i" != 0 ];do
|
||||||
|
[ "$j" = 60 ] && exit 1
|
||||||
|
sleep 1
|
||||||
|
ns_lookup baidu.com
|
||||||
|
i=$?
|
||||||
|
j=$((j+1))
|
||||||
|
done
|
||||||
|
steaming_dns(){
|
||||||
|
steaming_dir=$clashdir/steaming/${steaming_type}_Domains.list
|
||||||
|
if [ ! -f "$steaming_dir" ];then
|
||||||
|
echo 未找到$steaming_type域名数据库,正在下载!
|
||||||
|
mkdir -p $clashdir/steaming
|
||||||
|
$0 webget "$steaming_dir" "$update_url/bin/${steaming_type}_Domains.list"
|
||||||
|
[ "$?" = "1" ] && logger "$steaming_type数据库文件下载失败"
|
||||||
|
fi
|
||||||
|
if [ -f "$steaming_dir" ];then
|
||||||
|
for line in $(cat $steaming_dir);do
|
||||||
|
[ -n "$line" ] && ns_lookup "$line"
|
||||||
|
done >/dev/null 2>&1
|
||||||
|
echo "$steaming_type域名预解析完成!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
echo
|
||||||
|
echo "正在后台进行流媒体预解析服务,请耐心等待!"
|
||||||
|
[ "$netflix_pre" = "已开启" ] && steaming_type=Netflix && steaming_dns
|
||||||
|
[ "$disneyP_pre" = "已开启" ] && steaming_type=Disney_Plus && steaming_dns
|
||||||
|
echo "请输入回车继续!"
|
||||||
|
}
|
||||||
autoSSH(){
|
autoSSH(){
|
||||||
#自动开启SSH
|
#自动开启SSH
|
||||||
|
echo `date`ssh状态设置 >> /data/clash/ui/log
|
||||||
nvram set telnet_en=1
|
nvram set telnet_en=1
|
||||||
nvram set uart_en=1
|
|
||||||
nvram set ssh_en=1
|
nvram set ssh_en=1
|
||||||
|
nvram set uart_en=1
|
||||||
nvram commit
|
nvram commit
|
||||||
|
uci -c /usr/share/xiaoqiang set xiaoqiang_version.version.CHANNEL='stable'
|
||||||
|
uci -c /usr/share/xiaoqiang commit xiaoqiang_version.version
|
||||||
sed -i 's/channel=.*/channel="debug"/g' /etc/init.d/dropbear
|
sed -i 's/channel=.*/channel="debug"/g' /etc/init.d/dropbear
|
||||||
/etc/init.d/dropbear start
|
/etc/init.d/dropbear restart
|
||||||
}
|
}
|
||||||
#配置文件相关
|
#配置文件相关
|
||||||
getyaml(){
|
getyaml(){
|
||||||
@@ -765,7 +805,7 @@ afstart(){
|
|||||||
cronset '#每10分钟保存节点配置' "*/10 * * * * test -n \"\$(pidof clash)\" && $clashdir/start.sh web_save #每10分钟保存节点配置"
|
cronset '#每10分钟保存节点配置' "*/10 * * * * test -n \"\$(pidof clash)\" && $clashdir/start.sh web_save #每10分钟保存节点配置"
|
||||||
[ -f $clashdir/web_save ] && web_restore & #后台还原面板配置
|
[ -f $clashdir/web_save ] && web_restore & #后台还原面板配置
|
||||||
#自动开启SSH
|
#自动开启SSH
|
||||||
[ "$autoSSH" = "禁用" ] && [ -z "$(pidof sshd)" -o -z "$(netstat -ntul | grep :22)" ] && autoSSH 2>/dev/null
|
[ "$mi_autoSSH" = "已启用" ] && [ -z "$(pidof dropbear)" -o -z "$(netstat -ntul | grep :22)" ] && autoSSH 2>/dev/null
|
||||||
else
|
else
|
||||||
logger "clash服务启动失败!请查看报错信息!" 31
|
logger "clash服务启动失败!请查看报错信息!" 31
|
||||||
$bindir/clash -t -d $bindir
|
$bindir/clash -t -d $bindir
|
||||||
@@ -846,15 +886,13 @@ init)
|
|||||||
elif [ -d "/jffs/clash" ];then
|
elif [ -d "/jffs/clash" ];then
|
||||||
clashdir=/jffs/clash
|
clashdir=/jffs/clash
|
||||||
profile=/jffs/configs/profile.add
|
profile=/jffs/configs/profile.add
|
||||||
elif [ -d "/data/clash" ];then
|
else
|
||||||
clashdir=/data/clash
|
clashdir=$(echo $0 | grep -oE '.*clash')
|
||||||
profile=/etc/profile
|
profile=/etc/profile
|
||||||
#开启SSH
|
|
||||||
autoSSH 2>/dev/null
|
|
||||||
fi
|
fi
|
||||||
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
||||||
echo "export clashdir=\"$clashdir\"" >> $profile
|
echo "export clashdir=\"$clashdir\"" >> $profile
|
||||||
$0 start
|
[ -f $clashdir/.dis_startup ] || $0 start
|
||||||
;;
|
;;
|
||||||
getyaml)
|
getyaml)
|
||||||
getconfig
|
getconfig
|
||||||
@@ -928,41 +966,7 @@ unset_proxy)
|
|||||||
sed -i '/ALL_PROXY/'d $profile
|
sed -i '/ALL_PROXY/'d $profile
|
||||||
;;
|
;;
|
||||||
steaming)
|
steaming)
|
||||||
getconfig
|
steaming
|
||||||
#设置循环检测clashDNS端口
|
|
||||||
ns_type=$(nslookup -version 2>&1 | grep -io busybox)
|
|
||||||
ns_lookup(){
|
|
||||||
[ -n "$ns_type" ] && \
|
|
||||||
nslookup $1 127.0.0.1:${dns_port} > /dev/null 2>&1 || \
|
|
||||||
nslookup -port=${dns_port} $1 127.0.0.1 > /dev/null 2>&1
|
|
||||||
}
|
|
||||||
while [ "$i" != 0 ];do
|
|
||||||
[ "$j" = 60 ] && exit 1
|
|
||||||
sleep 1
|
|
||||||
ns_lookup baidu.com
|
|
||||||
i=$?
|
|
||||||
j=$((j+1))
|
|
||||||
done
|
|
||||||
steaming_dns(){
|
|
||||||
steaming_dir=$clashdir/steaming/${steaming_type}_Domains.list
|
|
||||||
if [ ! -f "$steaming_dir" ];then
|
|
||||||
echo 未找到$steaming_type域名数据库,正在下载!
|
|
||||||
mkdir -p $clashdir/steaming
|
|
||||||
$0 webget "$steaming_dir" "$update_url/bin/${steaming_type}_Domains.list"
|
|
||||||
[ "$?" = "1" ] && logger "$steaming_type数据库文件下载失败"
|
|
||||||
fi
|
|
||||||
if [ -f "$steaming_dir" ];then
|
|
||||||
for line in $(cat $steaming_dir);do
|
|
||||||
[ -n "$line" ] && ns_lookup "$line"
|
|
||||||
done >/dev/null 2>&1
|
|
||||||
echo "$steaming_type域名预解析完成!"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
echo
|
|
||||||
echo "正在后台进行流媒体预解析服务,请耐心等待!"
|
|
||||||
[ "$netflix_pre" = "已开启" ] && steaming_type=Netflix && steaming_dns
|
|
||||||
[ "$disneyP_pre" = "已开启" ] && steaming_type=Disney_Plus && steaming_dns
|
|
||||||
echo "请输入回车继续!"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user