mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-04-16 12:35:54 +00:00
Reworked --installcert success criteria, cleanup behavior adjusted.
This commit is contained in:
parent
99ce1fcba5
commit
03e7e4cd20
3 changed files with 42 additions and 15 deletions
19
install.sh
19
install.sh
|
|
@ -457,16 +457,25 @@ ssl_cert_issue() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install the certificate
|
# install the certificate
|
||||||
# acme.sh may exit non-zero when reloadcmd fails even if cert files are installed.
|
local installOutput=""
|
||||||
~/.acme.sh/acme.sh --installcert -d ${domain} \
|
installOutput=$(~/.acme.sh/acme.sh --installcert -d ${domain} \
|
||||||
--key-file /root/cert/${domain}/privkey.pem \
|
--key-file /root/cert/${domain}/privkey.pem \
|
||||||
--fullchain-file /root/cert/${domain}/fullchain.pem --reloadcmd "${reloadCmd}" 2>&1 || true
|
--fullchain-file /root/cert/${domain}/fullchain.pem --reloadcmd "${reloadCmd}" 2>&1)
|
||||||
|
local installRc=$?
|
||||||
|
echo "${installOutput}"
|
||||||
|
|
||||||
if [[ -f "/root/cert/${domain}/privkey.pem" && -f "/root/cert/${domain}/fullchain.pem" ]]; then
|
local installWroteFiles=0
|
||||||
|
if echo "${installOutput}" | grep -q "Installing key to:" && echo "${installOutput}" | grep -q "Installing full chain to:"; then
|
||||||
|
installWroteFiles=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "/root/cert/${domain}/privkey.pem" && -f "/root/cert/${domain}/fullchain.pem" && ( ${installRc} -eq 0 || ${installWroteFiles} -eq 1 ) ]]; then
|
||||||
echo -e "${green}Installing certificate succeeded, enabling auto renew...${plain}"
|
echo -e "${green}Installing certificate succeeded, enabling auto renew...${plain}"
|
||||||
else
|
else
|
||||||
echo -e "${red}Installing certificate failed, exiting.${plain}"
|
echo -e "${red}Installing certificate failed, exiting.${plain}"
|
||||||
rm -rf ~/.acme.sh/${domain}
|
if [[ ${cert_exists} -eq 0 ]]; then
|
||||||
|
rm -rf ~/.acme.sh/${domain}
|
||||||
|
fi
|
||||||
systemctl start x-ui 2>/dev/null || rc-service x-ui start 2>/dev/null
|
systemctl start x-ui 2>/dev/null || rc-service x-ui start 2>/dev/null
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
19
update.sh
19
update.sh
|
|
@ -480,16 +480,25 @@ ssl_cert_issue() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install the certificate
|
# install the certificate
|
||||||
# acme.sh may exit non-zero when reloadcmd fails even if cert files are installed.
|
local installOutput=""
|
||||||
~/.acme.sh/acme.sh --installcert -d ${domain} \
|
installOutput=$(~/.acme.sh/acme.sh --installcert -d ${domain} \
|
||||||
--key-file /root/cert/${domain}/privkey.pem \
|
--key-file /root/cert/${domain}/privkey.pem \
|
||||||
--fullchain-file /root/cert/${domain}/fullchain.pem --reloadcmd "${reloadCmd}" 2>&1 || true
|
--fullchain-file /root/cert/${domain}/fullchain.pem --reloadcmd "${reloadCmd}" 2>&1)
|
||||||
|
local installRc=$?
|
||||||
|
echo "${installOutput}"
|
||||||
|
|
||||||
if [[ -f "/root/cert/${domain}/privkey.pem" && -f "/root/cert/${domain}/fullchain.pem" ]]; then
|
local installWroteFiles=0
|
||||||
|
if echo "${installOutput}" | grep -q "Installing key to:" && echo "${installOutput}" | grep -q "Installing full chain to:"; then
|
||||||
|
installWroteFiles=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "/root/cert/${domain}/privkey.pem" && -f "/root/cert/${domain}/fullchain.pem" && ( ${installRc} -eq 0 || ${installWroteFiles} -eq 1 ) ]]; then
|
||||||
echo -e "${green}Installing certificate succeeded, enabling auto renew...${plain}"
|
echo -e "${green}Installing certificate succeeded, enabling auto renew...${plain}"
|
||||||
else
|
else
|
||||||
echo -e "${red}Installing certificate failed, exiting.${plain}"
|
echo -e "${red}Installing certificate failed, exiting.${plain}"
|
||||||
rm -rf ~/.acme.sh/${domain}
|
if [[ ${cert_exists} -eq 0 ]]; then
|
||||||
|
rm -rf ~/.acme.sh/${domain}
|
||||||
|
fi
|
||||||
systemctl start x-ui 2>/dev/null || rc-service x-ui start 2>/dev/null
|
systemctl start x-ui 2>/dev/null || rc-service x-ui start 2>/dev/null
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
19
x-ui.sh
19
x-ui.sh
|
|
@ -1444,16 +1444,25 @@ ssl_cert_issue() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install the certificate
|
# install the certificate
|
||||||
# acme.sh may exit non-zero when reloadcmd fails even if cert files are installed.
|
local installOutput=""
|
||||||
~/.acme.sh/acme.sh --installcert -d ${domain} \
|
installOutput=$(~/.acme.sh/acme.sh --installcert -d ${domain} \
|
||||||
--key-file /root/cert/${domain}/privkey.pem \
|
--key-file /root/cert/${domain}/privkey.pem \
|
||||||
--fullchain-file /root/cert/${domain}/fullchain.pem --reloadcmd "${reloadCmd}" 2>&1 || true
|
--fullchain-file /root/cert/${domain}/fullchain.pem --reloadcmd "${reloadCmd}" 2>&1)
|
||||||
|
local installRc=$?
|
||||||
|
echo "${installOutput}"
|
||||||
|
|
||||||
if [[ -f "/root/cert/${domain}/privkey.pem" && -f "/root/cert/${domain}/fullchain.pem" ]]; then
|
local installWroteFiles=0
|
||||||
|
if echo "${installOutput}" | grep -q "Installing key to:" && echo "${installOutput}" | grep -q "Installing full chain to:"; then
|
||||||
|
installWroteFiles=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f "/root/cert/${domain}/privkey.pem" && -f "/root/cert/${domain}/fullchain.pem" && ( ${installRc} -eq 0 || ${installWroteFiles} -eq 1 ) ]]; then
|
||||||
LOGI "Installing certificate succeeded, enabling auto renew..."
|
LOGI "Installing certificate succeeded, enabling auto renew..."
|
||||||
else
|
else
|
||||||
LOGE "Installing certificate failed, exiting."
|
LOGE "Installing certificate failed, exiting."
|
||||||
rm -rf ~/.acme.sh/${domain}
|
if [[ ${cert_exists} -eq 0 ]]; then
|
||||||
|
rm -rf ~/.acme.sh/${domain}
|
||||||
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue