From f96a6a1dd0cbfcbc650af121b201f976ae7b16be Mon Sep 17 00:00:00 2001 From: juewuy Date: Tue, 30 Jan 2024 23:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8Dsingboxpure=E5=86=85=E6=A0=B8?= =?UTF-8?q?=20=E9=80=82=E9=85=8Dsingbox=E5=86=85=E6=A0=B8=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E6=9C=AC=E6=9C=BAhosts=E5=8A=9F=E8=83=BD=20debug?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E5=A2=9E=E5=8A=A0singbox=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=90=88=E5=B9=B6=E5=8A=9F=E8=83=BD=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96singbox=E5=86=85=E6=A0=B8dns=E5=8F=8Adns?= =?UTF-8?q?=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91=20=E4=BC=98=E5=8C=96json?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=87=E5=89=B2=E6=96=B9=E5=BC=8F=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96ip6tables=E6=A8=A1=E5=9D=97=E6=A3=80=E6=B5=8B?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/getdate.sh | 44 ++++++---- scripts/init.sh | 1 + scripts/menu.sh | 9 +- scripts/shellcrash.service | 1 + scripts/start.sh | 175 ++++++++++++++++++++----------------- 5 files changed, 128 insertions(+), 102 deletions(-) diff --git a/scripts/getdate.sh b/scripts/getdate.sh index 27ebb61..0d7cbe8 100644 --- a/scripts/getdate.sh +++ b/scripts/getdate.sh @@ -94,7 +94,7 @@ setrules(){ #自定义规则 echo -e " 1 新增自定义规则" echo -e " 2 移除自定义规则" echo -e " 3 清空规则列表" - [ "$crashcore" = singbox ] || echo -e " 4 配置节点绕过: \033[36m$proxies_bypass\033[0m" + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] || echo -e " 4 配置节点绕过: \033[36m$proxies_bypass\033[0m" echo -e " 0 返回上级菜单" read -p "请输入对应数字 > " num case $num in @@ -379,7 +379,7 @@ override(){ #配置文件覆写 echo ----------------------------------------------- echo -e " 1 自定义\033[32m端口及秘钥\033[0m" echo -e " 2 管理\033[36m自定义规则\033[0m" - [ "$crashcore" = singbox ] || { + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] || { echo -e " 3 管理\033[33m自定义节点\033[0m" echo -e " 4 管理\033[36m自定义策略组\033[0m" } @@ -416,7 +416,7 @@ override(){ #配置文件覆写 override ;; 5) - [ "$crashcore" = singbox ] && set_singbox_adv || set_clash_adv + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && set_singbox_adv || set_clash_adv sleep 3 override ;; @@ -651,7 +651,7 @@ set_core_config_link(){ #直接导入配置 set_core_config(){ #配置文件功能 [ -z "$rule_link" ] && rule_link=1 [ -z "$server_link" ] && server_link=1 - [ "$crashcore" = singbox ] && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml echo ----------------------------------------------- echo -e "\033[30;47m ShellCrash配置文件管理\033[0m" echo ----------------------------------------------- @@ -819,7 +819,7 @@ setcpucore(){ echo -e "不知道如何获取核心版本?请参考:\033[36;4mhttps://juewuy.github.io/bdaz\033[0m" echo ----------------------------------------------- read -p "请输入对应数字 > " num - setcpucore=$(echo $cpucore_list | awk '{print $"'"$num"'"}' ) + [ -n "$num" ] && setcpucore=$(echo $cpucore_list | awk '{print $"'"$num"'"}' ) if [ -z "$setcpucore" ];then echo -e "\033[31m请输入正确的处理器架构!\033[0m" sleep 1 @@ -830,7 +830,7 @@ setcpucore(){ fi } setcoretype(){ - [ "$crashcore" = singbox ] && core_old=singbox || core_old=clash + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_old=singbox || core_old=clash echo -e "\033[33m请确认该自定义内核的类型:\033[0m" echo -e " 1 Clash基础内核" echo -e " 2 Clash-Premium内核" @@ -843,7 +843,7 @@ setcoretype(){ 4) crashcore=singbox ;; *) crashcore=clash ;; esac - [ "$crashcore" = singbox ] && core_new=singbox || core_new=clash + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_new=singbox || core_new=clash } switch_core(){ #singbox和clash内核切换时提示是否保留文件 @@ -865,7 +865,7 @@ switch_core(){ setconfig geosite_cn_v } } - if [ "$crashcore" = singbox ];then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then COMMAND='"$TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons"' else COMMAND='"$TMPDIR/CrashCore -d $BINDIR -f $TMPDIR/config.yaml"' @@ -875,7 +875,7 @@ switch_core(){ getcore(){ [ -z "$crashcore" ] && crashcore=clashpre [ -z "$cpucore" ] && getcpucore - [ "$crashcore" = singbox ] && core_new=singbox || core_new=clash + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_new=singbox || core_new=clash #获取在线内核文件 echo ----------------------------------------------- echo 正在在线获取$crashcore核心文件…… @@ -900,7 +900,7 @@ getcore(){ } chmod +x ${TMPDIR}/CrashCore [ "$crashcore" = unknow ] && setcoretype - if [ "$crashcore" = singbox ];then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then core_v=$(${TMPDIR}/CrashCore version 2>/dev/null | grep version | awk '{print $3}') else core_v=$(${TMPDIR}/CrashCore -v 2>/dev/null | head -n 1 | sed 's/ linux.*//;s/.* //') @@ -964,7 +964,7 @@ setcore(){ #获取核心及版本信息 [ -z "$crashcore" ] && crashcore="unknow" [ ! -f ${CRASHDIR}/core.tar.gz ] && crashcore="未安装核心" - [ "$crashcore" = singbox ] && core_old=singbox || core_old=clash + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && core_old=singbox || core_old=clash ### echo ----------------------------------------------- [ -z "$cpucore" ] && getcpucore @@ -973,7 +973,7 @@ setcore(){ echo -e "\033[33m请选择需要使用的核心版本!\033[0m" echo -e "\033[36m如需本地上传,请将二进制文件上传至 /tmp 目录后重新运行crash命令\033[0m" echo ----------------------------------------------- - echo -e "1 \033[43;30m Clash \033[0m: \033[32m占用低\033[0m" + echo -e "1 \033[43;30m Clash \033[0m: \033[32m占用低\033[0m" echo -e " (开源基础内核) \033[33m不支持Tun、Rule-set等\033[0m" echo -e " 说明文档: \033[36;4mhttps://lancellc.gitbook.io\033[0m" echo @@ -981,17 +981,17 @@ setcore(){ echo -e " (sing-box主干) \033[33m不支持providers\033[0m" echo -e " 说明文档: \033[36;4mhttps://sing-box.sagernet.org\033[0m" echo - echo -e "3 \033[43;30m Mihomo \033[0m: \033[32m多功能,支持全面\033[0m" - echo -e " (Meta/Mihomo) \033[33m内存占用较高\033[0m" + echo -e "3 \033[43;30m Mihomo \033[0m: \033[32m多功能,支持全面\033[0m" + echo -e " (Meta/Mihomo) \033[33m内存占用较高\033[0m" echo -e " 说明文档: \033[36;4mhttps://wiki.metacubex.one\033[0m" echo - echo -e "4 \033[43;30m SingBoxP\033[0m: \033[32m支持ssr、providers、dns并发……\033[0m" + echo -e "4 \033[43;30m SingBoxP \033[0m: \033[32m支持ssr、providers、dns并发……\033[0m" echo -e " (sing-box分支) \033[33mPuerNya分支版本\033[0m" echo -e " 说明文档: \033[36;4mhttps://sing-box.sagernet.org\033[0m" echo echo -e "5 \033[32m自定义内核\033[0m: \033[33m仅限专业用户使用\033[0m" echo - echo "6 手动指定处理器架构" + echo "9 手动指定处理器架构" echo ----------------------------------------------- echo 0 返回上级菜单 read -p "请输入对应数字 > " num @@ -1867,7 +1867,7 @@ userguide(){ } #测试菜单 debug(){ - [ "$crashcore" = singbox ] && config_tmp=$TMPDIR/config.json || config_tmp=$TMPDIR/config.yaml + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && config_tmp=$TMPDIR/jsons || config_tmp=$TMPDIR/config.yaml echo ----------------------------------------------- echo -e "\033[36m注意:Debug运行均会停止原本的内核服务\033[0m" echo -e "后台运行日志地址:\033[32m$TMPDIR/debug.log\033[0m" @@ -1879,6 +1879,7 @@ debug(){ echo -e " 3 后台运行完整启动流程,并配置防火墙劫持,日志等级:\033[31merror\033[0m" echo -e " 4 后台运行完整启动流程,并配置防火墙劫持,日志等级:\033[32minfo\033[0m" echo -e " 5 后台运行完整启动流程,并配置防火墙劫持,日志等级:\033[33mdebug\033[0m" + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && echo -e " 6 将\033[32m$config_tmp\033[0m下json文件合并为$TMPDIR/debug.json" echo ----------------------------------------------- echo " 0 返回上级目录!" read -p "请输入对应数字 > " num @@ -1886,7 +1887,7 @@ debug(){ 0) ;; 1) $CRASHDIR/start.sh stop - if [ "$crashcore" = singbox ] ;then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ] ;then $TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons & { sleep 4 ; kill $! &>/dev/null & } wait @@ -1914,13 +1915,17 @@ debug(){ $CRASHDIR/start.sh debug debug main_menu ;; + 6) + $TMPDIR/CrashCore merge $TMPDIR/debug.json -C $TMPDIR/jsons && echo -e "\033[32m合并成功!\033[0m" + main_menu + ;; *) errornum ;; esac } testcommand(){ - [ "$crashcore" = singbox ] && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && config_path=${JSONSDIR}/config.json || config_path=${YAMLSDIR}/config.yaml echo ----------------------------------------------- echo -e "\033[30;47m这里是测试命令菜单\033[0m" echo -e "\033[33m如遇问题尽量运行相应命令后截图提交issue或TG讨论组\033[0m" @@ -1970,6 +1975,7 @@ testcommand(){ [ "$local_proxy" = "已开启" ] && [ "$local_type" = "iptables增强模式" ] && { echo ----------------OUTPUT------------------- iptables -t nat -L OUTPUT --line-numbers + iptables -t nat -L shellcrash_dns_out --line-numbers iptables -t nat -L shellcrash_out --line-numbers } [ "$ipv6_redir" = "已开启" ] && { diff --git a/scripts/init.sh b/scripts/init.sh index 1abf330..c648d4b 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -299,5 +299,6 @@ sed -i "s/clashcore/crashcore/g" $configpath sed -i "s/clash_v/core_v/g" $configpath sed -i "s/clash.meta/meta/g" $configpath sed -i "s/ShellClash/ShellCrash/g" $configpath +sed -i "s/cpucore=armv8/cpucore=arm64/g" $configpath echo -e "\033[32m脚本初始化完成,请输入\033[30;47m crash \033[0;33m命令开始使用!\033[0m" diff --git a/scripts/menu.sh b/scripts/menu.sh index 2c94c97..dbe9ce1 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -83,7 +83,7 @@ ckstatus(){ #检测系统端口占用 checkport fi - [ "$crashcore" = singbox ] && corename=Sing-Box || corename=Clash + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && corename=SingBox || corename=Clash [ -f ${TMPDIR}/debug.log -a -n "$PID" ] && auto="\033[33m并处于debug状态!\033[0m" #输出状态 echo ----------------------------------------------- @@ -158,9 +158,8 @@ errornum(){ echo -e "\033[31m请输入正确的字母或数字!\033[0m" } startover(){ - [ "$crashcore" = singbox ] && corename=Singbox || corename=Clash echo -e "\033[32m$corename服务已启动!\033[0m" - echo -e "请使用 \033[4;32mhttp://$host$hostdir\033[0m 管理内置规则" + echo -e "请使用 \033[4;36mhttp://$host$hostdir\033[0m 管理内置规则" if [ "$redir_mod" = "纯净模式" ];then echo ----------------------------------------------- echo -e "其他设备可以使用PAC配置连接:\033[4;32mhttp://$host:$db_port/ui/pac\033[0m" @@ -168,7 +167,7 @@ startover(){ fi } start_core(){ - if [ "$crashcore" = singbox ];then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then core_config=${CRASHDIR}/jsons/config.json else core_config=${CRASHDIR}/yamls/config.yaml @@ -1229,7 +1228,7 @@ normal_set(){ #基础设置 echo ----------------------------------------------- echo -e "\033[36m已设为 $dns_mod 模式!!\033[0m" elif [ "$num" = 3 ]; then - if [ "$crashcore" = singbox ];then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then dns_mod=mix setconfig dns_mod $dns_mod echo ----------------------------------------------- diff --git a/scripts/shellcrash.service b/scripts/shellcrash.service index b89885b..e2fadd6 100644 --- a/scripts/shellcrash.service +++ b/scripts/shellcrash.service @@ -5,6 +5,7 @@ After=network.target [Service] Type=simple User=shellcrash +ExecStartPre=/etc/ShellCrash/start.sh bfstart ExecStart=/etc/ShellCrash/CrashCore run -D /etc/ShellCrash -C /tmp/ShellCrash/jsons ExecStartPost=/etc/ShellCrash/start.sh afstart >/dev/null & ExecStopPost=/etc/ShellCrash/start.sh stop_firewall ; /etc/ShellCrash/start.sh unset_proxy diff --git a/scripts/start.sh b/scripts/start.sh index 5e8a9a2..b02c991 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -33,7 +33,7 @@ getconfig(){ #获取脚本配置 [ -z "$multiport" ] && multiport='22,53,80,123,143,194,443,465,587,853,993,995,5222,8080,8443' [ "$common_ports" = "已开启" ] && ports="-m multiport --dports $multiport" #内核配置文件 - if [ "$crashcore" = singbox ];then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then target=singbox format=json core_config=${CRASHDIR}/jsons/config.json @@ -231,11 +231,6 @@ check_singbox_config(){ #检查singbox配置文件 logger "获取到了配置文件【$core_config_new】,但似乎并不包含正确的节点信息!" 31 exit 1 fi - #检测SSR节点 - if [ -n "$(cat $core_config_new | grep -oE '"shadowsocksr"')" ];then - echo ----------------------------------------------- - logger "singbox主干已移除对SSR相关协议的支持,请使用clash系内核或者PuerNya分支!" 33 - fi #检测并去除无效策略组 [ -n "$url_type" ] && { #获得无效策略组名称 @@ -310,7 +305,7 @@ get_core_config(){ #下载内核配置文件 fi else Https="" - [ "$crashcore" = singbox ] && check_singbox_config || check_clash_config + [ "$crashcore" = singbox -o "$crashcore" = singboxp ] && check_singbox_config || check_clash_config #如果不同则备份并替换文件 if [ -s $core_config ];then compare $core_config_new $core_config @@ -536,9 +531,8 @@ modify_json(){ #修饰singbox配置文件 cat > ${TMPDIR}/jsons/log.json < ${TMPDIR}/jsons/dns.json < ${TMPDIR}/jsons/add_hosts.json < ${TMPDIR}/jsons/dns.json < ${TMPDIR}/jsons/add_route.json < ${TMPDIR}/jsons/ntp.json < ${TMPDIR}/jsons/add_route.json < ${TMPDIR}/jsons/cust_add_rules.json } - #提取配置文件以获得outbounds.json及route.json + #提取配置文件以获得outbounds.json,outbound_providers.json及route.json ${TMPDIR}/CrashCore format -c $core_config > ${TMPDIR}/format.json echo '{' > ${TMPDIR}/jsons/outbounds.json echo '{' > ${TMPDIR}/jsons/route.json - cat ${TMPDIR}/format.json | sed -n '/"outbounds":/,/"route":/{/"route":/d; p}' >> ${TMPDIR}/jsons/outbounds.json - cat ${TMPDIR}/format.json | sed -n '/"route":/,/"experimental":/{/"experimental":/d; p}' >> ${TMPDIR}/jsons/route.json + cat ${TMPDIR}/format.json | sed -n '/"outbounds":/,/^ "[a-z]/{/^ "\(route\|outbound_providers\)/d; p}' >> ${TMPDIR}/jsons/outbounds.json + [ "$crashcore" = "singboxp" ] && cat ${TMPDIR}/format.json | sed -n '/"outbound_providers":/,/^ "[a-z]/{/^ "route/d; p}' >> ${TMPDIR}/jsons/outbound_providers.json + cat ${TMPDIR}/format.json | sed -n '/"route":/,/^ "[a-z]/{/^ "experimental/d; p}' >> ${TMPDIR}/jsons/route.json #清理route.json中的process_name规则以及"auto_detect_interface" sed -i '/"process_name": \[/,/],$/d' ${TMPDIR}/jsons/route.json sed -i '/"process_name": "[^"]*",/d' ${TMPDIR}/jsons/route.json @@ -731,9 +740,10 @@ EOF else sed -i 's/"insecure": true/"insecure": false/' ${TMPDIR}/jsons/outbounds.json fi - #修饰outbounds&route.json结尾 + #修饰outbounds&outbound_providers&route.json结尾 sed -i 's/^ ],$/ ] }/' ${TMPDIR}/jsons/outbounds.json sed -i 's/^ },$/ } }/' ${TMPDIR}/jsons/route.json + [ -s ${TMPDIR}/jsons/outbound_providers.json ] && sed -i 's/^ },$/ } }/' ${TMPDIR}/jsons/outbound_providers.json || rm -rf ${TMPDIR}/jsons/outbound_providers.json #加载自定义配置文件 mkdir -p ${TMPDIR}/jsons_base for char in log dns ntp experimental;do @@ -762,6 +772,7 @@ EOF #清理缓存 rm -rf ${TMPDIR}/*.json rm -rf ${TMPDIR}/jsons_base + return 0 } #设置路由规则 @@ -833,7 +844,7 @@ start_redir(){ #iptables-redir iptables -t nat -A PREROUTING -p tcp $ports -j shellcrash [ "$dns_mod" != "redir_host" -a "$common_ports" = "已开启" ] && iptables -t nat -A PREROUTING -p tcp -d 198.18.0.0/16 -j shellcrash #设置ipv6转发 - if [ "$ipv6_redir" = "已开启" -a -n "$(lsmod | grep 'ip6table_nat')" ];then + if [ "$ipv6_redir" = "已开启" ] && ip6tables -t nat -L &>/dev/null;then ip6tables -t nat -N shellcrashv6 for ip in $reserve_ipv6 $host_ipv6;do #跳过目标保留地址及目标本机网段 ip6tables -t nat -A shellcrashv6 -d $ip -j RETURN @@ -943,7 +954,7 @@ start_tproxy(){ #iptables-tproxy iptables -I INPUT -p udp --dport 443 -m comment --comment "ShellCrash-QUIC-REJECT" $set_cn_ip -j REJECT >/dev/null 2>&1 } #设置ipv6转发 - [ "$ipv6_redir" = "已开启" ] && { + [ "$ipv6_redir" = "已开启" ] && ip6tables -t nat -L &>/dev/null && { ip -6 rule add fwmark $fwmark table 101 ip -6 route add local ::/0 dev lo table 101 ip6tables -t mangle -N shellcrashv6 @@ -1072,7 +1083,7 @@ start_tun(){ #iptables-tun [ "$1" = "all" ] && iptables -t mangle -A PREROUTING -p tcp $ports -j shellcrash #设置ipv6转发 - [ "$ipv6_redir" = "已开启" ] && [ "$crashcore" = "singbox" -o "$crashcore" = "meta" ] && { + [ "$ipv6_redir" = "已开启" ] && ip6tables -t nat -L &>/dev/null && [ "$crashcore" != clash ] && { ip -6 route add default dev utun table 101 ip -6 rule add fwmark $fwmark table 101 ip6tables -t mangle -N shellcrashv6 @@ -1459,7 +1470,7 @@ core_check(){ mv -f ${TMPDIR}/core_new/$file ${TMPDIR}/CrashCore done rm -rf ${TMPDIR}/core_new - if [ "$crashcore" = singbox ];then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then core_v=$(${TMPDIR}/CrashCore version 2>/dev/null | grep version | awk '{print $3}') COMMAND='"$TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons"' else @@ -1479,8 +1490,8 @@ core_check(){ fi fi fi - [ ! -x ${TMPDIR}/CrashCore ] && chmod +x ${TMPDIR}/CrashCore 2>/dev/null #自动授权 + return 0 } clash_check(){ #clash启动前检查 #检测vless/hysteria协议 @@ -1511,7 +1522,7 @@ clash_check(){ #clash启动前检查 #预下载GeoIP数据库 if [ ! -f ${BINDIR}/Country.mmdb ];then if [ -f ${CRASHDIR}/Country.mmdb ];then - mv ${CRASHDIR}/Country.mmdb ${BINDIR}/Country.mmdb + ln -sf ${CRASHDIR}/Country.mmdb ${BINDIR}/Country.mmdb else logger "未找到GeoIP数据库,正在下载!" 33 get_bin ${BINDIR}/Country.mmdb bin/geodata/cn_mini.mmdb @@ -1523,7 +1534,7 @@ clash_check(){ #clash启动前检查 #预下载GeoSite数据库 if [ -n "$(cat $core_config|grep -Ei 'geosite')" ] && [ ! -f ${BINDIR}/GeoSite.dat ];then if [ -f ${CRASHDIR}/GeoSite.dat ];then - mv -f ${CRASHDIR}/GeoSite.dat ${BINDIR}/GeoSite.dat + ln -sf ${CRASHDIR}/GeoSite.dat ${BINDIR}/GeoSite.dat else logger "未找到GeoSite数据库,正在下载!" 33 get_bin ${BINDIR}/GeoSite.dat bin/geodata/geosite.dat @@ -1533,11 +1544,20 @@ clash_check(){ #clash启动前检查 return 0 } singbox_check(){ #singbox启动前检查 + #检测PuerNya专属功能 + if [ -n "$(cat ${CRASHDIR}/jsons/*.json | grep -oE 'shadowsocksr|providers')" ];then + echo ----------------------------------------------- + logger "检测到PuerNya内核专属功能,改为使用singboxp内核启动!" 33 + rm -rf ${TMPDIR}/CrashCore + rm -rf ${CRASHDIR}/CrashCore + rm -rf ${CRASHDIR}/core.tar.gz + crashcore=singboxp + fi core_check #预下载GeoIP数据库 if [ ! -f ${BINDIR}/geoip.db ];then if [ -f ${CRASHDIR}/geoip.db ];then - mv ${CRASHDIR}/geoip.db ${BINDIR}/geoip.db + ln -sf ${CRASHDIR}/geoip.db ${BINDIR}/geoip.db else logger "未找到GeoIP数据库,正在下载!" 33 get_bin ${BINDIR}/geoip.db bin/geodata/geoip_cn.db @@ -1547,9 +1567,9 @@ singbox_check(){ #singbox启动前检查 fi fi #预下载GeoSite数据库 - if [ -n "$(cat $core_config|grep -Ei '"geosite":')" ] && [ ! -f ${BINDIR}/geosite.db ];then + if [ -n "cat ${CRASHDIR}/jsons/*.json | grep -Ei 'geosite')" -o "$dns_mod" = "mix" ] && [ ! -f ${BINDIR}/geosite.db ];then if [ -f ${CRASHDIR}/geosite.db ];then - mv -f ${CRASHDIR}/geosite.db ${BINDIR}/geosite.db + ln -sf ${CRASHDIR}/geosite.db ${BINDIR}/geosite.db else logger "未找到GeoSite数据库,正在下载!" 33 get_bin ${BINDIR}/geosite.db bin/geodata/geosite_cn.db @@ -1587,7 +1607,7 @@ bfstart(){ #启动前 catpac #生成pac文件 #内核及内核配置文件检查 [ ! -x ${TMPDIR}/CrashCore ] && chmod +x ${TMPDIR}/CrashCore 2>/dev/null #检测可执行权限 - if [ "$crashcore" = singbox ];then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then singbox_check [ -d ${TMPDIR}/jsons ] && rm -rf ${TMPDIR}/jsons/* || mkdir -p ${TMPDIR}/jsons #准备目录 [ "$disoverride" != "1" ] && modify_json || ln -sf $core_config ${TMPDIR}/jsons/config.json @@ -1743,7 +1763,6 @@ start) elif [ -f /etc/rc.common -a "$(cat /proc/1/comm)" = "procd" ];then /etc/init.d/shellcrash start elif [ "$USER" = "root" -a "$(cat /proc/1/comm)" = "systemd" ];then - bfstart FragmentPath=$(systemctl show -p FragmentPath shellcrash | sed 's/FragmentPath=//') setconfig ExecStart "$COMMAND >/dev/null" "$FragmentPath" systemctl daemon-reload @@ -1786,7 +1805,7 @@ debug) stop_firewall >/dev/null #清理路由策略 bfstart [ -n "$2" ] && { - if [ "$crashcore" = singbox ];then + if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then sed -i "s/\"level\": \"info\"/\"level\": \"$2\"/" ${TMPDIR}/config.json else sed -i "s/log-level: info/log-level: $2/" ${TMPDIR}/config.yaml