mirror of
https://github.com/wnlen/clash-for-linux.git
synced 2026-10-10 04:03:04 +08:00
7018217281
mihomo 默认从 raw.githubusercontent.com 下载 GEO 数据库 (https://github.com/MetaCubeX/mihomo/blob/Meta/config/config.go#L570-L575), 在大部分国内网络环境下无法获取,导致启动失败。 复现方式: cat >/tmp/geosite-test.yaml <<'YAML' mixed-port: 7890 allow-lan: false mode: rule log-level: debug proxies: [] proxy-groups: [] rules: - GEOSITE,cn,DIRECT YAML /root/clash/runtime/bin/mihomo -t -f /tmp/geosite-test.yaml -d /root/clash/runtime 报错: INFO Start initial configuration in progress INFO Geodata Loader mode: memconservative INFO Geosite Matcher implementation: succinct INFO Can't find GeoSite.dat, start download ERRO can't initial GeoSite: can't download GeoSite.dat: Get "https://release-assets.githubusercontent.com/...": context deadline exceeded ERRO rules[0] [GEOSITE,cn,DIRECT] error: can't download GeoSite.dat: context deadline exceeded configuration file /tmp/geosite-test.yaml test failed 新增 resolve_geo_assets 在安装阶段通过 GitHub 镜像池预下载全部 GEO 资产 到 RUNTIME_DIR,避免 mihomo 启动时因网络不通而失败。 资产列表对齐 mihomo GeoXUrl 默认值: Country.mmdb / geoip.metadb / GeoLite2-ASN.mmdb / GeoIP.dat / GeoSite.dat - 复用 copy_bundled_asset 优先从 resources/geo/ 复制 - 本地不存在时通过 download_file 走 default_github_mirror_pool 镜像加速 - copy_bundled_asset 增加 $RESOURCE_DIR/$category/$file 搜索路径
75 lines
2.2 KiB
Bash
Executable File
75 lines
2.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
sed -i 's/\r$//' "$0" 2>/dev/null || true
|
|
|
|
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
source "$PROJECT_DIR/scripts/core/common.sh"
|
|
source "$PROJECT_DIR/scripts/core/runtime.sh"
|
|
source "$PROJECT_DIR/scripts/core/config.sh"
|
|
source "$PROJECT_DIR/scripts/init/systemd.sh"
|
|
source "$PROJECT_DIR/scripts/init/systemd-user.sh"
|
|
source "$PROJECT_DIR/scripts/init/script.sh"
|
|
|
|
init_project_context "$PROJECT_DIR"
|
|
guard_unsafe_sudo_auto_install "${1:-}"
|
|
load_env_if_exists
|
|
migrate_env_legacy_compat_fields "$PROJECT_DIR/.env"
|
|
detect_install_scope "${1:-auto}"
|
|
ensure_project_not_wsl_windows_mount
|
|
|
|
ensure_openwrt_install_supported
|
|
ensure_required_commands
|
|
|
|
init_layout
|
|
ensure_dashboard_deploy_prerequisites
|
|
|
|
resolve_geo_assets
|
|
|
|
resolve_runtime_kernel
|
|
resolve_yq
|
|
resolve_subconverter
|
|
|
|
mark_install_environment || true
|
|
mark_install_plan || true
|
|
mark_install_port_plan || true
|
|
|
|
install_clashctl_entry
|
|
install_clashctl_completion
|
|
install_shell_alias_entry
|
|
install_runtime_entry
|
|
install_local_dashboard_assets
|
|
ensure_controller_secret >/dev/null
|
|
set_shell_proxy_persist_enabled "false"
|
|
|
|
ensure_subscription_bootstrap_for_install "default"
|
|
prompt_subscription_if_needed
|
|
|
|
if [ -n "$(subscription_url 2>/dev/null || true)" ]; then
|
|
if generate_config; then
|
|
if [ -n "${INSTALL_PENDING_SUBSCRIPTION_URL:-}" ]; then
|
|
write_env_value "CLASH_SUBSCRIPTION_URL" "$INSTALL_PENDING_SUBSCRIPTION_URL"
|
|
fi
|
|
echo "✨ 订阅已生效"
|
|
post_install_verify
|
|
else
|
|
write_runtime_value "INSTALL_VERIFY_CONFIG_READY" "false"
|
|
write_runtime_value "INSTALL_VERIFY_RUNTIME_READY" "false"
|
|
write_runtime_value "INSTALL_VERIFY_CONTROLLER_READY" "false"
|
|
|
|
echo
|
|
echo "❗ 安装未完成:订阅编译失败"
|
|
if [ -n "$(read_build_value "BUILD_LAST_ERROR_SUMMARY" 2>/dev/null || true)" ]; then
|
|
echo "❌ 原因:$(read_build_value "BUILD_LAST_ERROR_SUMMARY" 2>/dev/null || true)"
|
|
fi
|
|
if [ -f "$RUNTIME_DIR/tmp/subscription-invalid-preview.txt" ]; then
|
|
echo "🧾 调试预览:$RUNTIME_DIR/tmp/subscription-invalid-preview.txt"
|
|
fi
|
|
echo "👉 下一步:clashctl doctor"
|
|
echo
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
print_install_summary
|