Skip to content
This repository was archived by the owner on Nov 13, 2024. It is now read-only.

Commit 204edd3

Browse files
committed
Fix multi certs issue
1 parent 7520286 commit 204edd3

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

x-ui.sh

+4-10
Original file line numberDiff line numberDiff line change
@@ -482,17 +482,14 @@ ssl_cert_issue_standalone() {
482482
certPath=/root/cert
483483
if [ ! -d "$certPath" ]; then
484484
mkdir $certPath
485-
else
486-
rm -rf $certPath
487-
mkdir $certPath
488485
fi
489486
#get the domain here,and we need verify it
490487
local domain=""
491488
read -p "请输入你的域名:" domain
492489
LOGD "你输入的域名为:${domain},正在进行域名合法性校验..."
493490
#here we need to judge whether there exists cert already
494-
local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
495-
if [ ${currentCert} == ${domain} ]; then
491+
local currentCert=$(~/.acme.sh/acme.sh --list | grep ${domain} | wc -l)
492+
if [ ${currentCert} -ne 0 ]; then
496493
local certInfo=$(~/.acme.sh/acme.sh --list)
497494
LOGE "域名合法性校验失败,当前环境已有对应域名证书,不可重复申请,当前证书详情:"
498495
LOGI "$certInfo"
@@ -566,16 +563,13 @@ ssl_cert_issue_by_cloudflare() {
566563
certPath=/root/cert
567564
if [ ! -d "$certPath" ]; then
568565
mkdir $certPath
569-
else
570-
rm -rf $certPath
571-
mkdir $certPath
572566
fi
573567
LOGD "请设置域名:"
574568
read -p "Input your domain here:" CF_Domain
575569
LOGD "你的域名设置为:${CF_Domain},正在进行域名合法性校验..."
576570
#here we need to judge whether there exists cert already
577-
local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
578-
if [ ${currentCert} == ${CF_Domain} ]; then
571+
local currentCert=$(~/.acme.sh/acme.sh --list | grep ${CF_Domain} | wc -l)
572+
if [ ${currentCert} -ne 0 ]; then
579573
local certInfo=$(~/.acme.sh/acme.sh --list)
580574
LOGE "域名合法性校验失败,当前环境已有对应域名证书,不可重复申请,当前证书详情:"
581575
LOGI "$certInfo"

x-ui_en.sh

+8-14
Original file line numberDiff line numberDiff line change
@@ -474,17 +474,14 @@ ssl_cert_issue_standalone() {
474474
certPath=/root/cert
475475
if [ ! -d "$certPath" ]; then
476476
mkdir $certPath
477-
else
478-
rm -rf $certPath
479-
mkdir $certPath
480477
fi
481478
#get the domain here,and we need verify it
482479
local domain=""
483480
read -p "please input your domain:" domain
484481
LOGD "your domain is:${domain},check it..."
485482
#here we need to judge whether there exists cert already
486-
local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
487-
if [ ${currentCert} == ${domain} ]; then
483+
local currentCert=$(~/.acme.sh/acme.sh --list | grep ${domain} | wc -l)
484+
if [ ${currentCert} -ne 0 ]; then
488485
local certInfo=$(~/.acme.sh/acme.sh --list)
489486
LOGE "system already have certs here,can not issue again,current certs details:"
490487
LOGI "$certInfo"
@@ -512,8 +509,8 @@ ssl_cert_issue_standalone() {
512509
fi
513510
#install cert
514511
~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \
515-
--cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \
516-
--fullchain-file /root/cert/fullchain.cer
512+
--cert-file /root/cert/${domain}.cer --key-file /root/cert/${domain}.key \
513+
--fullchain-file /root/cert/fullchain.cer
517514

518515
if [ $? -ne 0 ]; then
519516
LOGE "install certs failed,exit"
@@ -556,16 +553,13 @@ ssl_cert_issue_by_cloudflare() {
556553
certPath=/root/cert
557554
if [ ! -d "$certPath" ]; then
558555
mkdir $certPath
559-
else
560-
rm -rf $certPath
561-
mkdir $certPath
562556
fi
563557
LOGD "please input your domain:"
564558
read -p "Input your domain here:" CF_Domain
565559
LOGD "your domain is:${CF_Domain},check it..."
566560
#here we need to judge whether there exists cert already
567-
local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}')
568-
if [ ${currentCert} == ${CF_Domain} ]; then
561+
local currentCert=$(~/.acme.sh/acme.sh --list | grep ${CF_Domain} | wc -l)
562+
if [ ${currentCert} -ne 0 ]; then
569563
local certInfo=$(~/.acme.sh/acme.sh --list)
570564
LOGE "system already have certs here,can not issue again,current certs details:"
571565
LOGI "$certInfo"
@@ -595,8 +589,8 @@ ssl_cert_issue_by_cloudflare() {
595589
LOGI "issue cert succeed,installing..."
596590
fi
597591
~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \
598-
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
599-
--fullchain-file /root/cert/fullchain.cer
592+
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \
593+
--fullchain-file /root/cert/fullchain.cer
600594
if [ $? -ne 0 ]; then
601595
LOGE "install cert failed,exit"
602596
rm -rf ~/.acme.sh/${CF_Domain}

0 commit comments

Comments
 (0)