Commit 5c9edd5f authored by Vitaly Lipatov's avatar Vitaly Lipatov

pve: add pve-destroy.sh to delete VM/CT with confirmation

Refuses to delete a running resource; prints type/VMID/name/node/pool and requires the operator to retype the VM name to confirm. Uses --purge to clean up backups and references. Co-Authored-By: 's avatarClaude Opus 4.7 (1M context) <noreply@anthropic.com>
parent 5e27326e
#!/bin/sh
# Delete VM or CT with confirmation
# Usage: pve-destroy.sh VMID
set -e
MYDIR=$(dirname "$0")
. "$MYDIR/functions"
VMID="$1"
if [ -z "$VMID" ] ; then
echo "Usage: $(basename "$0") VMID" >&2
echo "Delete a VM or CT from the PVE cluster (with confirmation)." >&2
exit 1
fi
resolve_vmid "$VMID"
mgr=$(vm_mgr)
if [ "$RES_STATUS" = "running" ] ; then
fatal "$RES_TYPE $VMID ($RES_NAME) is running — stop it first"
fi
echo ""
echo "About to destroy:"
echo " Type: $RES_TYPE"
echo " VMID: $VMID"
echo " Name: $RES_NAME"
echo " Node: $RES_NODE"
echo " Pool: $RES_POOL"
echo ""
printf "Type VM name '%s' to confirm deletion: " "$RES_NAME"
read confirm
if [ "$confirm" != "$RES_NAME" ] ; then
log "Confirmation failed — aborting."
exit 1
fi
log "Destroying $RES_TYPE $VMID ($RES_NAME) on $RES_NODE ..."
vm_cmd "$mgr" destroy "$VMID" --purge
log "Destroyed."
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment