fix: 修复Gitee镜像加速仍从GitHub下载的问题

问题描述:
- 虽然显示"使用Gitee镜像加速"
- 但acme.sh安装脚本内部仍从GitHub下载tar.gz包
- 导致国内网络安装失败

根本原因:
- 使用了 --install-online 参数
- acme.sh脚本会在线下载master.tar.gz
- 默认还是从GitHub下载

修复方案:
- 使用acme.sh官方推荐的方法
- 设置环境变量 ACME_USE_GITEE=1
- 让acme.sh内部也使用Gitee源
- 移除 --install-online 参数

官方文档:
https://github.com/acmesh-official/acme.sh/wiki/Install-in-China

修复代码:
# 国内网络
export ACME_USE_GITEE=1
curl https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh

修复函数:
- deploy_acme_letsencrypt
- deploy_acme_zerossl
- deploy_acme_buypass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
WanWanYun
2025-11-13 01:41:14 +08:00
parent e915d5e4db
commit 4a73a8c348

View File

@@ -1244,16 +1244,22 @@ deploy_acme_letsencrypt() {
# 检测是否在中国大陆,使用镜像加速 # 检测是否在中国大陆,使用镜像加速
if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then
# 海外网络 # 海外网络 - 使用官方源
ACME_INSTALL_URL="https://get.acme.sh" if curl -fsSL https://get.acme.sh | sh; then
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
print_success "acme.sh 安装成功"
else else
# 中国大陆使用Gitee镜像 print_error "acme.sh 安装失败"
print_info "检测到国内网络使用Gitee镜像加速..." return 1
ACME_INSTALL_URL="https://gitee.com/neilpang/acme.sh/raw/master/acme.sh"
fi fi
else
# 中国大陆 - 使用Gitee镜像官方方法
print_info "检测到国内网络使用Gitee镜像加速..."
if curl -fsSL "$ACME_INSTALL_URL" | sh -s -- --install-online; then # 设置环境变量让acme.sh使用Gitee源
# 重新加载环境变量 export ACME_USE_GITEE=1
if curl -fsSL https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh; then
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
print_success "acme.sh 安装成功" print_success "acme.sh 安装成功"
else else
@@ -1261,12 +1267,13 @@ deploy_acme_letsencrypt() {
echo "" echo ""
print_warning "解决方案:" print_warning "解决方案:"
echo " 1. 检查网络连接" echo " 1. 检查网络连接"
echo " 2. 尝试手动安装: curl https://get.acme.sh | sh" echo " 2. 尝试手动安装: export ACME_USE_GITEE=1 && curl https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh"
echo " 3. 或访问: https://github.com/acmesh-official/acme.sh/wiki/Install-in-China" echo " 3. 或访问: https://github.com/acmesh-official/acme.sh/wiki/Install-in-China"
echo "" echo ""
return 1 return 1
fi fi
fi fi
fi
# 确认acme.sh可用 # 确认acme.sh可用
if [[ ! -f ~/.acme.sh/acme.sh ]]; then if [[ ! -f ~/.acme.sh/acme.sh ]]; then
@@ -1316,19 +1323,26 @@ deploy_acme_zerossl() {
# 检测网络环境 # 检测网络环境
if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then
ACME_INSTALL_URL="https://get.acme.sh" # 海外网络
else if curl -fsSL https://get.acme.sh | sh; then
print_info "检测到国内网络使用Gitee镜像加速..."
ACME_INSTALL_URL="https://gitee.com/neilpang/acme.sh/raw/master/acme.sh"
fi
if curl -fsSL "$ACME_INSTALL_URL" | sh -s -- --install-online; then
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
print_success "acme.sh 安装成功" print_success "acme.sh 安装成功"
else else
print_error "acme.sh 安装失败" print_error "acme.sh 安装失败"
return 1 return 1
fi fi
else
# 中国大陆 - 使用Gitee镜像
print_info "检测到国内网络使用Gitee镜像加速..."
export ACME_USE_GITEE=1
if curl -fsSL https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh; then
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
print_success "acme.sh 安装成功"
else
print_error "acme.sh 安装失败"
return 1
fi
fi
fi fi
# 确认acme.sh可用 # 确认acme.sh可用
@@ -1373,19 +1387,26 @@ deploy_acme_buypass() {
# 检测网络环境 # 检测网络环境
if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then
ACME_INSTALL_URL="https://get.acme.sh" # 海外网络
else if curl -fsSL https://get.acme.sh | sh; then
print_info "检测到国内网络使用Gitee镜像加速..."
ACME_INSTALL_URL="https://gitee.com/neilpang/acme.sh/raw/master/acme.sh"
fi
if curl -fsSL "$ACME_INSTALL_URL" | sh -s -- --install-online; then
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
print_success "acme.sh 安装成功" print_success "acme.sh 安装成功"
else else
print_error "acme.sh 安装失败" print_error "acme.sh 安装失败"
return 1 return 1
fi fi
else
# 中国大陆 - 使用Gitee镜像
print_info "检测到国内网络使用Gitee镜像加速..."
export ACME_USE_GITEE=1
if curl -fsSL https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh; then
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
print_success "acme.sh 安装成功"
else
print_error "acme.sh 安装失败"
return 1
fi
fi
fi fi
# 确认acme.sh可用 # 确认acme.sh可用