重构:移除部署脚本中的 SSL 证书操作
SSL 证书已配置完成,不再需要从部署脚本中执行 certbot。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -125,34 +125,6 @@ def check_ssh():
|
||||
log_info("SSH 连接正常")
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# SSL 证书
|
||||
# ============================================================================
|
||||
|
||||
|
||||
def deploy_ssl():
|
||||
"""申请 SSL 证书"""
|
||||
log_section("申请 SSL 证书")
|
||||
ssl_script = PROJECT_DIR / "tools" / "deploy-ssl-cert.py"
|
||||
if not ssl_script.exists():
|
||||
log_error(f"SSL 证书脚本不存在: {ssl_script}")
|
||||
return False
|
||||
|
||||
log_info("上传并执行 SSL 证书脚本...")
|
||||
ok, _, err = scp_file(str(ssl_script), "/tmp/deploy-ssl-cert.py", timeout=120)
|
||||
if not ok:
|
||||
log_error(f"上传 SSL 脚本失败: {err}")
|
||||
return False
|
||||
|
||||
ok, _, err = ssh_command("python3 /tmp/deploy-ssl-cert.py", timeout=300)
|
||||
if not ok:
|
||||
log_error(f"执行 SSL 脚本失败: {err}")
|
||||
return False
|
||||
|
||||
log_info("SSL 证书申请完成")
|
||||
return True
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Nginx 配置
|
||||
# ============================================================================
|
||||
@@ -369,7 +341,6 @@ def main():
|
||||
log_info(f"部署时间: {time.strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
|
||||
actions = {
|
||||
"ssl": lambda: check_ssh() or True and deploy_ssl(),
|
||||
"backend": lambda: check_ssh() or True and deploy_backend(),
|
||||
"frontend": lambda: check_ssh() or True and deploy_frontend(),
|
||||
"admin": lambda: check_ssh() or True and deploy_admin(),
|
||||
@@ -381,7 +352,6 @@ def main():
|
||||
|
||||
if deploy_type == "all":
|
||||
check_ssh()
|
||||
deploy_ssl() or True
|
||||
deploy_nginx() or True
|
||||
deploy_backend()
|
||||
deploy_frontend()
|
||||
@@ -392,7 +362,7 @@ def main():
|
||||
actions[deploy_type]()
|
||||
else:
|
||||
log_error(f"无效的部署类型: {deploy_type}")
|
||||
print("使用方法: python deploy.py [ssl|backend|frontend|admin|life-script|nginx|verify|all]")
|
||||
print("使用方法: python deploy.py [backend|frontend|admin|life-script|nginx|verify|all]")
|
||||
sys.exit(1)
|
||||
|
||||
duration = int(time.time() - start_time)
|
||||
|
||||
@@ -50,21 +50,6 @@ check_ssh() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# SSL 证书
|
||||
# ============================================================================
|
||||
deploy_ssl() {
|
||||
log_section "申请 SSL 证书"
|
||||
if [ ! -f "tools/deploy-ssl-cert.py" ]; then
|
||||
log_error "SSL 证书脚本不存在: tools/deploy-ssl-cert.py"
|
||||
return 1
|
||||
fi
|
||||
log_info "上传并执行 SSL 证书脚本..."
|
||||
scp tools/deploy-ssl-cert.py ${USERNAME}@${SERVER_IP}:/tmp/deploy-ssl-cert.py
|
||||
ssh ${USERNAME}@${SERVER_IP} "python3 /tmp/deploy-ssl-cert.py"
|
||||
log_info "✅ SSL 证书申请完成"
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# Nginx 配置
|
||||
# ============================================================================
|
||||
@@ -201,10 +186,6 @@ main() {
|
||||
log_info "部署时间: $(date '+%Y-%m-%d %H:%M:%S')"
|
||||
|
||||
case "$DEPLOY_TYPE" in
|
||||
ssl)
|
||||
check_ssh
|
||||
deploy_ssl
|
||||
;;
|
||||
backend)
|
||||
check_ssh
|
||||
deploy_backend
|
||||
@@ -230,7 +211,6 @@ main() {
|
||||
;;
|
||||
all)
|
||||
check_ssh
|
||||
deploy_ssl || true
|
||||
deploy_nginx || true
|
||||
deploy_backend
|
||||
deploy_frontend
|
||||
@@ -240,7 +220,7 @@ main() {
|
||||
;;
|
||||
*)
|
||||
log_error "无效的部署类型: $DEPLOY_TYPE"
|
||||
echo "使用方法: bash deploy.sh [ssl|backend|frontend|admin|life-script|nginx|verify|all]"
|
||||
echo "使用方法: bash deploy.sh [backend|frontend|admin|life-script|nginx|verify|all]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user