From c988b0a5f2e8d28bba3589de765168af0bd57903 Mon Sep 17 00:00:00 2001 From: juewuy Date: Mon, 29 Jan 2024 16:18:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=85=E6=A0=B8=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/getdate.sh | 9 ++++----- scripts/init.sh | 2 ++ scripts/menu.sh | 6 ++++-- scripts/start.sh | 16 ++++++++++------ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/scripts/getdate.sh b/scripts/getdate.sh index 287055e..27ebb61 100644 --- a/scripts/getdate.sh +++ b/scripts/getdate.sh @@ -800,7 +800,7 @@ getsh(){ getcpucore(){ cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]') [ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="armv5" - [ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs/CrashCore ] && cpucore="armv7" + [ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs ] && cpucore="armv7" [ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="arm64" [ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="386" [ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="amd64" @@ -891,7 +891,6 @@ getcore(){ else [ -n "$(pidof CrashCore)" ] && ${CRASHDIR}/start.sh stop #停止内核服务防止内存不足 [ -f ${TMPDIR}/core.tar.gz ] && { - echo -e "\033[31m正在解压……\033[0m" mkdir -p ${TMPDIR}/core_new tar -zxvf "${TMPDIR}/core.tar.gz" -C ${TMPDIR}/core_new/ &>/dev/null || tar -zxvf "${TMPDIR}/core.tar.gz" --no-same-owner -C ${TMPDIR}/core_new/ for file in "$(ls -1 ${TMPDIR}/core_new | grep -iE 'CrashCore|sing-box|clash|mihomo|meta')" ;do @@ -964,7 +963,7 @@ setcustcore(){ setcore(){ #获取核心及版本信息 [ -z "$crashcore" ] && crashcore="unknow" - [ ! -f ${CRASHDIR}/CrashCore ] && crashcore="未安装核心" + [ ! -f ${CRASHDIR}/core.tar.gz ] && crashcore="未安装核心" [ "$crashcore" = singbox ] && core_old=singbox || core_old=clash ### echo ----------------------------------------------- @@ -1888,11 +1887,11 @@ debug(){ 1) $CRASHDIR/start.sh stop if [ "$crashcore" = singbox ] ;then - $BINDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons & + $TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons & { sleep 4 ; kill $! &>/dev/null & } wait else - $BINDIR/CrashCore -t -d $BINDIR -f $TMPDIR/config.yaml + $TMPDIR/CrashCore -t -d $BINDIR -f $TMPDIR/config.yaml fi echo ----------------------------------------------- exit diff --git a/scripts/init.sh b/scripts/init.sh index d03e4c2..07ae25e 100644 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -270,6 +270,8 @@ done mv -f ${CRASHDIR}/configs/ShellClash.cfg ${CRASHDIR}/configs/ShellCrash.cfg 2>/dev/null #内核改名 mv -f ${CRASHDIR}/clash ${CRASHDIR}/CrashCore 2>/dev/null + #内核压缩 + [ -f ${CRASHDIR}/CrashCore ] && tar -zcvf ${CRASHDIR}/core.tar.gz -C ${CRASHDIR} CrashCore for file in dropbear_rsa_host_key authorized_keys tun.ko ShellDDNS.sh;do mv -f ${CRASHDIR}/$file ${CRASHDIR}/tools/$file 2>/dev/null done diff --git a/scripts/menu.sh b/scripts/menu.sh index fe53ad9..c73426c 100644 --- a/scripts/menu.sh +++ b/scripts/menu.sh @@ -114,7 +114,7 @@ ckstatus(){ if [ -n "$core_v" ];then source ${CRASHDIR}/getdate.sh && setcoretype && \ mv -f $file ${TMPDIR}/CrashCore && \ - tar --no-same-owner -zcvf ${BINDIR}/core.tar.gz ${TMPDIR}/CrashCore && \ + tar -zcvf ${BINDIR}/core.tar.gz -C ${TMPDIR} CrashCore && \ echo -e "\033[32m内核加载完成!\033[0m " && \ setconfig crashcore $crashcore && \ setconfig core_v $core_v && \ @@ -1466,7 +1466,9 @@ advanced_set(){ #进阶设置 echo ----------------------------------------------- if [ "$sniffer" = "未启用" ];then if [ "$crashcore" = "clash" ];then - rm -rf ${BINDIR}/CrashCore + rm -rf ${TMPDIR}/CrashCore + rm -rf ${CRASHDIR}/CrashCore + rm -rf ${CRASHDIR}/core.tar.gz crashcore=meta setconfig crashcore $crashcore echo "已将ShellCrash内核切换为Meta内核!域名嗅探依赖Meta或者高版本clashpre内核!" diff --git a/scripts/start.sh b/scripts/start.sh index c5e0edf..35a9afe 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -509,9 +509,9 @@ EOF #合并完整配置文件 cut -c 1- ${TMPDIR}/set.yaml $yaml_dns $yaml_hosts $yaml_user $yaml_others $yaml_add > ${TMPDIR}/config.yaml #测试自定义配置文件 - ${BINDIR}/CrashCore -t -d ${BINDIR} -f ${TMPDIR}/config.yaml >/dev/null + ${TMPDIR}/CrashCore -t -d ${BINDIR} -f ${TMPDIR}/config.yaml >/dev/null if [ "$?" != 0 ];then - logger "$(${BINDIR}/CrashCore -t -d ${BINDIR} -f ${TMPDIR}/config.yaml | grep -Eo 'error.*=.*')" 31 + logger "$(${TMPDIR}/CrashCore -t -d ${BINDIR} -f ${TMPDIR}/config.yaml | grep -Eo 'error.*=.*')" 31 logger "自定义配置文件校验失败!将使用基础配置文件启动!" 33 logger "错误详情请参考 ${TMPDIR}/error.yaml 文件!" 33 mv -f ${TMPDIR}/config.yaml ${TMPDIR}/error.yaml &>/dev/null @@ -715,7 +715,7 @@ EOF | sed '$s/,$/ ] } }/' > ${TMPDIR}/jsons/cust_add_rules.json } #提取配置文件以获得outbounds.json及route.json - ${BINDIR}/CrashCore format -c $core_config > ${TMPDIR}/format.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 @@ -747,7 +747,7 @@ EOF } done #测试自定义配置文件 - error=$(${BINDIR}/CrashCore check -D ${BINDIR} -C ${TMPDIR}/jsons 2>&1 | grep -Eo 'cust.*\.json' | sed 's/cust_//g' ) + error=$(${TMPDIR}/CrashCore check -D ${BINDIR} -C ${TMPDIR}/jsons 2>&1 | grep -Eo 'cust.*\.json' | sed 's/cust_//g' ) if [ -n "$error" ];then [ "$error" = 'add_rules.json' ] && error_file=${CRASHDIR}/yamls/rules.yaml自定义规则 || error_file=${CRASHDIR}/jsons/$error logger "自定义配置文件校验失败,请检查 ${error_file}文件!" 31 @@ -1480,7 +1480,9 @@ clash_check(){ #clash启动前检查 if [ "$crashcore" != "meta" ] && [ -n "$(cat $core_config | grep -oE 'type: vless|type: hysteria')" ];then echo ----------------------------------------------- logger "检测到vless/hysteria协议!将改为使用meta核心启动!" 33 - rm -rf ${BINDIR}/CrashCore + rm -rf ${TMPDIR}/CrashCore + rm -rf ${CRASHDIR}/CrashCore + rm -rf ${CRASHDIR}/core.tar.gz crashcore=meta echo ----------------------------------------------- fi @@ -1491,7 +1493,9 @@ clash_check(){ #clash启动前检查 [ "$redir_mod" = "Tun模式" ] && { echo ----------------------------------------------- logger "检测到高级功能!将改为使用meta核心启动!" 33 - rm -rf ${BINDIR}/CrashCore + rm -rf ${TMPDIR}/CrashCore + rm -rf ${CRASHDIR}/CrashCore + rm -rf ${CRASHDIR}/core.tar.gz crashcore=meta echo ----------------------------------------------- }