From 204edd35eebf8ea06807a9953bf8f1b7ff06de7a Mon Sep 17 00:00:00 2001 From: FranzKafkayu Date: Fri, 9 Jun 2023 17:16:33 +0800 Subject: [PATCH] Fix multi certs issue --- x-ui.sh | 14 ++++---------- x-ui_en.sh | 22 ++++++++-------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/x-ui.sh b/x-ui.sh index 36e06f68f3..914c068a02 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -482,17 +482,14 @@ ssl_cert_issue_standalone() { certPath=/root/cert if [ ! -d "$certPath" ]; then mkdir $certPath - else - rm -rf $certPath - mkdir $certPath fi #get the domain here,and we need verify it local domain="" read -p "请输入你的域名:" domain LOGD "你输入的域名为:${domain},正在进行域名合法性校验..." #here we need to judge whether there exists cert already - local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}') - if [ ${currentCert} == ${domain} ]; then + local currentCert=$(~/.acme.sh/acme.sh --list | grep ${domain} | wc -l) + if [ ${currentCert} -ne 0 ]; then local certInfo=$(~/.acme.sh/acme.sh --list) LOGE "域名合法性校验失败,当前环境已有对应域名证书,不可重复申请,当前证书详情:" LOGI "$certInfo" @@ -566,16 +563,13 @@ ssl_cert_issue_by_cloudflare() { certPath=/root/cert if [ ! -d "$certPath" ]; then mkdir $certPath - else - rm -rf $certPath - mkdir $certPath fi LOGD "请设置域名:" read -p "Input your domain here:" CF_Domain LOGD "你的域名设置为:${CF_Domain},正在进行域名合法性校验..." #here we need to judge whether there exists cert already - local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}') - if [ ${currentCert} == ${CF_Domain} ]; then + local currentCert=$(~/.acme.sh/acme.sh --list | grep ${CF_Domain} | wc -l) + if [ ${currentCert} -ne 0 ]; then local certInfo=$(~/.acme.sh/acme.sh --list) LOGE "域名合法性校验失败,当前环境已有对应域名证书,不可重复申请,当前证书详情:" LOGI "$certInfo" diff --git a/x-ui_en.sh b/x-ui_en.sh index 5848646dc0..4dbd6e0924 100644 --- a/x-ui_en.sh +++ b/x-ui_en.sh @@ -474,17 +474,14 @@ ssl_cert_issue_standalone() { certPath=/root/cert if [ ! -d "$certPath" ]; then mkdir $certPath - else - rm -rf $certPath - mkdir $certPath fi #get the domain here,and we need verify it local domain="" read -p "please input your domain:" domain LOGD "your domain is:${domain},check it..." #here we need to judge whether there exists cert already - local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}') - if [ ${currentCert} == ${domain} ]; then + local currentCert=$(~/.acme.sh/acme.sh --list | grep ${domain} | wc -l) + if [ ${currentCert} -ne 0 ]; then local certInfo=$(~/.acme.sh/acme.sh --list) LOGE "system already have certs here,can not issue again,current certs details:" LOGI "$certInfo" @@ -512,8 +509,8 @@ ssl_cert_issue_standalone() { fi #install cert ~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \ - --cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \ - --fullchain-file /root/cert/fullchain.cer + --cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \ + --fullchain-file /root/cert/fullchain.cer if [ $? -ne 0 ]; then LOGE "install certs failed,exit" @@ -556,16 +553,13 @@ ssl_cert_issue_by_cloudflare() { certPath=/root/cert if [ ! -d "$certPath" ]; then mkdir $certPath - else - rm -rf $certPath - mkdir $certPath fi LOGD "please input your domain:" read -p "Input your domain here:" CF_Domain LOGD "your domain is:${CF_Domain},check it..." #here we need to judge whether there exists cert already - local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}') - if [ ${currentCert} == ${CF_Domain} ]; then + local currentCert=$(~/.acme.sh/acme.sh --list | grep ${CF_Domain} | wc -l) + if [ ${currentCert} -ne 0 ]; then local certInfo=$(~/.acme.sh/acme.sh --list) LOGE "system already have certs here,can not issue again,current certs details:" LOGI "$certInfo" @@ -595,8 +589,8 @@ ssl_cert_issue_by_cloudflare() { LOGI "issue cert succeed,installing..." fi ~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \ - --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ - --fullchain-file /root/cert/fullchain.cer + --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ + --fullchain-file /root/cert/fullchain.cer if [ $? -ne 0 ]; then LOGE "install cert failed,exit" rm -rf ~/.acme.sh/${CF_Domain}