From 05db1f23403582a54359e9c33b3d0475a37192da Mon Sep 17 00:00:00 2001 From: shuki Date: Thu, 5 Mar 2026 03:36:28 +0200 Subject: [PATCH] Fix restore: use whmapi1 removeacct instead of /scripts/removeacct The /scripts/removeacct script was failing with "You do not have permission to remove that account" even when running as root. Switch to whmapi1 removeacct which uses the WHM API with proper root authentication context. Also check the whmapi1 result field since whmapi1 returns exit code 0 even on logical failures. Co-Authored-By: Claude Opus 4.6 --- lib/restore.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/restore.sh b/lib/restore.sh index 5add19e..5c94a36 100644 --- a/lib/restore.sh +++ b/lib/restore.sh @@ -132,13 +132,21 @@ restore_full_account() { if [[ "$terminate" == "true" ]] && account_exists "$user"; then log_info "Terminating existing account $user before restore..." local removeacct_output - if ! removeacct_output=$(/scripts/removeacct "$user" --force 2>&1); then + if ! removeacct_output=$(whmapi1 removeacct user="$user" 2>&1); then log_error "Failed to terminate account $user" log_debug "removeacct output: $removeacct_output" rm -rf "$restore_dir" return 1 fi log_debug "removeacct output: $removeacct_output" + # Check whmapi1 result field for failure + if echo "$removeacct_output" | grep -q 'result: 0'; then + local reason + reason=$(echo "$removeacct_output" | grep 'reason:' | sed 's/.*reason: //') + log_error "Failed to terminate account $user: $reason" + rm -rf "$restore_dir" + return 1 + fi fi # Run restorepkg (--force to merge into existing account if present)