fix: 增强acme.sh安装验证,立即检查目录是否创建
问题: - 用户反馈方法2-4(acme.sh系列)显示"安装目录不存在" - 安装命令返回成功(exit 0)但目录未创建 - 导致验证阶段报错但无法诊断原因 原因分析: - 安装命令可能显示帮助文本而非真正安装 - 仅依赖exit code无法判断是否真正安装成功 - 缺少安装后的立即验证 改进: 1. 捕获安装命令的退出码(不再使用if判断) 2. 安装后立即检查目录和文件是否创建 3. 验证条件:exit code = 0 AND 目录存在 AND 文件存在 4. 失败时显示详细诊断信息: - 安装命令退出码 - 目录是否存在 - 文件是否存在 - HOME环境变量 - 当前用户 5. 统一三个acme.sh函数的验证逻辑 预期效果: - 如果安装真的失败,会显示详细诊断信息 - 用户和开发者可以根据诊断信息判断具体问题 - 不再有"显示成功但实际失败"的情况 影响函数: - deploy_acme_letsencrypt() - deploy_acme_zerossl() - deploy_acme_buypass() 相关提交: -18512d9(增强acme.sh验证逻辑) -4a73a8c(Gitee镜像加速)
This commit is contained in:
97
install.sh
97
install.sh
@@ -1315,13 +1315,9 @@ deploy_acme_letsencrypt() {
|
||||
# 检测是否在中国大陆,使用镜像加速
|
||||
if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then
|
||||
# 海外网络 - 使用官方源
|
||||
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
|
||||
print_error "acme.sh 安装失败"
|
||||
return 1
|
||||
fi
|
||||
print_info "使用官方源安装..."
|
||||
curl -fsSL https://get.acme.sh | sh
|
||||
install_result=$?
|
||||
else
|
||||
# 中国大陆 - 使用Gitee镜像(官方方法)
|
||||
print_info "检测到国内网络,使用Gitee镜像加速..."
|
||||
@@ -1329,21 +1325,38 @@ deploy_acme_letsencrypt() {
|
||||
# 设置环境变量,让acme.sh使用Gitee源
|
||||
export ACME_USE_GITEE=1
|
||||
|
||||
if curl -fsSL https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh; then
|
||||
curl -fsSL https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh
|
||||
install_result=$?
|
||||
fi
|
||||
|
||||
# 重新加载环境变量
|
||||
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
|
||||
|
||||
# 等待文件系统同步
|
||||
sleep 2
|
||||
|
||||
# 验证安装是否真正成功(检查目录是否创建)
|
||||
if [[ $install_result -eq 0 ]] && [[ -d ~/.acme.sh ]] && [[ -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_success "acme.sh 安装成功"
|
||||
else
|
||||
print_error "acme.sh 安装失败"
|
||||
echo ""
|
||||
print_warning "诊断信息:"
|
||||
echo " - 安装命令退出码: $install_result"
|
||||
echo " - 目录 ~/.acme.sh 存在: $([ -d ~/.acme.sh ] && echo '是' || echo '否')"
|
||||
echo " - 文件 ~/.acme.sh/acme.sh 存在: $([ -f ~/.acme.sh/acme.sh ] && echo '是' || echo '否')"
|
||||
echo " - HOME变量: $HOME"
|
||||
echo " - 当前用户: $(whoami)"
|
||||
echo ""
|
||||
print_warning "解决方案:"
|
||||
echo " 1. 检查网络连接"
|
||||
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 " 2. 查看安装日志: ls -la ~ | grep acme"
|
||||
echo " 3. 手动安装: export ACME_USE_GITEE=1 && curl https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh"
|
||||
echo " 4. 或访问: https://github.com/acmesh-official/acme.sh/wiki/Install-in-China"
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# 确认acme.sh可用
|
||||
echo ""
|
||||
@@ -1423,26 +1436,39 @@ deploy_acme_zerossl() {
|
||||
# 检测网络环境
|
||||
if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then
|
||||
# 海外网络
|
||||
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
|
||||
print_error "acme.sh 安装失败"
|
||||
return 1
|
||||
fi
|
||||
print_info "使用官方源安装..."
|
||||
curl -fsSL https://get.acme.sh | sh
|
||||
install_result=$?
|
||||
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
|
||||
curl -fsSL https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh
|
||||
install_result=$?
|
||||
fi
|
||||
|
||||
# 重新加载环境变量
|
||||
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
|
||||
|
||||
# 等待文件系统同步
|
||||
sleep 2
|
||||
|
||||
# 验证安装是否真正成功(检查目录是否创建)
|
||||
if [[ $install_result -eq 0 ]] && [[ -d ~/.acme.sh ]] && [[ -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_success "acme.sh 安装成功"
|
||||
else
|
||||
print_error "acme.sh 安装失败"
|
||||
echo ""
|
||||
print_warning "诊断信息:"
|
||||
echo " - 安装命令退出码: $install_result"
|
||||
echo " - 目录 ~/.acme.sh 存在: $([ -d ~/.acme.sh ] && echo '是' || echo '否')"
|
||||
echo " - 文件 ~/.acme.sh/acme.sh 存在: $([ -f ~/.acme.sh/acme.sh ] && echo '是' || echo '否')"
|
||||
echo " - HOME变量: $HOME"
|
||||
echo " - 当前用户: $(whoami)"
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# 确认acme.sh可用
|
||||
echo ""
|
||||
@@ -1516,26 +1542,39 @@ deploy_acme_buypass() {
|
||||
# 检测网络环境
|
||||
if curl -s --connect-timeout 3 https://www.google.com > /dev/null 2>&1; then
|
||||
# 海外网络
|
||||
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
|
||||
print_error "acme.sh 安装失败"
|
||||
return 1
|
||||
fi
|
||||
print_info "使用官方源安装..."
|
||||
curl -fsSL https://get.acme.sh | sh
|
||||
install_result=$?
|
||||
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
|
||||
curl -fsSL https://gitee.com/neilpang/acme.sh/raw/master/acme.sh | sh
|
||||
install_result=$?
|
||||
fi
|
||||
|
||||
# 重新加载环境变量
|
||||
source ~/.bashrc 2>/dev/null || source ~/.profile 2>/dev/null || true
|
||||
|
||||
# 等待文件系统同步
|
||||
sleep 2
|
||||
|
||||
# 验证安装是否真正成功(检查目录是否创建)
|
||||
if [[ $install_result -eq 0 ]] && [[ -d ~/.acme.sh ]] && [[ -f ~/.acme.sh/acme.sh ]]; then
|
||||
print_success "acme.sh 安装成功"
|
||||
else
|
||||
print_error "acme.sh 安装失败"
|
||||
echo ""
|
||||
print_warning "诊断信息:"
|
||||
echo " - 安装命令退出码: $install_result"
|
||||
echo " - 目录 ~/.acme.sh 存在: $([ -d ~/.acme.sh ] && echo '是' || echo '否')"
|
||||
echo " - 文件 ~/.acme.sh/acme.sh 存在: $([ -f ~/.acme.sh/acme.sh ] && echo '是' || echo '否')"
|
||||
echo " - HOME变量: $HOME"
|
||||
echo " - 当前用户: $(whoami)"
|
||||
echo ""
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# 确认acme.sh可用
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user