-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgo-win11.sh.example
More file actions
50 lines (43 loc) · 1.4 KB
/
go-win11.sh.example
File metadata and controls
50 lines (43 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# -----------------------------------------------------------------------------
# AUTOMATED WINDOWS 11 LAUNCHER
# -----------------------------------------------------------------------------
# 1. Checks if VM is off.
# 2. Boots it using System Daemon.
# 3. Waits for RDP port 3389 to open.
# 4. Launches xfreerdp client.
# -----------------------------------------------------------------------------
# CONFIGURATION - Change accordingly for new machine
VM_NAME="Win11"
VM_IP="192.168.x.x"
RDP_PORT=3389
RDP_CLIENT="/home/$USER/.local/bin/win11"
# Force connection to System Daemon (Bypasses need for .bashrc variables)
VIRSH="virsh -c qemu:///system"
# 1. CHECK STATUS & BOOT
STATE=$($VIRSH domstate $VM_NAME 2>/dev/null)
echo "🔍 Status: $VM_NAME is $STATE"
if [ "$STATE" != "running" ]; then
echo "⚡ Booting $VM_NAME..."
$VIRSH start $VM_NAME
# 2. WAIT FOR RDP SERVICE
echo "⏳ Waiting for RDP connection..."
TIMEOUT=0
# Loop until Netcat (nc) successfully connects to port 3389
while ! nc -z $VM_IP $RDP_PORT; do
sleep 1
TIMEOUT=$((TIMEOUT+1))
if [ $TIMEOUT -ge 90 ]; then
echo "❌ Error: Windows boot timed out (>90s)."
exit 1
fi
echo -n "."
done
echo ""
echo "✅ Windows is ready!"
else
echo "✅ VM is already online."
fi
# 3. LAUNCH CLIENT
echo "🚀 Starting Session..."
$RDP_CLIENT