mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 11:42:18 +08:00
修改内核压缩方式
This commit is contained in:
parent
69217f7ba6
commit
c988b0a5f2
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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内核!"
|
||||
|
|
|
@ -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 -----------------------------------------------
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user