| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/bin/bash
- # Certbot 自动安装脚本
- # 支持 Debian/Ubuntu, CentOS/RHEL, Fedora
- echo "=== 检测系统类型 ==="
- if [ -f /etc/os-release ]; then
- . /etc/os-release
- echo "系统: $NAME"
- echo "版本: $VERSION"
- else
- echo "无法检测系统类型"
- exit 1
- fi
- echo ""
- echo "=== 开始安装 Certbot ==="
- # 检测包管理器并安装
- if command -v apt &> /dev/null; then
- echo "检测到 apt (Debian/Ubuntu)"
- sudo apt update
- sudo apt install certbot python3-certbot-nginx -y
-
- elif command -v yum &> /dev/null; then
- echo "检测到 yum (CentOS/RHEL)"
- # 安装 EPEL 仓库
- sudo yum install epel-release -y
- sudo yum install certbot python3-certbot-nginx -y
-
- elif command -v dnf &> /dev/null; then
- echo "检测到 dnf (Fedora/CentOS 8+)"
- sudo dnf install epel-release -y
- sudo dnf install certbot python3-certbot-nginx -y
-
- else
- echo "未检测到支持的包管理器"
- echo "尝试使用 pip 安装..."
- if command -v pip3 &> /dev/null; then
- sudo pip3 install certbot certbot-nginx
- else
- echo "错误: 无法安装 certbot"
- exit 1
- fi
- fi
- echo ""
- echo "=== 验证安装 ==="
- if command -v certbot &> /dev/null; then
- certbot --version
- echo ""
- echo "✅ Certbot 安装成功!"
- echo ""
- echo "下一步: 运行以下命令获取 SSL 证书"
- echo "sudo certbot --nginx -d aiorz.com -d www.aiorz.com"
- else
- echo "❌ Certbot 安装失败"
- exit 1
- fi
|