11#! /bin/bash
2- # 本地验证脚本
3- # Usage: bash scripts/validate-local.sh
4-
52set -e
63
74echo " === 配置验证开始 ==="
85
9- # 1. 检查当前 YAML 配置语法
106echo " 📋 检查当前 YAML 配置..."
11- if command -v python3 & > /dev/null; then
12- python3 - << 'PY '
7+ python3 - << 'PY '
138import yaml
149for path in [
15- 'stash/Stash-v4-public-airport.yaml',
1610 'stash/Stash-v4-public-airport-android.yaml',
11+ 'temp/NekoBox-Temporary-Import.yaml',
1712 'custom-rules-clash/My-Crypto.yaml',
1813 'custom-rules-clash/My-Finance-Direct.yaml',
1914]:
2015 with open(path, encoding='utf-8') as f:
2116 yaml.safe_load(f)
2217 print('✅ YAML 语法正确:', path)
2318PY
24- else
25- echo " ⚠️ 未安装 python3,跳过 YAML 检查"
26- fi
2719
28- # 2. 检查重复策略组
2920echo " 📋 检查重复策略组..."
30- for f in stash/Stash-v4-public-airport.yaml stash/Stash-v4-public-airport-android .yaml; do
21+ for f in stash/Stash-v4-public-airport-android .yaml temp/NekoBox-Temporary-Import .yaml; do
3122 DUPS=$( grep " ^ - name:" " $f " 2> /dev/null | sort | uniq -d)
3223 if [ -n " $DUPS " ]; then
3324 echo " ❌ 存在重复策略组: $f "
@@ -37,28 +28,19 @@ for f in stash/Stash-v4-public-airport.yaml stash/Stash-v4-public-airport-androi
3728done
3829echo " ✅ 无重复策略组"
3930
40- # 3. 检查当前自维护规则文件存在
4131echo " 📋 检查自维护规则文件..."
4232for f in custom-rules/My-Crypto.list custom-rules/My-Finance-Direct.list custom-rules-clash/My-Crypto.yaml custom-rules-clash/My-Finance-Direct.yaml; do
43- if [ -f " $f " ]; then
44- echo " ✅ $f "
45- else
46- echo " ❌ 缺失: $f "
47- exit 1
48- fi
33+ test -f " $f "
34+ echo " ✅ $f "
4935done
5036
51- # 4. 测试关键 URL 可访问性
5237echo " 📋 测试关键 URL 可访问性..."
5338FAILED=0
5439TEST_URLS=(
55- " https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/OpenAI/OpenAI.yaml"
56- " https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Google/Google.yaml"
57- " https://cdn.jsdelivr.net/gh/blackmatrix7/ios_rule_script@master/rule/Clash/Netflix/Netflix.yaml"
40+ " https://raw.githubusercontent.com/dodo258/surge/main/temp/NekoBox-Temporary-Import.yaml"
5841 " https://raw.githubusercontent.com/dodo258/surge/main/custom-rules-clash/My-Crypto.yaml"
5942 " https://raw.githubusercontent.com/dodo258/surge/main/custom-rules-clash/My-Finance-Direct.yaml"
6043)
61-
6244for url in " ${TEST_URLS[@]} " ; do
6345 HTTP_CODE=$( curl -L -s -o /dev/null -w " %{http_code}" " $url " 2> /dev/null)
6446 if [ " $HTTP_CODE " = " 404" ]; then
@@ -70,7 +52,6 @@ for url in "${TEST_URLS[@]}"; do
7052 echo " ⚠️ $HTTP_CODE : $url "
7153 fi
7254done
73-
7455if [ $FAILED -eq 1 ]; then
7556 exit 1
7657fi
0 commit comments