使用 sing-box check 的返回值来判断配置文件是否正确

This commit is contained in:
MoonFruit
2025-07-10 17:57:23 +08:00
parent 53a6b9f2c1
commit 0e8c77fa90

View File

@@ -403,7 +403,7 @@ EOF
#插入过滤规则 #插入过滤规则
cat >>"$TMPDIR"/dns.yaml <<EOF cat >>"$TMPDIR"/dns.yaml <<EOF
- "rule-set:geosite-cn" - "rule-set:geosite-cn"
nameserver-policy: nameserver-policy:
"+.googleapis.cn": [$dns_fallback] "+.googleapis.cn": [$dns_fallback]
EOF EOF
} }
@@ -893,8 +893,7 @@ EOF
} }
done done
#测试自定义配置文件 #测试自定义配置文件
error=$("$TMPDIR"/CrashCore check -D "$BINDIR" -C "$TMPDIR"/jsons 2>&1) if ! error=$("$TMPDIR"/CrashCore check -D "$BINDIR" -C "$TMPDIR"/jsons 2>&1); then
if [ -n "$error" ]; then
echo $error echo $error
error_file=$(echo $error | grep -Eo 'cust.*\.json' | sed 's/cust_//g') error_file=$(echo $error | grep -Eo 'cust.*\.json' | sed 's/cust_//g')
[ "$error_file" = 'add_rules.json' ] && error_file="$CRASHDIR"/yamls/rules.yaml自定义规则 || error_file="$CRASHDIR"/jsons/$error_file [ "$error_file" = 'add_rules.json' ] && error_file="$CRASHDIR"/yamls/rules.yaml自定义规则 || error_file="$CRASHDIR"/jsons/$error_file