做网站先得注册域名吗,网站cdn+自己做,网站建设哪家公司便宜,网站备案的公司注销了由于某些需要我们重新申请ssl证书#xff0c;x-ui自动化脚本不能强制更新#xff0c;根据x-ui仓库源码#xff1a;
https://github.com/vaxilu/x-ui/blob/main/x-ui.sh 在申请ssl证书的地方稍作修改#xff0c;得到#xff0c;运行下面的脚本就可以重新申请ssl证书#…由于某些需要我们重新申请ssl证书x-ui自动化脚本不能强制更新根据x-ui仓库源码
https://github.com/vaxilu/x-ui/blob/main/x-ui.sh 在申请ssl证书的地方稍作修改得到运行下面的脚本就可以重新申请ssl证书不过建议使用global key和origin key的方式更安全这里我就不改了还是按照global key和cf邮箱的方式
#!/bin/bashRED\033[31m
GREEN\033[32m
YELLOW\033[33m
BLUE\033[34m
RESET\033[0m# 日志函数
LOGD() { echo -e ${BLUE}[DEBUG] $* ${RESET}; }
LOGI() { echo -e ${GREEN}[INFO] $* ${RESET}; }
LOGE() { echo -e ${RED}[ERROR] $* ${RESET}; }confirm() {local prompt$1 (默认: $2) local default$2read -p $prompt answeranswer${answer:-$default}[[ $answer ~ ^[Yy]$ ]] return 0 || return 1
}echo -e \n${YELLOW}****** 使用说明 ******${RESET}
LOGI 该脚本将使用 Acme 脚本申请证书使用时需保证
LOGI 1. 知晓 Cloudflare 注册邮箱
LOGI 2. 知晓 Cloudflare Global API Key
LOGI 3. 域名已通过 Cloudflare 解析到当前服务器
LOGI 4. 证书默认安装路径为 /root/cert 目录confirm 我已确认以上内容 [y/n] y || { echo -e ${RED}用户取消操作退出脚本${RESET}; exit 1; }cd ~ || { LOGE 无法进入用户目录; exit 1; }# 安装 acme.sh
LOGI 正在安装 Acme 脚本...
curl https://get.acme.sh | sh
if [ $? -ne 0 ]; thenLOGE 安装 acme.sh 失败exit 1
fiCF_Domain
CF_GlobalKey
CF_AccountEmail
certPath/root/cert# 清理并创建证书目录
LOGI 设置证书目录: $certPath
rm -rf $certPath 2/dev/null
mkdir -p $certPath || { LOGE 创建目录失败; exit 1; }LOGD 请输入域名如 example.com:
read -p Input your domain here: CF_Domain
LOGD 你的域名设置为: ${CF_Domain}LOGD 请输入 Cloudflare Global API Key:
read -p Input your key here: CF_GlobalKey
LOGD 你的 API 密钥为: ${CF_GlobalKey}LOGD 请输入 Cloudflare 注册邮箱:
read -p Input your email here: CF_AccountEmail
LOGD 你的注册邮箱为: ${CF_AccountEmail}# 设置默认 CA
LOGI 配置默认证书颁发机构为 Lets Encrypt...
~/.acme.sh/acme.sh --set-default-ca --server letsencrypt || { LOGE 配置 CA 失败; exit 1; }export CF_Key${CF_GlobalKey}
export CF_Email${CF_AccountEmail}# 申请证书
LOGI 正在签发证书域名: ${CF_Domain}...
~/.acme.sh/acme.sh --issue --dns dns_cf -d ${CF_Domain} -d *.${CF_Domain} --log --force
if [ $? -ne 0 ]; thenLOGE 证书签发失败exit 1
fi# 安装证书
LOGI 正在安装证书到 $certPath ...
~/.acme.sh/acme.sh --install-cert -d ${CF_Domain} -d *.${CF_Domain} \--ca-file ${certPath}/ca.cer \--cert-file ${certPath}/${CF_Domain}.cer \--key-file ${certPath}/${CF_Domain}.key \--fullchain-file ${certPath}/fullchain.cerif [ $? -ne 0 ]; thenLOGE 证书安装失败exit 1
fi# 设置自动更新
LOGI 启用自动更新...
~/.acme.sh/acme.sh --upgrade --auto-upgrade || { LOGE 自动更新设置失败; exit 1; }# 设置权限
LOGI 设置证书文件权限...
chmod 600 ${certPath}/*.cer ${certPath}/*.key 2/dev/null
chmod 700 $certPathLOGI ${GREEN}证书申请成功${RESET}
echo -e \n${YELLOW}证书文件信息:${RESET}
ls -lah $certPathexit 0