File size: 2,935 Bytes
dcbeeb2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
set -e

# ==============================================================================
# AeroOS VirtualBox Boot Script for macOS (Apple Silicon / Intel)
# ==============================================================================

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
cd "${PROJECT_ROOT}"

VM_NAME="AeroOS-Desktop"
RAW_IMG="${PROJECT_ROOT}/target/x86_64-unknown-none/debug/aero-kernel.bios.img"
VDI_PATH="${PROJECT_ROOT}/target/aero-os.vdi"

echo "============================================================"
echo "          AeroOS VirtualBox Automated Launcher              "
echo "============================================================"

# Check if VBoxManage is installed
if ! command -v VBoxManage &>/dev/null; then
    echo "[!] Error: 'VBoxManage' not found in PATH."
    exit 1
fi

# Always compile latest kernel and generate bootable images
echo "[*] Compiling latest AeroOS kernel..."
cargo build --package aero-kernel --target x86_64-unknown-none
cargo run --package aero-runner -- target/x86_64-unknown-none/debug/aero-kernel

# Clean up any existing VM with the same name
if VBoxManage list vms | grep -q "\"${VM_NAME}\""; then
    echo "[*] Resetting previous VM instance..."
    VBoxManage controlvm "${VM_NAME}" poweroff 2>/dev/null || true
    sleep 2
    VBoxManage unregistervm "${VM_NAME}" --delete 2>/dev/null || true
fi
rm -rf "${HOME}/VirtualBox VMs/${VM_NAME}" 2>/dev/null || true

# Convert raw disk to native VirtualBox VDI
echo "[*] Converting raw image to VirtualBox VDI format..."
rm -f "${VDI_PATH}"
rm -f "${PROJECT_ROOT}/target/aeroos_serial.log"
VBoxManage convertfromraw "${RAW_IMG}" "${VDI_PATH}" --format VDI

echo "[*] Creating VirtualBox VM: ${VM_NAME}..."
VBoxManage createvm --name "${VM_NAME}" --ostype "Other_64" --register

echo "[*] Configuring VM hardware (2048 MB RAM, 128 MB VRAM, PS/2 input)..."
VBoxManage modifyvm "${VM_NAME}" \
    --memory 2048 \
    --vram 128 \
    --cpus 2 \
    --firmware bios \
    --boot1 disk \
    --mouse ps2 \
    --keyboard ps2 \
    --audio-driver none \
    --nic1 nat \
    --nictype1 virtio \
    --uart1 0x3F8 4 \
    --uart-mode1 file "${PROJECT_ROOT}/target/aeroos_serial.log" \
    --uart-type1 16550A

echo "[*] Creating SATA storage controller..."
VBoxManage storagectl "${VM_NAME}" --name "SATA Controller" --add sata --controller IntelAHCI

echo "[*] Attaching AeroOS VDI hard disk (${VDI_PATH})..."
VBoxManage storageattach "${VM_NAME}" \
    --storagectl "SATA Controller" \
    --port 0 \
    --device 0 \
    --type hdd \
    --medium "${VDI_PATH}"

echo "[+] Starting VirtualBox VM: ${VM_NAME}..."
VBoxManage startvm "${VM_NAME}" --type gui

# Focus VirtualBox window on macOS desktop
sleep 1
osascript -e 'tell application "System Events" to set frontmost of first process whose name contains "VirtualBox" to true' 2>/dev/null || true