Files
proxmox/scripts/remove-containers-106-122.sh

62 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Remove and Purge Containers 106-122
# Run this on the Proxmox host
set -euo pipefail
START_VMID=106
END_VMID=122
echo "========================================="
echo "Remove and Purge Containers 106-122"
echo "========================================="
echo ""
echo "WARNING: This will PERMANENTLY DELETE containers 106 through 122"
echo "All data in these containers will be lost!"
echo ""
read -p "Continue? [y/N]: " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Operation cancelled"
exit 0
fi
echo ""
for vmid in $(seq $START_VMID $END_VMID); do
echo "Processing container $vmid..."
# Check if container exists
if ! pct list 2>/dev/null | grep -q "^\s*$vmid\s"; then
echo "⚠ Container $vmid does not exist, skipping"
continue
fi
# Get container status
status=$(pct status "$vmid" 2>/dev/null | awk '{print $2}' || echo "unknown")
echo " Container $vmid status: $status"
# Stop container if running
if [[ "$status" == "running" ]]; then
echo " Stopping container $vmid..."
pct stop "$vmid" --timeout 30 2>/dev/null || {
echo " Force stopping container $vmid..."
pct stop "$vmid" --skiplock 2>/dev/null || true
}
sleep 2
fi
# Remove and purge container
echo " Removing and purging container $vmid..."
if pct destroy "$vmid" --purge 2>/dev/null; then
echo " ✓ Container $vmid removed and purged"
else
echo " ✗ Failed to remove container $vmid"
fi
done
echo ""
echo "========================================="
echo "Container removal completed!"
echo "========================================="