From 414042a45bded2f98c47da4da15b74b932542a34 Mon Sep 17 00:00:00 2001 From: somebodywashere <68244480+somebodywashere@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:58:18 +0300 Subject: [PATCH] Update to regular cert issue --- x-ui.sh | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/x-ui.sh b/x-ui.sh index 87d18262..36a98b23 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -1136,10 +1136,36 @@ ssl_cert_issue() { LOGE "Issuing certificate succeeded, installing certificates..." fi + reloadCmd="x-ui restart" + + LOGI "Default --reloadcmd for ACME is: ${yellow}x-ui restart" + LOGI "This command will run on every certificate issue and renew." + read -p "Would you like to modify --reloadcmd for ACME? (y/n): " setReloadcmd + if [[ "$setReloadcmd" == "y" || "$setReloadcmd" == "Y" ]]; then + echo -e "\n${green}\t1.${plain} Preset: systemctl reload nginx ; x-ui restart" + echo -e "${green}\t2.${plain} Input your own command" + echo -e "${green}\t0.${plain} Keep default reloadcmd" + read -p "Choose an option: " choice + case "$choice" in + 1) + LOGI "Reloadcmd is: systemctl reload nginx ; x-ui restart" + reloadCmd="systemctl reload nginx ; x-ui restart" + ;; + 2) + LOGD "It's recommended to put x-ui restart at the end, so it won't raise an error if other services fails" + read -p "Please enter your reloadcmd (example: systemctl reload nginx ; x-ui restart): " reloadCmd + LOGI "Your reloadcmd is: ${reloadCmd}" + ;; + *) + LOGI "Keep default reloadcmd" + ;; + esac + fi + # install the certificate ~/.acme.sh/acme.sh --installcert -d ${domain} \ --key-file /root/cert/${domain}/privkey.pem \ - --fullchain-file /root/cert/${domain}/fullchain.pem + --fullchain-file /root/cert/${domain}/fullchain.pem --reloadcmd "${reloadCmd}" if [ $? -ne 0 ]; then LOGE "Installing certificate failed, exiting." @@ -1261,17 +1287,18 @@ ssl_cert_issue_CF() { LOGI "This command will run on every certificate issue and renew." read -p "Would you like to modify --reloadcmd for ACME? (y/n): " setReloadcmd if [[ "$setReloadcmd" == "y" || "$setReloadcmd" == "Y" ]]; then - echo -e "\n${green}\t1.${plain} Preset: x-ui restart ; systemctl reload nginx" + echo -e "\n${green}\t1.${plain} Preset: systemctl reload nginx ; x-ui restart" echo -e "${green}\t2.${plain} Input your own command" echo -e "${green}\t0.${plain} Keep default reloadcmd" read -p "Choose an option: " choice case "$choice" in 1) - LOGI "Reloadcmd is: x-ui restart ; systemctl reload nginx" - reloadCmd="x-ui restart ; systemctl reload nginx" + LOGI "Reloadcmd is: systemctl reload nginx ; x-ui restart" + reloadCmd="systemctl reload nginx ; x-ui restart" ;; - 2) - read -p "Please enter your reloadcmd (example: x-ui restart ; systemctl reload nginx): " reloadCmd + 2) + LOGD "It's recommended to put x-ui restart at the end, so it won't raise an error if other services fails" + read -p "Please enter your reloadcmd (example: systemctl reload nginx ; x-ui restart): " reloadCmd LOGI "Your reloadcmd is: ${reloadCmd}" ;; *) @@ -1282,6 +1309,7 @@ ssl_cert_issue_CF() { ~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} \ --key-file ${certPath}/privkey.pem \ --fullchain-file ${certPath}/fullchain.pem --reloadcmd "${reloadCmd}" + if [ $? -ne 0 ]; then LOGE "Certificate installation failed, script exiting..." exit 1