From 72321edca554ff00bd0ca53a825f8a99e5eb70b9 Mon Sep 17 00:00:00 2001 From: juewuy Date: Sun, 20 Feb 2022 14:40:28 +0800 Subject: [PATCH] =?UTF-8?q?v1.5.2=20~=E5=A2=9E=E5=8A=A0DDNS=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=20~=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E6=9C=AC=E6=9C=BAhosts=E5=8A=9F=E8=83=BD=20~=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=AE=89=E8=A3=85=E8=84=9A=E6=9C=AC=20~=E5=85=AC?= =?UTF-8?q?=E7=BD=91=E8=AE=BF=E9=97=AE=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?ipv6=E6=94=AF=E6=8C=81=20~=E4=BC=98=E5=8C=96Geosite=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E4=B8=8B=E8=BD=BD=E6=A3=80=E6=B5=8B=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=20~=E5=B0=9D=E8=AF=95=E5=B1=8F=E8=94=BDOpenWrt=E8=87=AA?= =?UTF-8?q?=E5=B8=A653=E7=AB=AF=E5=8F=A3=E5=8A=AB=E6=8C=81=20~=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=A2=85=E6=9E=97/=E5=8D=8E=E7=A1=95=E7=AD=89?= =?UTF-8?q?=E4=BD=8E=E5=86=85=E6=A0=B8=E8=AE=BE=E5=A4=87=E9=80=80=E5=87=BA?= =?UTF-8?q?SSH=E5=AF=BC=E8=87=B4=E8=BF=9B=E7=A8=8B=E9=80=80=E5=87=BA?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20~=E4=BB=A3=E7=A0=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=8F=8Abug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/clash.service | 2 +- scripts/clash.sh | 4 +--- scripts/start.sh | 23 ++++++++++++++++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/scripts/clash.service b/scripts/clash.service index 1f5fc14..5c80303 100644 --- a/scripts/clash.service +++ b/scripts/clash.service @@ -5,7 +5,7 @@ After=network.target [Service] Type=simple User=root -ExecStart=/etc/clash/clash -d /etc/clash +ExecStart=/etc/clash/clash -d /etc/clash >/dev/null ExecStartPost=/etc/clash/start.sh afstart Restart=on-failure RestartSec=3s diff --git a/scripts/clash.sh b/scripts/clash.sh index 2eadea9..4cf6dd0 100644 --- a/scripts/clash.sh +++ b/scripts/clash.sh @@ -960,10 +960,8 @@ clashadv(){ elif [ "$num" = 7 ]; then [ ! -f $clashdir/user.yaml ] && cat > $clashdir/user.yaml < $clashdir/rules.yaml <> $tmpdir/hosts.yaml + done < $hosts_dir + fi #合并文件 - cut -c 1- $tmpdir/set.yaml $yaml_user $tmpdir/proxy.yaml > $tmpdir/config.yaml + cut -c 1- $tmpdir/set.yaml $tmpdir/hosts.yaml $yaml_user $tmpdir/proxy.yaml > $tmpdir/config.yaml #插入自定义规则 sed -i "/#自定义规则/d" $tmpdir/config.yaml space=$(sed -n '/^rules/{n;p}' $tmpdir/proxy.yaml | grep -oE '^\ *') #获取空格数 if [ -f $clashdir/rules.yaml ];then sed -i '/^$/d' $clashdir/rules.yaml && echo >> $clashdir/rules.yaml #处理换行 while read line;do - [ -z "$(echo "$line " | grep '#')" ] && \ + [ -z "$(echo "$line" | grep '#')" ] && \ [ -n "$(echo "$line" | grep '\-\ ')" ] && \ line=$(echo "$line" | sed 's#/#\\/#') && \ sed -i "/^rules:/a\\$space$line #自定义规则" $tmpdir/config.yaml @@ -303,6 +315,7 @@ EOF fi rm -f $tmpdir/set.yaml rm -f $tmpdir/proxy.yaml + rm -f $tmpdir/hosts.yaml } #设置路由规则 cn_ip_route(){ @@ -753,7 +766,8 @@ start_old(){ if [ "$local_proxy" = "已开启" -a "$local_type" = "iptables增强模式" ];then su shellclash -c "$bindir/clash -d $bindir >/dev/null" & else - $bindir/clash -d $bindir >/dev/null & + [ -n "$(command -v nohup)" ] && nohup=nohup + $nohup $bindir/clash -d $bindir >/dev/null 2>&1 & fi afstart $0 daemon @@ -773,6 +787,8 @@ start) #检测必须文件并下载 bfstart stop_iptables #清理iptables + #使用内置规则强行覆盖config配置文件 + [ "$modify_yaml" != "已开启" ] && modify_yaml #使用不同方式启动clash服务 if [ "$start_old" = "已开启" ];then start_old @@ -790,6 +806,7 @@ stop) #删除守护进程&面板配置自动保存 cronset "clash保守模式守护进程" cronset "保存节点配置" + cronset "流媒体预解析" #多种方式结束进程 if [ -f /etc/rc.common ];then /etc/init.d/clash stop >/dev/null 2>&1