Fixed command not found

main
Anthony 2025-03-22 01:37:21 +08:00
parent a81cac18bf
commit 798f36ab4b
2 changed files with 44 additions and 27 deletions

View File

@ -588,19 +588,24 @@ actions:
type: info
message: "${response.out}"
remove_ssl_cert:
- if: ${settings.confirm} != true
return:
type: error
message: "Confirmation checkbox must be checked to proceed with certificate removal."
- cmd[cp]:
user: root
commands:
- >
if [[ "${settings.confirm}" == "true" ]]; then
bash /home/litespeed/mbmanager/ssl-manager/ssl_manager.sh --domain="${settings.domain}" --remove-cert=yes --confirm=yes
else
echo "Confirmation checkbox must be checked to proceed with certificate removal."
exit 1
fi
- return:
type: info
message: "${response.out}"
- bash /home/litespeed/mbmanager/ssl-manager/ssl_manager.sh --domain="${settings.domain}" --remove-cert=yes --confirm=yes
- if: ${response.exitcode} == 0
return:
type: success
message: "SSL certificate for '${settings.domain}' has been successfully removed."
- else:
return:
type: error
message: "Failed to remove SSL certificate: ${response.out}"
responses:
enableSuccess:

View File

@ -764,11 +764,15 @@ remove_ssl_certificate() {
return 1
fi
# Remove the HTTPS-domain listener section
# Remove the HTTPS-domain listener section - find both <name> and <n> tags to handle inconsistencies
grep -n -E "<(name|n)>HTTPS-${domain}</(name|n)>" "$config_file" > /dev/null || {
log "No listener found for domain ${domain}, continuing with certificate removal only.";
}
awk -v domain="$domain" '
BEGIN { skip = 0; }
/<name>HTTPS-'"$domain"'<\/name>/,/<\/listener>/ {
if ($0 ~ /<name>HTTPS-'"$domain"'<\/name>/) {
/HTTPS-'"$domain"'/,/<\/listener>/ {
if ($0 ~ /HTTPS-'"$domain"'/) {
skip = 1;
print "<!-- Listener for " domain " removed by ssl_manager.sh -->";
}
@ -785,21 +789,29 @@ remove_ssl_certificate() {
log "Removing domain-specific virtual host if it exists..."
local vhost_name="${domain//[.]/_}"
awk -v vhost="$vhost_name" '
BEGIN { skip = 0; }
/<name>'"$vhost"'<\/name>/,/<\/virtualHost>/ {
if ($0 ~ /<name>'"$vhost"'<\/name>/) {
skip = 1;
print "<!-- VirtualHost for " vhost " removed by ssl_manager.sh -->";
}
if ($0 ~ /<\/virtualHost>/ && skip == 1) {
skip = 0;
next;
}
if (skip) next;
# Check if virtualhost exists
grep -n -E "<(name|n)>${vhost_name}</(name|n)>" "$config_file" > /dev/null || {
log "No virtual host found for ${vhost_name}, skipping this step.";
cp "$temp_file" "${temp_file}.new";
}
{ if (!skip) print; }
' "$temp_file" > "${temp_file}.new"
if [ ! -f "${temp_file}.new" ]; then
awk -v vhost="$vhost_name" '
BEGIN { skip = 0; }
/'"$vhost"'/,/<\/virtualHost>/ {
if ($0 ~ /'"$vhost"'/) {
skip = 1;
print "<!-- VirtualHost for " vhost " removed by ssl_manager.sh -->";
}
if ($0 ~ /<\/virtualHost>/ && skip == 1) {
skip = 0;
next;
}
if (skip) next;
}
{ if (!skip) print; }
' "$temp_file" > "${temp_file}.new"
fi
# 4. Remove any domain mappings from shared listeners
log "Removing domain mappings from shared listeners..."