fixed - multi domain ssl path

This commit is contained in:
MHSanaei 2023-04-02 21:01:08 +03:30
parent c07b2c73d7
commit e51c59995c

101
x-ui.sh
View File

@ -548,14 +548,7 @@ ssl_cert_issue_standalone() {
else else
LOGI "install socat succeed..." LOGI "install socat succeed..."
fi fi
#creat a directory for install cert
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 #get the domain here,and we need verify it
local domain="" local domain=""
read -p "please input your domain:" domain read -p "please input your domain:" domain
@ -570,6 +563,16 @@ ssl_cert_issue_standalone() {
else else
LOGI "your domain is ready for issuing cert now..." LOGI "your domain is ready for issuing cert now..."
fi fi
#create a directory for install cert
certPath="/root/cert/${domain}"
if [ ! -d "$certPath" ]; then
mkdir -p "$certPath"
else
rm -rf "$certPath"
mkdir -p "$certPath"
fi
#get needed port here #get needed port here
local WebPort=80 local WebPort=80
read -p "please choose which port do you use,default will be 80 port:" WebPort read -p "please choose which port do you use,default will be 80 port:" WebPort
@ -589,9 +592,9 @@ ssl_cert_issue_standalone() {
LOGE "issue certs succeed,installing certs..." LOGE "issue certs succeed,installing certs..."
fi fi
#install cert #install cert
~/.acme.sh/acme.sh --installcert -d ${domain} --ca-file /root/cert/ca.cer \ ~/.acme.sh/acme.sh --installcert -d ${domain} \
--cert-file /root/cert/${domain}.cer --key-file /root/cert/privkey.pem \ --key-file /root/cert/${domain}/privkey.pem \
--fullchain-file /root/cert/fullchain.pem --fullchain-file /root/cert/${domain}/fullchain.pem
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
LOGE "install certs failed,exit" LOGE "install certs failed,exit"
@ -600,17 +603,18 @@ ssl_cert_issue_standalone() {
else else
LOGI "install certs succeed,enable auto renew..." LOGI "install certs succeed,enable auto renew..."
fi fi
~/.acme.sh/acme.sh --upgrade --auto-upgrade
if [ $? -ne 0 ]; then ~/.acme.sh/acme.sh --upgrade --auto-upgrade
LOGE "auto renew failed,certs details:" if [ $? -ne 0 ]; then
ls -lah cert LOGE "auto renew failed, certs details:"
chmod 755 $certPath ls -lah cert/*
exit 1 chmod 755 $certPath/*
else exit 1
LOGI "auto renew succeed,certs details:" else
ls -lah cert LOGI "auto renew succeed, certs details:"
chmod 755 $certPath ls -lah cert/*
fi chmod 755 $certPath/*
fi
} }
@ -631,13 +635,7 @@ ssl_cert_issue_by_cloudflare() {
CF_Domain="" CF_Domain=""
CF_GlobalKey="" CF_GlobalKey=""
CF_AccountEmail="" CF_AccountEmail=""
certPath=/root/cert
if [ ! -d "$certPath" ]; then
mkdir $certPath
else
rm -rf $certPath
mkdir $certPath
fi
LOGD "please input your domain:" LOGD "please input your domain:"
read -p "Input your domain here:" CF_Domain read -p "Input your domain here:" CF_Domain
LOGD "your domain is:${CF_Domain},check it..." LOGD "your domain is:${CF_Domain},check it..."
@ -651,6 +649,16 @@ ssl_cert_issue_by_cloudflare() {
else else
LOGI "your domain is ready for issuing cert now..." LOGI "your domain is ready for issuing cert now..."
fi fi
#create a directory for install cert
certPath="/root/cert/${CF_Domain}"
if [ ! -d "$certPath" ]; then
mkdir -p "$certPath"
else
rm -rf "$certPath"
mkdir -p "$certPath"
fi
LOGD "please inout your cloudflare global API key:" LOGD "please inout your cloudflare global API key:"
read -p "Input your key here:" CF_GlobalKey read -p "Input your key here:" CF_GlobalKey
LOGD "your cloudflare global API key is:${CF_GlobalKey}" LOGD "your cloudflare global API key is:${CF_GlobalKey}"
@ -672,9 +680,10 @@ ssl_cert_issue_by_cloudflare() {
else else
LOGI "Certificate issued Successfully, Installing..." LOGI "Certificate issued Successfully, Installing..."
fi fi
~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \ ~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} \
--cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ --key-file /root/cert/${CF_Domain}/privkey.pem \
--fullchain-file /root/cert/fullchain.cer --fullchain-file /root/cert/${CF_Domain}/fullchain.pem
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
LOGE "install cert failed,exit" LOGE "install cert failed,exit"
rm -rf ~/.acme.sh/${CF_Domain} rm -rf ~/.acme.sh/${CF_Domain}
@ -682,17 +691,17 @@ ssl_cert_issue_by_cloudflare() {
else else
LOGI "Certificate installed Successfully,Turning on automatic updates..." LOGI "Certificate installed Successfully,Turning on automatic updates..."
fi fi
~/.acme.sh/acme.sh --upgrade --auto-upgrade ~/.acme.sh/acme.sh --upgrade --auto-upgrade
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
LOGE "Auto update setup Failed, script exiting..." LOGE "auto renew failed, certs details:"
ls -lah cert ls -lah cert/*
chmod 755 $certPath chmod 755 $certPath/*
exit 1 exit 1
else else
LOGI "The certificate is installed and auto-renewal is turned on, Specific information is as follows" LOGI "auto renew succeed, certs details:"
ls -lah cert ls -lah cert/*
chmod 755 $certPath chmod 755 $certPath/*
fi fi
else else
show_menu show_menu
fi fi
@ -739,9 +748,9 @@ show_menu() {
${green}14.${plain} Disabel x-ui On System Startup ${green}14.${plain} Disabel x-ui On System Startup
———————————————— ————————————————
${green}15.${plain} Enable BBR ${green}15.${plain} Enable BBR
${green}16.${plain} Issuse Certs ${green}16.${plain} Apply for an SSL Certificate
${green}17.${plain} Update Geoip and Geosite ${green}17.${plain} Update Geo Files
${green}18.${plain} Enable Firewall and open Ports ${green}18.${plain} Active Firewall and open ports
" "
show_status show_status
echo && read -p "Please enter your selection [0-18]: " num echo && read -p "Please enter your selection [0-18]: " num