From 7a16665ce8ebccd0e2d7273a54dc02a515a81741 Mon Sep 17 00:00:00 2001 From: Anthony Date: Tue, 25 Mar 2025 21:15:42 +0800 Subject: [PATCH] Fix Typo --- mbadmin.jps | 64 ++++++++++++++++++++++------------------------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/mbadmin.jps b/mbadmin.jps index f17c525..f9849af 100644 --- a/mbadmin.jps +++ b/mbadmin.jps @@ -143,6 +143,17 @@ menu: action: remove_ssl_cert settings: sslRemoveConfig successText: "${response.out}" + - confirmText: Are you sure you want to clean up certificate references? + loadingText: Cleaning certificate references... + caption: Clean Certificate References + action: clean_cert_references + settings: cleanCertConfig + successText: "Certificate references cleaned successfully for ${settings.domain}" + - confirmText: Are you sure you want to diagnose LiteSpeed configuration? + loadingText: Analyzing configuration... + caption: Diagnose LiteSpeed Config + action: diagnose_litespeed_config + successText: "${response.out}" settings: checkDomainConfig: @@ -269,6 +280,13 @@ settings: type: text caption: Comma-separated Domains required: true + cleanCertConfig: + submitUnchanged: true + fields: + - name: domain + type: text + caption: Domain Name + required: true actions: dynamic_wp_cli: @@ -630,60 +648,30 @@ actions: cp "${CONF_FILE}" "${BACKUP_FILE}" echo "Created backup at ${BACKUP_FILE}" - # Create temp file for processing + # Clean up process TEMP_FILE=$(mktemp) - - # Clean up certificate references - echo "Cleaning up certificate references for ${DOMAIN}..." - - # Use awk with proper quoting and domain variable handling awk -v domain="${DOMAIN}" ' BEGIN { in_listener = 0; is_shared = 0; } - - // { - in_listener = 1; - print; - next; - } - + // { in_listener = 1; print; next; } in_listener && (/HTTPS<\/name>/ || /HTTPS-ipv6<\/name>/) { - is_shared = 1; - print; - next; + is_shared = 1; print; next; } - in_listener && is_shared && /.*live\/'"${DOMAIN}"'\/.*<\/keyFile>/ { - print " /var/www/conf/default.key"; - next; + print " /var/www/conf/default.key"; next; } - in_listener && is_shared && /.*live\/'"${DOMAIN}"'\/.*<\/certFile>/ { - print " /var/www/conf/default.crt"; - next; + print " /var/www/conf/default.crt"; next; } - - /<\/listener>/ { - in_listener = 0; - is_shared = 0; - print; - next; - } - + /<\/listener>/ { in_listener = 0; is_shared = 0; print; next; } { print; } ' "${CONF_FILE}" > "${TEMP_FILE}" - # Verify the file is valid - if grep -q "" "${TEMP_FILE}" && grep -q "" "${TEMP_FILE}"; then - # Apply changes + if grep -q "" "${TEMP_FILE}"; then cat "${TEMP_FILE}" > "${CONF_FILE}" rm -f "${TEMP_FILE}" - echo "Certificate references cleaned up successfully." - - # Restart LiteSpeed - echo "Restarting LiteSpeed..." systemctl restart lsws else - echo "ERROR: Generated config is invalid. Keeping original configuration." + echo "ERROR: Invalid config generated" rm -f "${TEMP_FILE}" exit 1 fi