diff --git a/image/sbin/secubox-kiosk-launcher b/image/sbin/secubox-kiosk-launcher index d4f6af67..2329c4a4 100755 --- a/image/sbin/secubox-kiosk-launcher +++ b/image/sbin/secubox-kiosk-launcher @@ -10,7 +10,7 @@ readonly KIOSK_USER="secubox-kiosk" readonly KIOSK_HOME="/home/secubox-kiosk" readonly LOG_TAG="secubox-kiosk" -log() { echo "[kiosk] $*"; logger -t "$LOG_TAG" "$*" 2>/dev/null || true; } +log() { echo "[kiosk] $*" >&2; logger -t "$LOG_TAG" "$*" 2>/dev/null || true; } err() { echo "[kiosk] ERROR: $*" >&2; logger -t "$LOG_TAG" -p err "$*" 2>/dev/null || true; } # ══════════════════════════════════════════════════════════════════ diff --git a/scripts/run-qemu.sh b/scripts/run-qemu.sh new file mode 100755 index 00000000..7036fcac --- /dev/null +++ b/scripts/run-qemu.sh @@ -0,0 +1,125 @@ +#!/bin/bash +# ═══════════════════════════════════════════════════════════════════ +# SecuBox — QEMU Launcher +# Launch SecuBox Live image in QEMU with proper port forwarding +# ═══════════════════════════════════════════════════════════════════ +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +PROJECT_DIR="$(dirname "$SCRIPT_DIR")" + +# Defaults +IMAGE="${PROJECT_DIR}/output/secubox-live-amd64-bookworm.img" +RAM="4096" +CPUS="4" +SSH_PORT="2222" +HTTPS_PORT="9443" +HTTP_PORT="8080" +DISPLAY_TYPE="gtk" +EFI="yes" + +usage() { + cat </dev/null; then + echo "Error: VBoxManage not found. Install VirtualBox." + exit 1 +fi + +# Validate image +if [[ ! -f "$IMAGE" ]]; then + echo "Error: Image not found: $IMAGE" + exit 1 +fi + +# Convert to VDI if needed +VDI_PATH="${IMAGE%.img}.vdi" +if [[ ! -f "$VDI_PATH" ]] || [[ "$IMAGE" -nt "$VDI_PATH" ]]; then + echo "Converting image to VDI format..." + VBoxManage convertfromraw "$IMAGE" "$VDI_PATH" --format VDI 2>/dev/null || { + # If exists, delete and retry + rm -f "$VDI_PATH" + VBoxManage convertfromraw "$IMAGE" "$VDI_PATH" --format VDI + } +fi + +# Delete existing VM if requested +if [[ "$DELETE_VM" == "yes" ]]; then + echo "Deleting existing VM: $VM_NAME" + VBoxManage unregistervm "$VM_NAME" --delete 2>/dev/null || true +fi + +# Check if VM exists +if VBoxManage showvminfo "$VM_NAME" &>/dev/null; then + echo "VM '$VM_NAME' already exists. Starting..." +else + echo "Creating VM: $VM_NAME" + + # Create VM + VBoxManage createvm --name "$VM_NAME" --ostype "Debian_64" --register + + # Configure VM + VBoxManage modifyvm "$VM_NAME" \ + --memory "$RAM" \ + --cpus "$CPUS" \ + --vram "$VRAM" \ + --graphicscontroller vmsvga \ + --firmware efi64 \ + --boot1 disk \ + --boot2 none \ + --nic1 nat \ + --nictype1 virtio \ + --audio-enabled off \ + --usb-ehci off \ + --usb-xhci on + + # Add storage controller + VBoxManage storagectl "$VM_NAME" --name "SATA" --add sata --controller IntelAhci + + # Attach VDI + VBoxManage storageattach "$VM_NAME" \ + --storagectl "SATA" \ + --port 0 \ + --device 0 \ + --type hdd \ + --medium "$VDI_PATH" + + # Port forwarding + VBoxManage modifyvm "$VM_NAME" \ + --natpf1 "SSH,tcp,,${SSH_PORT},,22" \ + --natpf1 "HTTPS,tcp,,${HTTPS_PORT},,443" \ + --natpf1 "HTTP,tcp,,${HTTP_PORT},,80" + + echo "VM created successfully" +fi + +echo "" +echo "═══════════════════════════════════════════════════════════════" +echo "SecuBox VirtualBox VM" +echo "═══════════════════════════════════════════════════════════════" +echo "VM Name: $VM_NAME" +echo "RAM: ${RAM}MB" +echo "CPUs: $CPUS" +echo "" +echo "Port Forwarding:" +echo " SSH: ssh -p $SSH_PORT root@localhost" +echo " Web: https://localhost:$HTTPS_PORT" +echo "" +echo "Default credentials: root / secubox" +echo "═══════════════════════════════════════════════════════════════" + +# Start VM +echo "Starting VM..." +VBoxManage startvm "$VM_NAME" --type gui