#!/bin/bash VM_NAME="particle-os-test" NETWORK_NAME="particle-os-net" echo "🚀 === Particle-OS VM Management Script ===" echo "" case "${1:-status}" in "start") echo "Starting $VM_NAME..." sudo virsh start $VM_NAME ;; "stop") echo "Stopping $VM_NAME..." sudo virsh shutdown $VM_NAME ;; "restart") echo "Restarting $VM_NAME..." sudo virsh reboot $VM_NAME ;; "destroy") echo "Force stopping $VM_NAME..." sudo virsh destroy $VM_NAME ;; "status") echo "VM Status:" sudo virsh list --all | grep $VM_NAME echo "" echo "Network Status:" sudo virsh net-list --all | grep $NETWORK_NAME echo "" echo "VNC Connection:" sudo virsh vncdisplay $VM_NAME 2>/dev/null || echo "VNC not available" ;; "console") echo "Opening console for $VM_NAME..." sudo virsh console $VM_NAME ;; "info") echo "VM Information:" sudo virsh dominfo $VM_NAME echo "" echo "Network Interfaces:" sudo virsh domifaddr $VM_NAME ;; "help"|"-h"|"--help") echo "Usage: $0 [command]" echo "" echo "Commands:" echo " start - Start the VM" echo " stop - Gracefully stop the VM" echo " restart - Restart the VM" echo " destroy - Force stop the VM" echo " status - Show VM and network status (default)" echo " console - Open VM console" echo " info - Show detailed VM information" echo " help - Show this help message" echo "" echo "Examples:" echo " $0 start # Start the VM" echo " $0 status # Check status" echo " $0 console # Open console" ;; *) echo "Unknown command: $1" echo "Use '$0 help' for usage information" exit 1 ;; esac