From c5e28110cbcaebe2ee86ea00c4bde03a0fa1ea25 Mon Sep 17 00:00:00 2001 From: juewuy Date: Sat, 13 Apr 2024 11:19:01 +0800 Subject: [PATCH] =?UTF-8?q?~=E5=A2=9E=E5=8A=A0=E5=BC=80=E6=9C=BA=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E7=9A=84=E8=81=94=E7=BD=91=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E6=9C=BA=E5=88=B6=EF=BC=8C=E4=BB=A5=E4=BF=AE=E5=A4=8D=E9=83=A8?= =?UTF-8?q?=E5=88=86=E8=AE=BE=E5=A4=87=E5=BC=80=E6=9C=BA=E8=87=AA=E5=90=AF?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20~=E5=B0=9D?= =?UTF-8?q?=E8=AF=95=E5=A2=9E=E5=8A=A0=E5=90=AF=E5=8A=A8=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E8=87=B310s=20~=E5=B0=86singbox=E5=86=85?= =?UTF-8?q?=E6=A0=B8DNS=E7=9A=84=E9=BB=98=E8=AE=A4reverse=5Fmapping?= =?UTF-8?q?=E5=8F=8Aindependent=5Fcache=E5=8A=9F=E8=83=BD=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BAfalse=20~=E7=A7=BB=E9=99=A4=E4=BA=86wget?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E7=9A=84=E9=87=8D=E8=AF=95=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=85=BC=E5=AE=B9=E6=9B=B4=E5=A4=9A=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=20~=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/menu.sh | 2 +- scripts/start.sh | 31 ++++++++++++++++++++++--------- scripts/update.sh | 6 +++--- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/scripts/menu.sh b/scripts/menu.sh index 379bd84..71037d8 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -193,7 +193,7 @@ start_core(){ ${CRASHDIR}/start.sh start #设置循环检测以判定服务启动是否成功 i=1 - while [ -z "$test" -a "$i" -lt 5 ];do + while [ -z "$test" -a "$i" -lt 10 ];do sleep 1 if curl --version > /dev/null 2>&1;then test=$(curl -s http://127.0.0.1:${db_port}/configs | grep -o port) diff --git a/scripts/start.sh b/scripts/start.sh index 9dd9e0e..d43ded2 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -89,7 +89,7 @@ logger(){ #日志工具 if curl --version >/dev/null 2>&1;then curl -kfsSl -X POST --connect-timeout 3 -H "Content-Type: application/json; charset=utf-8" "$1" -d "$2" >/dev/null 2>&1 elif wget --version >/dev/null 2>&1;then - wget -Y on -q --timeout=3 -t 1 --method=POST --header="Content-Type: application/json; charset=utf-8" --body-data="$2" "$1" + wget -Y on -q --timeout=3 --method=POST --header="Content-Type: application/json; charset=utf-8" --body-data="$2" "$1" else echo "找不到有效的curl或wget应用,请先安装!" fi @@ -650,8 +650,8 @@ EOF { "query_type": [ "A", "AAAA" ], "server": "dns_fakeip", "rewrite_ttl": 1 } ], "final": "dns_direct", - "independent_cache": true, - "reverse_mapping": true, + "independent_cache": false, + "reverse_mapping": false, "fakeip": { "enabled": true, "inet4_range": "198.18.0.0/16", "inet6_range": "fc00::/16" } } } @@ -1573,12 +1573,25 @@ singbox_check(){ #singbox启动前检查 [ -n "$(cat ${CRASHDIR}/jsons/*.json | grep -oEi '"geosite":')" ] && ckgeo geosite.db geosite_cn.db return 0 } +network_check(){ #检查是否联网 + for host in 223.5.5.5 114.114.114.114 1.2.4.8 dns.alidns.com doh.pub doh.360.cn;do + ping -c 3 $host >/dev/null 2>&1 && exit 0 + sleep 2 + done + logger "当前设备无法连接网络,已取消开机启动!" 33 + exit 1 +} bfstart(){ #启动前 routing_mark=$((fwmark + 2)) - #延迟启动 - [ ! -f ${TMPDIR}/crash_start_time ] && [ -n "$start_delay" ] && [ "$start_delay" -gt 0 ] && { - logger "ShellCrash将延迟$start_delay秒启动" 31 pushoff - sleep $start_delay + #启动前等待 + [ ! -f ${TMPDIR}/crash_start_time ] && { + #延迟启动 + [ -n "$start_delay" ] && [ "$start_delay" -gt 0 ] && { + logger "ShellCrash将延迟$start_delay秒启动" 31 pushoff + sleep $start_delay + } + #检测网络连接 + network_check } [ ! -d ${BINDIR}/ui ] && mkdir -p ${BINDIR}/ui [ -z "$crashcore" ] && crashcore=clash @@ -1636,7 +1649,7 @@ afstart(){ #启动后 [ -z "$firewall_area" ] && firewall_area=1 #设置循环检测面板端口以判定服务启动是否成功 i=1 - while [ -z "$test" -a "$i" -lt 5 ];do + while [ -z "$test" -a "$i" -lt 10 ];do sleep 1 if curl --version > /dev/null 2>&1;then test=$(curl -s http://127.0.0.1:${db_port}/configs | grep -o port) @@ -1843,7 +1856,7 @@ webget) [ "$4" = "echooff" ] && progress='-q' || progress='-q --show-progress' [ "$5" = "rediroff" ] && redirect='--max-redirect=0' || redirect='' [ "$6" = "skipceroff" ] && certificate='' || certificate='--no-check-certificate' - timeout='--timeout=5 -t 2' + timeout='--timeout=5' fi [ "$4" = "echoon" ] && progress='' [ "$4" = "echooff" ] && progress='-q' diff --git a/scripts/update.sh b/scripts/update.sh index b7d1399..0c166c5 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -75,7 +75,7 @@ setrules(){ #自定义规则 '') ;; *) text=$(cat $YAMLSDIR/rules.yaml | grep -Ev '^#' | sed -n "$num p" | awk '{print $2}') - if [ -n $text ];then + if [ -n "$text" ];then sed -i "/$text/d" $YAMLSDIR/rules.yaml sleep 1 del_rule_type @@ -676,7 +676,7 @@ setproviders(){ #自定义providers [ "$res" = "1" ] && rm -rf $CRASHDIR/configs/providers.cfg setproviders ;; - d) + e) echo -e "\033[33m将清空 $CRASHDIR/providers 目录下所有内容\033[0m" read -p "是否继续?(1/0) > " res [ "$res" = "1" ] && rm -rf $CRASHDIR/providers @@ -1651,7 +1651,7 @@ setcustgeo(){ #下载自定义数据库文件 } setgeo(){ #数据库选择菜单 source $CFG_PATH > /dev/null - [ -n "$cn_mini.mmdb_v" ] && geo_type_des=精简版 || geo_type_des=全球版 + [ -n "$cn_mini_v" ] && geo_type_des=精简版 || geo_type_des=全球版 echo ----------------------------------------------- echo -e "\033[36m请选择需要更新的Geo/CN数据库文件:\033[0m" echo -e "\033[36m全球版GeoIP和精简版CN-IP数据库不共存\033[0m"