From 023787a7124b8b37171adfa54c8bbb8d68886164 Mon Sep 17 00:00:00 2001 From: juewuy Date: Mon, 16 Sep 2024 16:35:12 +0800 Subject: [PATCH] =?UTF-8?q?~=E4=B8=BA=E5=8D=8E=E7=A1=95=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9F=BA=E4=BA=8E=E4=B8=8B=E8=BD=BD=E5=A4=A7?= =?UTF-8?q?=E5=B8=88=E7=9A=84=E8=87=AA=E5=90=AF=E9=80=89=E9=A1=B9(?= =?UTF-8?q?=E6=9C=AA=E6=B5=8B=E8=AF=95)=20~=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E8=AE=BE=E5=A4=87=E5=9B=A0=E6=9C=AA=E5=BC=80=E6=9C=BA?= =?UTF-8?q?=E5=8A=A0=E8=BD=BDtproxy=E7=9B=B8=E5=85=B3=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E8=80=8C=E5=AF=BC=E8=87=B4tproxy=E4=BB=A3=E7=90=86=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E7=9A=84=E9=97=AE=E9=A2=98=20~=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=9C=AA=E5=AE=89=E8=A3=85iptables=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=90=AF=E5=8A=A8=E6=97=B6=E7=9A=84=E5=A4=A7=E9=87=8F?= =?UTF-8?q?=E6=97=A0=E6=84=8F=E4=B9=89=E6=8A=A5=E9=94=99=20~=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E4=BC=98=E5=8C=96=E5=8F=8A=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 23 ++++++++++++++++++++--- scripts/init.sh | 29 +++++++++++++++++++++++++---- scripts/menu.sh | 2 +- scripts/start.sh | 8 ++++---- 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index 0f3c1e6..4f87ef9 100644 --- a/install.sh +++ b/install.sh @@ -62,7 +62,7 @@ gettar(){ mkdir -p $CRASHDIR > /dev/null tar -zxf '/tmp/ShellCrash.tar.gz' -C $CRASHDIR/ || tar -zxf '/tmp/ShellCrash.tar.gz' --no-same-owner -C $CRASHDIR/ if [ -f $CRASHDIR/init.sh ];then - source $CRASHDIR/init.sh >/dev/null + . $CRASHDIR/init.sh >/dev/null else rm -rf /tmp/ShellCrash.tar.gz $echo "\033[33m文件解压失败!\033[0m" @@ -82,6 +82,16 @@ setdir(){ set_usb_dir fi } + set_asus_dir(){ + echo -e "请选择U盘目录" + du -hL /tmp/mnt | awk '{print " "NR" "$2" "$1}' + read -p "请输入相应数字 > " num + dir=$(du -hL /tmp/mnt | awk '{print $2}' | sed -n "$num"p) + if [ ! -f "$dir/asusware.arm/etc/init.d/S50downloadmaster" ];then + echo -e "\033[31m未找到下载大师自启文件:$dir/asusware.arm/etc/init.d/S50downloadmaster,请检查设置!\033[0m" + set_asus_dir + fi + } set_cust_dir(){ echo ----------------------------------------------- echo '可用路径 剩余空间:' @@ -123,6 +133,7 @@ if [ -n "$systype" ];then $echo "\033[33m检测到当前设备为华硕固件,请选择安装方式\033[0m" $echo " 1 基于USB设备安装(限23年9月之前固件,须插入\033[31m任意\033[0mUSB设备)" $echo " 2 基于自启脚本安装(仅支持梅林及部分官改固件)" + $echo " 3 基于下载大师安装(支持最新固件,限ARM设备,须插入U盘或移动硬盘)" $echo " 0 退出安装" echo ----------------------------------------------- read -p "请输入相应数字 > " num @@ -131,11 +142,17 @@ if [ -n "$systype" ];then read -p "将脚本安装到USB存储/系统闪存?(1/0) > " res [ "$res" = "1" ] && set_usb_dir || dir=/jffs usb_status=1 - ;; + ;; 2) $echo "如无法正常开机启动,请重新使用USB方式安装!" sleep 2 - dir=/jffs ;; + dir=/jffs + ;; + 3) + echo -e "请先在路由器网页后台安装下载大师,之后选择外置存储所在目录!" + sleep 2 + set_asus_dir + ;; *) exit 1 ;; esac diff --git a/scripts/init.sh b/scripts/init.sh index b3e8c57..f58d0d8 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -17,6 +17,16 @@ setdir(){ set_usb_dir fi } + set_asus_dir(){ + echo -e "请选择U盘目录" + du -hL /tmp/mnt | awk '{print " "NR" "$2" "$1}' + read -p "请输入相应数字 > " num + dir=$(du -hL /tmp/mnt | awk '{print $2}' | sed -n "$num"p) + if [ ! -f "$dir/asusware.arm/etc/init.d/S50downloadmaster" ];then + echo -e "\033[31m未找到下载大师自启文件:$dir/asusware.arm/etc/init.d/S50downloadmaster,请检查设置!\033[0m" + set_asus_dir + fi + } set_cust_dir(){ echo ----------------------------------------------- echo '可用路径 剩余空间:' @@ -55,8 +65,9 @@ if [ -n "$systype" ];then } [ "$systype" = "asusrouter" ] && { echo -e "\033[33m检测到当前设备为华硕固件,请选择安装方式\033[0m" - echo -e " 1 基于USB设备安装(通用,须插入\033[31m任意\033[0mUSB设备)" + echo -e " 1 基于USB设备安装(限23年9月之前固件,须插入\033[31m任意\033[0mUSB设备)" echo -e " 2 基于自启脚本安装(仅支持梅林及部分官改固件)" + echo -e " 3 基于下载大师安装(支持最新固件,限ARM设备,须插入U盘或移动硬盘)" echo -e " 0 退出安装" echo ----------------------------------------------- read -p "请输入相应数字 > " num @@ -65,13 +76,20 @@ if [ -n "$systype" ];then read -p "将脚本安装到USB存储/系统闪存?(1/0) > " res [ "$res" = "1" ] && set_usb_dir || dir=/jffs usb_status=1 - ;; + ;; 2) echo -e "如无法正常开机启动,请重新使用USB方式安装!" sleep 2 - dir=/jffs ;; + dir=/jffs + ;; + 3) + echo -e "请先在路由器网页后台安装下载大师,之后选择外置存储所在目录!" + sleep 2 + set_asus_dir + ;; *) - exit 1 ;; + exit 1 + ;; esac } [ "$systype" = "ng_snapshot" ] && dir=/tmp/mnt @@ -279,6 +297,9 @@ fi nvram set script_usbmount="$CRASHDIR/asus_usb_mount.sh" nvram commit } +#华硕下载大师启动额外设置 +[ -f "$dir/asusware.arm/etc/init.d/S50downloadmaster" ] && \ + sed -i "/^PATH=/a\\$CRASHDIR/start.sh init #ShellCrash初始化脚本" "$dir/asusware.arm/etc/init.d/S50downloadmaster" #删除临时文件 rm -rf /tmp/*rash*gz rm -rf /tmp/SC_tmp diff --git a/scripts/menu.sh b/scripts/menu.sh index b7aae9e..545df8e 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -1313,7 +1313,7 @@ set_redir_mod(){ #代理模式设置 redir_mod=Tproxy模式 set_redir_config } - elif [ -n "$(grep -E '^TPROXY$' /proc/net/ip_tables_targets)" ] ;then + elif grep -qE '^TPROXY$' /proc/net/ip_tables_targets || modprobe xt_TPROXY >/dev/null 2>&1;then redir_mod=Tproxy模式 set_redir_config else diff --git a/scripts/start.sh b/scripts/start.sh index c49a4a2..48474a8 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -44,8 +44,8 @@ getconfig() { #读取配置及全局变量 core_config="$CRASHDIR"/yamls/config.yaml fi #检查$iptable命令可用性 - iptables -h | grep -q '\-w' && iptable='iptables -w' || iptable=iptables - ip6tables -h | grep -q '\-w' && ip6table='ip6tables -w' || ip6table=ip6tables + ckcmd iptables && iptables -h | grep -q '\-w' && iptable='iptables -w' || iptable=iptables + ckcmd ip6tables && ip6tables -h | grep -q '\-w' && ip6table='ip6tables -w' || ip6table=ip6tables } setconfig() { #脚本配置工具 #参数1代表变量名,参数2代表变量值,参数3即文件路径 @@ -1070,6 +1070,7 @@ start_iptables() { #iptables配置总入口 } } [ "$redir_mod" = "Tproxy模式" ] && { + modprobe xt_TPROXY >/dev/null 2>&1 JUMP="TPROXY --on-port $tproxy_port --tproxy-mark $fwmark" #跳转劫持的具体命令 if $iptable -j TPROXY -h 2>/dev/null | grep -q '\--on-port'; then [ "$lan_proxy" = true ] && start_ipt_route iptables mangle PREROUTING shellcrash_mark all @@ -1487,11 +1488,10 @@ stop_firewall() { #还原防火墙配置 $ip6table -D INPUT -p udp --dport 443 $set_cn_ip -j REJECT 2>/dev/null #tun $ip6table -D FORWARD -o utun -j ACCEPT 2>/dev/null - $ip6table -D FORWARD -p udp --dport 443 -o utun -j REJECT >/dev/null 2>&1 #屏蔽QUIC [ "$dns_mod" != "fake-ip" -a "$cn_ipv6_route" = "已开启" ] && set_cn_ip6='-m set ! --match-set cn_ip6 dst' $ip6table -D INPUT -p udp --dport 443 $set_cn_ip6 -j REJECT 2>/dev/null - $ip6table -D FORWARD -p udp --dport 443 -o utun $set_cn_ip -j REJECT 2>/dev/null + $ip6table -D FORWARD -p udp --dport 443 -o utun $set_cn_ip6 -j REJECT 2>/dev/null #公网访问 $ip6table -D INPUT -p tcp --dport $mix_port -j REJECT 2>/dev/null $ip6table -D INPUT -p tcp --dport $mix_port -j ACCEPT 2>/dev/null