Fix restore: correct removeacct argument order, add debug output

cPanel's removeacct expects username before flags. Also capture and
log the command output to aid debugging if termination still fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-05 03:33:31 +02:00
parent 6779db023a
commit 3b5488f0d7

View File

@@ -131,11 +131,14 @@ restore_full_account() {
# Terminate existing account if requested # Terminate existing account if requested
if [[ "$terminate" == "true" ]] && account_exists "$user"; then if [[ "$terminate" == "true" ]] && account_exists "$user"; then
log_info "Terminating existing account $user before restore..." log_info "Terminating existing account $user before restore..."
if ! /scripts/removeacct --force "$user"; then local removeacct_output
if ! removeacct_output=$(/scripts/removeacct "$user" --force 2>&1); then
log_error "Failed to terminate account $user" log_error "Failed to terminate account $user"
log_debug "removeacct output: $removeacct_output"
rm -rf "$restore_dir" rm -rf "$restore_dir"
return 1 return 1
fi fi
log_debug "removeacct output: $removeacct_output"
fi fi
# Run restorepkg (--force to merge into existing account if present) # Run restorepkg (--force to merge into existing account if present)