~增加crash -d命令,可以更简洁的debug执行时的错误信息

~为padavan设备增加了启动服务后自动保存mtd的功能
~优化singbox配置文件覆写,增强对各种第三方配置文件的普适性
~当自动任务启用同步ntp服务时,不再启动singbox内置的ntp模块
~singbox内置ntp模块移除了指定出口以增强普适性,但效果有待观察
~适配singbox1.7.8版本的mix模式
~修复各种类型的找不到内核或者内核下载失败问题
~修复使用默认dns时singbox内核提示dns出错的bug
~修复sed -e报错
This commit is contained in:
juewuy
2024-02-03 22:19:04 +08:00
parent 5ec99ebcff
commit 318cca0716
8 changed files with 120 additions and 88 deletions

View File

@@ -903,7 +903,7 @@ getcore(){ #下载内核文件
mkdir -p ${TMPDIR}/core_tmp mkdir -p ${TMPDIR}/core_tmp
tar -zxf "${TMPDIR}/core_new.tar.gz" -C ${TMPDIR}/core_tmp/ &>/dev/null || tar -zxf "${TMPDIR}/core_new.tar.gz" --no-same-owner -C ${TMPDIR}/core_tmp/ tar -zxf "${TMPDIR}/core_new.tar.gz" -C ${TMPDIR}/core_tmp/ &>/dev/null || tar -zxf "${TMPDIR}/core_new.tar.gz" --no-same-owner -C ${TMPDIR}/core_tmp/
for file in $(find ${TMPDIR}/core_tmp 2>/dev/null);do for file in $(find ${TMPDIR}/core_tmp 2>/dev/null);do
[ -s $file ] && [ -n "$(echo $file | sed 's#.*/##' | grep -iE '(CrashCore|sing|meta|mihomo|clash|premium)')" ] && mv -f $file ${TMPDIR}/core_new [ -f $file ] && [ -n "$(echo $file | sed 's#.*/##' | grep -iE '(CrashCore|sing|meta|mihomo|clash|premium)')" ] && mv -f $file ${TMPDIR}/core_new
done done
rm -rf ${TMPDIR}/core_tmp rm -rf ${TMPDIR}/core_tmp
} }
@@ -942,38 +942,43 @@ setcustcore(){ #自定义内核
#通过githubapi获取内核信息 #通过githubapi获取内核信息
echo -e "\033[32m正在获取内核文件链接\033[0m" echo -e "\033[32m正在获取内核文件链接\033[0m"
${CRASHDIR}/start.sh webget ${TMPDIR}/github_api https://api.github.com/repos/${project}/releases/${api_url} ${CRASHDIR}/start.sh webget ${TMPDIR}/github_api https://api.github.com/repos/${project}/releases/${api_url}
release_tag=$(cat ${TMPDIR}/github_api | grep '"tag_name":' | awk -F '"' '{print $4}') if [ "$?" = 0 ];then
release_date=$(cat ${TMPDIR}/github_api | grep '"published_at":' | awk -F '"' '{print $4}') release_tag=$(cat ${TMPDIR}/github_api | grep '"tag_name":' | awk -F '"' '{print $4}')
[ -n "$(echo $cpucore | grep mips)" ] && cpu_type=mips || cpu_type=$cpucore release_date=$(cat ${TMPDIR}/github_api | grep '"published_at":' | awk -F '"' '{print $4}')
cat ${TMPDIR}/github_api | grep "browser_download_url" | grep -oE "https://github.com/${project}/releases/download.*linux.*${cpu_type}.*\.gz\"$" | sed 's/"//' > ${TMPDIR}/core.list [ -n "$(echo $cpucore | grep mips)" ] && cpu_type=mips || cpu_type=$cpucore
rm -rf ${TMPDIR}/github_api cat ${TMPDIR}/github_api | grep "browser_download_url" | grep -oE "https://github.com/${project}/releases/download.*linux.*${cpu_type}.*\.gz\"$" | sed 's/"//' > ${TMPDIR}/core.list
# rm -rf ${TMPDIR}/github_api
if [ -f ${TMPDIR}/core.list ];then #
echo ----------------------------------------------- if [ -s ${TMPDIR}/core.list ];then
echo -e "内核版本:\033[36m$release_tag\033[0m" echo -----------------------------------------------
echo -e "发布时间\033[32m$release_date\033[0m" echo -e "内核版本\033[36m$release_tag\033[0m"
echo ----------------------------------------------- echo -e "发布时间:\033[32m$release_date\033[0m"
echo -e "\033[33m请确认内核信息并选择\033[0m" echo -----------------------------------------------
cat ${TMPDIR}/core.list | grep -oE "$release_tag.*" | sed 's|.*/||' | awk '{print " "NR" "$1}' echo -e "\033[33m请确认内核信息并选择\033[0m"
echo -e " 0 返回上级菜单" cat ${TMPDIR}/core.list | grep -oE "$release_tag.*" | sed 's|.*/||' | awk '{print " "NR" "$1}'
echo ----------------------------------------------- echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num echo -----------------------------------------------
case "$num" in read -p "请输入对应数字 > " num
0) case "$num" in
setcustcore 0)
;; setcustcore
[1-99]) ;;
if [ "$num" -le "$(wc -l < ${TMPDIR}/core.list)" ];then [1-99])
custcorelink=$(sed -n "$num"p ${TMPDIR}/core.list) if [ "$num" -le "$(wc -l < ${TMPDIR}/core.list)" ];then
getcore custcorelink=$(sed -n "$num"p ${TMPDIR}/core.list)
else getcore
else
errornum
fi
;;
*)
errornum errornum
fi ;;
;; esac
*) else
errornum echo -e "\033[31m找不到可用内核可能是作者没有编译相关CPU架构版本的内核文件\033[0m"
;; sleep 1
esac fi
else else
echo -e "\033[31m查找失败请尽量在服务启动后再使用本功能\033[0m" echo -e "\033[31m查找失败请尽量在服务启动后再使用本功能\033[0m"
sleep 1 sleep 1
@@ -1960,7 +1965,9 @@ debug(){
echo -e " 3 后台运行完整启动流程,并配置防火墙劫持,日志等级:\033[31merror\033[0m" echo -e " 3 后台运行完整启动流程,并配置防火墙劫持,日志等级:\033[31merror\033[0m"
echo -e " 4 后台运行完整启动流程,并配置防火墙劫持,日志等级:\033[32minfo\033[0m" echo -e " 4 后台运行完整启动流程,并配置防火墙劫持,日志等级:\033[32minfo\033[0m"
echo -e " 5 后台运行完整启动流程,并配置防火墙劫持,日志等级:\033[33mdebug\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 -e " 8 后台运行完整启动流程,输出执行错误并查找上下文,之后关闭进程"
[ -s $TMPDIR/jsons/inbounds.json ] && echo -e " 9 将\033[32m$config_tmp\033[0m下json文件合并为$TMPDIR/debug.json"
echo ----------------------------------------------- echo -----------------------------------------------
echo " 0 返回上级目录!" echo " 0 返回上级目录!"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
@@ -1968,6 +1975,7 @@ debug(){
0) ;; 0) ;;
1) 1)
$CRASHDIR/start.sh stop $CRASHDIR/start.sh stop
$CRASHDIR/start.sh bfstart
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ] ;then if [ "$crashcore" = singbox -o "$crashcore" = singboxp ] ;then
$TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons & $TMPDIR/CrashCore run -D $BINDIR -C $TMPDIR/jsons &
{ sleep 4 ; kill $! &>/dev/null & } { sleep 4 ; kill $! &>/dev/null & }
@@ -1980,6 +1988,7 @@ debug(){
;; ;;
2) 2)
$CRASHDIR/start.sh stop $CRASHDIR/start.sh stop
$CRASHDIR/start.sh bfstart
$COMMAND $COMMAND
echo ----------------------------------------------- echo -----------------------------------------------
exit exit
@@ -1996,7 +2005,11 @@ debug(){
$CRASHDIR/start.sh debug debug $CRASHDIR/start.sh debug debug
main_menu main_menu
;; ;;
6) 8)
$0 -d
main_menu
;;
9)
$TMPDIR/CrashCore merge $TMPDIR/debug.json -C $TMPDIR/jsons && echo -e "\033[32m合并成功\033[0m" $TMPDIR/CrashCore merge $TMPDIR/debug.json -C $TMPDIR/jsons && echo -e "\033[32m合并成功\033[0m"
main_menu main_menu
;; ;;

View File

@@ -1897,6 +1897,7 @@ case "$1" in
echo " -h 帮助列表" echo " -h 帮助列表"
echo " -u 卸载脚本" echo " -u 卸载脚本"
echo " -i 初始化脚本" echo " -i 初始化脚本"
echo " -d 测试运行"
echo ----------------------------------------- echo -----------------------------------------
echo " crash -s start 启动服务" echo " crash -s start 启动服务"
echo " crash -s stop 停止服务" echo " crash -s stop 停止服务"
@@ -1921,6 +1922,26 @@ case "$1" in
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
$shtype -x ${CRASHDIR}/start.sh $2 $3 $4 $5 $6 $shtype -x ${CRASHDIR}/start.sh $2 $3 $4 $5 $6
;; ;;
-d)
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
echo -e "正在测试运行!如发现错误请截图后前往\033[32;4mt.me/ShellClash\033[0m咨询"
$shtype ${CRASHDIR}/start.sh debug >/dev/null 2>${TMPDIR}/sh_bug
$shtype -x ${CRASHDIR}/start.sh debug >/dev/null 2>${TMPDIR}/debug_sh.log
echo -----------------------------------------
if [ -s ${TMPDIR}/sh_bug ];then
while read line ;do
echo -e "发现错误:\033[33;4m$line\033[0m"
grep -A 1 -B 3 "$line" ${TMPDIR}/debug_sh.log
echo -----------------------------------------
done < ${TMPDIR}/sh_bug
rm -rf ${TMPDIR}/sh_bug
echo -e "\033[32m测试完成\033[0m完整执行记录请查看\033[36m${TMPDIR}/debug_sh.log\033[0m"
else
echo -e "\033[32m测试完成没有发现问题~\033[0m"
rm -rf ${TMPDIR}/debug_sh.log
fi
${CRASHDIR}/start.sh stop
;;
-u) -u)
uninstall uninstall
;; ;;

View File

@@ -52,7 +52,7 @@ ckcmd(){ #检查命令是否存在
command -v sh &>/dev/null && command -v $1 &>/dev/null || type $1 &>/dev/null command -v sh &>/dev/null && command -v $1 &>/dev/null || type $1 &>/dev/null
} }
ckgeo(){ #查找及下载Geo数据文件 ckgeo(){ #查找及下载Geo数据文件
[ -n "$(find --help 2>&1|grep size)" ] && find_para=' -size +20' #find命令兼容 [ -n "$(find --help 2>&1|grep -o size)" ] && find_para=' -size +20' #find命令兼容
[ -z "$(find ${BINDIR}/${1} $find_para 2>/dev/null)" ] && { [ -z "$(find ${BINDIR}/${1} $find_para 2>/dev/null)" ] && {
if [ -n "$(find ${CRASHDIR}/${1} $find_para 2>/dev/null)" ];then if [ -n "$(find ${CRASHDIR}/${1} $find_para 2>/dev/null)" ];then
mv ${CRASHDIR}/${1} ${BINDIR}/${1} #小闪存模式移动文件 mv ${CRASHDIR}/${1} ${BINDIR}/${1} #小闪存模式移动文件
@@ -351,7 +351,6 @@ modify_yaml(){ #修饰clash配置文件
} }
#dns配置 #dns配置
[ -z "$(cat ${CRASHDIR}/yamls/user.yaml 2>/dev/null | grep '^dns:')" ] && { [ -z "$(cat ${CRASHDIR}/yamls/user.yaml 2>/dev/null | grep '^dns:')" ] && {
[ "$crashcore" = 'meta' ] && dns_default_meta='- https://223.5.5.5/dns-query'
cat > ${TMPDIR}/dns.yaml <<EOF cat > ${TMPDIR}/dns.yaml <<EOF
dns: dns:
enable: true enable: true
@@ -361,7 +360,6 @@ dns:
default-nameserver: default-nameserver:
- 114.114.114.114 - 114.114.114.114
- 223.5.5.5 - 223.5.5.5
$dns_default_meta
enhanced-mode: fake-ip enhanced-mode: fake-ip
fake-ip-range: 198.18.0.1/16 fake-ip-range: 198.18.0.1/16
fake-ip-filter: fake-ip-filter:
@@ -560,22 +558,23 @@ EOF
cat > ${TMPDIR}/jsons/add_hosts.json <<EOF cat > ${TMPDIR}/jsons/add_hosts.json <<EOF
{ {
"dns": { "dns": {
"servers": [{ "servers": [
"tag": "hosts_local", { "tag": "hosts_local", "address": "local", "detour": "direct" }
"address": "local" ],
}], "rules": [
"rules": [{ {
"domain": [$hosts_domain], "domain": [$hosts_domain],
"server": "hosts_local" "server": "hosts_local"
}] }
]
} }
} }
EOF EOF
} }
fi fi
#生成dns.json #生成dns.json
dns_direct=\"$(echo $dns_nameserver | awk -F ',' '{print $1}')\" dns_direct=$(echo $dns_nameserver | awk -F ',' '{print $1}')
dns_proxy=\"$(echo $dns_fallback | awk -F ',' '{print $1}')\" dns_proxy=$(echo $dns_fallback | awk -F ',' '{print $1}')
[ -z "$dns_direct" ] && dns_direct='223.5.5.5' [ -z "$dns_direct" ] && dns_direct='223.5.5.5'
[ -z "$dns_proxy" ] && dns_proxy='1.0.0.1' [ -z "$dns_proxy" ] && dns_proxy='1.0.0.1'
[ "$ipv6_dns" = "已开启" ] && strategy='prefer_ipv4' || strategy='ipv4_only' [ "$ipv6_dns" = "已开启" ] && strategy='prefer_ipv4' || strategy='ipv4_only'
@@ -583,9 +582,10 @@ EOF
[ "$dns_mod" = "fake-ip" ] && final_dns=dns_fakeip && global_dns=dns_fakeip [ "$dns_mod" = "fake-ip" ] && final_dns=dns_fakeip && global_dns=dns_fakeip
[ "$dns_mod" = "mix" ] && { [ "$dns_mod" = "mix" ] && {
final_dns=dns_direct && global_dns=dns_fakeip final_dns=dns_direct && global_dns=dns_fakeip
mix_dns="{ \"rule_set\": [\"geosite-cn\"], \"invert\": true, \"server\": \"dns_fakeip\" }," if [ -z "$(echo "$core_v" | grep -E '^1\.7.*')" ];then
#生成add_rule_set.json mix_dns="{ \"rule_set\": [\"geosite-cn\"], \"invert\": true, \"server\": \"dns_fakeip\" },"
[ -z "$(cat ${CRASHDIR}/jsons/*.json | grep -Ei '\"tag\": \"geosite-cn\"')" ] && cat > ${TMPDIR}/jsons/add_rule_set.json <<EOF #生成add_rule_set.json
[ -z "$(cat ${CRASHDIR}/jsons/*.json | grep -Ei '\"tag\": \"geosite-cn\"')" ] && cat > ${TMPDIR}/jsons/add_rule_set.json <<EOF
{ {
"route": { "route": {
"rule_set": [ "rule_set": [
@@ -599,6 +599,9 @@ EOF
} }
} }
EOF EOF
else
mix_dns="{ \"geosite\": [\"cn\"], \"invert\": true, \"server\": \"dns_fakeip\" },"
fi
} }
cat > ${TMPDIR}/jsons/dns.json <<EOF cat > ${TMPDIR}/jsons/dns.json <<EOF
{ {
@@ -606,26 +609,20 @@ EOF
"servers": [ "servers": [
{ {
"tag": "dns_proxy", "tag": "dns_proxy",
"address": $dns_proxy, "address": "$dns_proxy",
"strategy": "$strategy", "strategy": "$strategy",
"address_resolver": "dns_resolver" "address_resolver": "dns_resolver"
}, { }, {
"tag": "dns_direct", "tag": "dns_direct",
"address": $dns_direct, "address": "$dns_direct",
"strategy": "$strategy", "strategy": "$strategy",
"address_resolver": "dns_resolver", "address_resolver": "dns_resolver",
"detour": "DIRECT" "detour": "direct"
}, { },
"tag": "dns_fakeip", { "tag": "dns_fakeip", "address": "fakeip" },
"address": "fakeip" { "tag": "dns_resolver", "address": "223.5.5.5", "detour": "direct" },
}, { { "tag": "block", "address": "rcode://success" },
"tag": "dns_resolver", { "tag": "local", "address": "local", "detour": "direct" }
"address": "223.5.5.5",
"detour": "DIRECT"
}, {
"tag": "block",
"address": "rcode://success"
}
], ],
"rules": [ "rules": [
{ "outbound": ["any"], "server": "dns_resolver" }, { "outbound": ["any"], "server": "dns_resolver" },
@@ -652,14 +649,13 @@ EOF
} }
EOF EOF
#生成ntp.json #生成ntp.json
cat > ${TMPDIR}/jsons/ntp.json <<EOF [ -z "$(grep '自动同步ntp时间' $CRASHDIR/task/afstart )" ] && cat > ${TMPDIR}/jsons/ntp.json <<EOF
{ {
"ntp": { "ntp": {
"enabled": true, "enabled": true,
"server": "203.107.6.88", "server": "203.107.6.88",
"server_port": 123, "server_port": 123,
"interval": "30m0s", "interval": "30m0s"
"detour": "DIRECT"
} }
} }
EOF EOF
@@ -761,9 +757,9 @@ EOF
cat ${TMPDIR}/format.json | sed -n '/"outbounds":/,/^ "[a-z]/p' | sed '$d' >> ${TMPDIR}/jsons/outbounds.json cat ${TMPDIR}/format.json | sed -n '/"outbounds":/,/^ "[a-z]/p' | sed '$d' >> ${TMPDIR}/jsons/outbounds.json
[ "$crashcore" = "singboxp" ] && { [ "$crashcore" = "singboxp" ] && {
echo '{' > ${TMPDIR}/jsons/outbound_providers.json echo '{' > ${TMPDIR}/jsons/outbound_providers.json
cat ${TMPDIR}/format.json | sed -n '/"outbound_providers":/,/^ "[a-z]/p}' | sed '$d' >> ${TMPDIR}/jsons/outbound_providers.json cat ${TMPDIR}/format.json | sed -n '/"outbound_providers":/,/^ "[a-z]/p' | sed '$d' >> ${TMPDIR}/jsons/outbound_providers.json
} }
cat ${TMPDIR}/format.json | sed -n '/"route":/,/^\( "[a-z]\|}\)/p}' | sed '$d' >> ${TMPDIR}/jsons/route.json cat ${TMPDIR}/format.json | sed -n '/"route":/,/^\( "[a-z]\|}\)/p' | sed '$d' >> ${TMPDIR}/jsons/route.json
#清理route.json中的process_name规则以及"auto_detect_interface" #清理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
sed -i '/"process_name": "[^"]*",/d' ${TMPDIR}/jsons/route.json sed -i '/"process_name": "[^"]*",/d' ${TMPDIR}/jsons/route.json
@@ -822,7 +818,7 @@ cn_ip_route(){ #CN-IP绕过
echo "create cn_ip hash:net family inet hashsize 10240 maxelem 10240" > ${TMPDIR}/cn_$USER.ipset echo "create cn_ip hash:net family inet hashsize 10240 maxelem 10240" > ${TMPDIR}/cn_$USER.ipset
awk '!/^$/&&!/^#/{printf("add cn_ip %s'" "'\n",$0)}' ${BINDIR}/cn_ip.txt >> ${TMPDIR}/cn_$USER.ipset awk '!/^$/&&!/^#/{printf("add cn_ip %s'" "'\n",$0)}' ${BINDIR}/cn_ip.txt >> ${TMPDIR}/cn_$USER.ipset
ipset -! flush cn_ip 2>/dev/null ipset -! flush cn_ip 2>/dev/null
ipset -! restore < ${TMPDIR}/cn_$USER.ipset ipset -! restore < ${TMPDIR}/cn_$USER.ipset 2>/dev/null
rm -rf cn_$USER.ipset rm -rf cn_$USER.ipset
} }
} }
@@ -834,7 +830,7 @@ cn_ipv6_route(){ #CN-IPV6绕过
echo "create cn_ip6 hash:net family inet6 hashsize 4096 maxelem 4096" > ${TMPDIR}/cn6_$USER.ipset echo "create cn_ip6 hash:net family inet6 hashsize 4096 maxelem 4096" > ${TMPDIR}/cn6_$USER.ipset
awk '!/^$/&&!/^#/{printf("add cn_ip6 %s'" "'\n",$0)}' ${BINDIR}/cn_ipv6.txt >> ${TMPDIR}/cn6_$USER.ipset awk '!/^$/&&!/^#/{printf("add cn_ip6 %s'" "'\n",$0)}' ${BINDIR}/cn_ipv6.txt >> ${TMPDIR}/cn6_$USER.ipset
ipset -! flush cn_ip6 2>/dev/null ipset -! flush cn_ip6 2>/dev/null
ipset -! restore < ${TMPDIR}/cn6_$USER.ipset ipset -! restore < ${TMPDIR}/cn6_$USER.ipset 2>/dev/null
rm -rf cn6_$USER.ipset rm -rf cn6_$USER.ipset
} }
} }
@@ -1482,12 +1478,11 @@ EOF
} }
core_check(){ core_check(){
#检查及下载内核文件 #检查及下载内核文件
if [ ! -f ${TMPDIR}/CrashCore ];then [ -n "$(find --help 2>&1|grep -o size)" ] && find_para=' -size +2000' #find命令兼容
if [ -f ${BINDIR}/CrashCore ];then [ -z "$(find ${TMPDIR}/CrashCore $find_para 2>/dev/null)" ] && [ -n "$(find ${BINDIR}/CrashCore $find_para 2>/dev/null)" ] && mv ${BINDIR}/CrashCore ${TMPDIR}/CrashCore
ln -sf ${BINDIR}/CrashCore ${TMPDIR}/CrashCore [ -z "$(find ${TMPDIR}/CrashCore $find_para 2>/dev/null)" ] && [ -n "$(find ${BINDIR}/CrashCore.tar.gz $find_para 2>/dev/null)" ] && \
elif [ -f ${BINDIR}/CrashCore.tar.gz ];then tar -zxf "${BINDIR}/CrashCore.tar.gz" -C ${TMPDIR}/ &>/dev/null || tar -zxf "${BINDIR}/CrashCore.tar.gz" --no-same-owner -C ${TMPDIR}/
tar -zxvf "${BINDIR}/CrashCore.tar.gz" -C ${TMPDIR}/ &>/dev/null || tar -zxvf "${BINDIR}/CrashCore.tar.gz" --no-same-owner -C ${TMPDIR}/ [ -z "$(find ${TMPDIR}/CrashCore $find_para 2>/dev/null)" ] && {
else
logger "未找到【$crashcore】核心,正在下载!" 33 logger "未找到【$crashcore】核心,正在下载!" 33
[ -z "$cpucore" ] && source ${CRASHDIR}/getdate.sh && getcpucore [ -z "$cpucore" ] && source ${CRASHDIR}/getdate.sh && getcpucore
[ -z "$cpucore" ] && logger 找不到设备的CPU信息请手动指定处理器架构类型 31 && exit 1 [ -z "$cpucore" ] && logger 找不到设备的CPU信息请手动指定处理器架构类型 31 && exit 1
@@ -1495,8 +1490,8 @@ core_check(){
#校验内核 #校验内核
mkdir -p ${TMPDIR}/core_tmp mkdir -p ${TMPDIR}/core_tmp
tar -zxvf "${TMPDIR}/CrashCore.tar.gz" -C ${TMPDIR}/core_tmp/ &>/dev/null || tar -zxvf "${TMPDIR}/CrashCore.tar.gz" --no-same-owner -C ${TMPDIR}/core_tmp/ tar -zxvf "${TMPDIR}/CrashCore.tar.gz" -C ${TMPDIR}/core_tmp/ &>/dev/null || tar -zxvf "${TMPDIR}/CrashCore.tar.gz" --no-same-owner -C ${TMPDIR}/core_tmp/
for file in $(find ${TMPDIR}/core_tmp 2>/dev/null);do for file in $(find ${TMPDIR}/core_tmp $find_para 2>/dev/null);do
[ -s $file ] && [ -n "$(echo $file | sed 's#.*/##' | grep -iE '(CrashCore|sing|meta|mihomo|clash|premium)')" ] && mv -f $file ${TMPDIR}/core_new [ -f $file ] && [ -n "$(echo $file | sed 's#.*/##' | grep -iE '(CrashCore|sing|meta|mihomo|clash|pre)')" ] && mv -f $file ${TMPDIR}/core_new
done done
rm -rf ${TMPDIR}/core_tmp rm -rf ${TMPDIR}/core_tmp
chmod +x ${TMPDIR}/core_new chmod +x ${TMPDIR}/core_new
@@ -1518,8 +1513,7 @@ core_check(){
setconfig crashcore $crashcore setconfig crashcore $crashcore
setconfig core_v $core_v setconfig core_v $core_v
fi fi
fi }
fi
[ ! -x ${TMPDIR}/CrashCore ] && chmod +x ${TMPDIR}/CrashCore 2>/dev/null #自动授权 [ ! -x ${TMPDIR}/CrashCore ] && chmod +x ${TMPDIR}/CrashCore 2>/dev/null #自动授权
return 0 return 0
} }
@@ -1688,6 +1682,7 @@ afstart(){ #启动后
mark_time #标记启动时间 mark_time #标记启动时间
[ -s ${CRASHDIR}/configs/web_save -o -s ${CRASHDIR}/configs/web_configs ] && web_restore &>/dev/null & #后台还原面板配置 [ -s ${CRASHDIR}/configs/web_save -o -s ${CRASHDIR}/configs/web_configs ] && web_restore &>/dev/null & #后台还原面板配置
{ sleep 5;logger ShellCrash服务已启动;} & #推送日志 { sleep 5;logger ShellCrash服务已启动;} & #推送日志
ckcmd mtd_storage.sh && mtd_storage.sh save &>/dev/null & #Padavan保存/etc/storage
#加载定时任务 #加载定时任务
[ -s ${CRASHDIR}/task/cron ] && croncmd ${CRASHDIR}/task/cron [ -s ${CRASHDIR}/task/cron ] && croncmd ${CRASHDIR}/task/cron
[ -s ${CRASHDIR}/task/running ] && { [ -s ${CRASHDIR}/task/running ] && {
@@ -1819,16 +1814,19 @@ debug)
getconfig getconfig
stop_firewall >/dev/null #清理路由策略 stop_firewall >/dev/null #清理路由策略
bfstart bfstart
[ -n "$2" ] && { if [ -n "$2" ];then
if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then if [ "$crashcore" = singbox -o "$crashcore" = singboxp ];then
sed -i "s/\"level\": \"info\"/\"level\": \"$2\"/" ${TMPDIR}/config.json sed -i "s/\"level\": \"info\"/\"level\": \"$2\"/" ${TMPDIR}/jsons/log.json 2>/dev/null
else else
sed -i "s/log-level: info/log-level: $2/" ${TMPDIR}/config.yaml sed -i "s/log-level: info/log-level: $2/" ${TMPDIR}/config.yaml
fi fi
} $COMMAND >${TMPDIR}/debug.log 2>&1 &
$COMMAND &>${TMPDIR}/debug.log & sleep 2
logger "已运行debug模式!如需停止,请使用重启/停止服务功能!" 33
else
$COMMAND >/dev/null 2>&1 &
fi
afstart afstart
logger "已运行debug模式!如需停止,请正常重启一次服务!" 33
;; ;;
init) init)
profile=/etc/profile profile=/etc/profile

View File

@@ -51,7 +51,7 @@ update_core(){ #自动更新内核
mkdir -p ${TMPDIR}/core_new mkdir -p ${TMPDIR}/core_new
tar -zxf "${TMPDIR}/core_new.tar.gz" -C ${TMPDIR}/core_new/ &>/dev/null || tar -zxf "${TMPDIR}/core_new.tar.gz" --no-same-owner -C ${TMPDIR}/core_new/ tar -zxf "${TMPDIR}/core_new.tar.gz" -C ${TMPDIR}/core_new/ &>/dev/null || tar -zxf "${TMPDIR}/core_new.tar.gz" --no-same-owner -C ${TMPDIR}/core_new/
for file in $(find ${TMPDIR}/core_tmp 2>/dev/null);do for file in $(find ${TMPDIR}/core_tmp 2>/dev/null);do
[ -s $file ] && [ -n "$(echo $file | sed 's#.*/##' | grep -iE '(CrashCore|sing|meta|mihomo|clash|premium)')" ] && mv -f $file ${TMPDIR}/core_new [ -f $file ] && [ -n "$(echo $file | sed 's#.*/##' | grep -iE '(CrashCore|sing|meta|mihomo|clash|premium)')" ] && mv -f $file ${TMPDIR}/core_new
done done
rm -rf ${TMPDIR}/core_new rm -rf ${TMPDIR}/core_new
} }