From e4c30ebca5003b9bbdba0ae363e0f8645f94890b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 7 Jan 2026 17:53:40 +0100 Subject: [PATCH] ip --- vm/unifi-os-server-vm.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/vm/unifi-os-server-vm.sh b/vm/unifi-os-server-vm.sh index c3ed0369f..33aa1619b 100644 --- a/vm/unifi-os-server-vm.sh +++ b/vm/unifi-os-server-vm.sh @@ -787,11 +787,20 @@ if [ "$START_VM" == "yes" ]; then sleep 300 msg_ok "UniFi OS Server installed" - # Step 4: Get IP address for final message + # Step 4: Start Guest Agent for IP detection + msg_info "Starting QEMU Guest Agent" + send_line_to_vm "systemctl start qemu-guest-agent" + sleep 3 + msg_ok "Guest Agent started" + + # Logout from VM console + send_line_to_vm "exit" + sleep 2 + + # Get IP from outside via Guest Agent msg_info "Detecting VM IP address" - sleep 5 VM_IP="" - for i in {1..30}; do + for i in {1..15}; do VM_IP=$(qm guest cmd $VMID network-get-interfaces 2>/dev/null | jq -r '.[] | select(.name != "lo") | .["ip-addresses"][]? | select(.["ip-address-type"] == "ipv4") | .["ip-address"]' 2>/dev/null | head -1 || echo "") if [ -n "$VM_IP" ]; then break @@ -802,8 +811,7 @@ if [ "$START_VM" == "yes" ]; then if [ -n "$VM_IP" ]; then msg_ok "VM IP Address: ${VM_IP}" else - msg_info "IP address will be shown in VM console" - send_line_to_vm "ip -4 addr show | grep inet | grep -v 127.0.0.1" + msg_info "Could not detect IP - check VM console" fi echo ""