- server/ profile and build-iso.sh [desktop|server]; make iso-server, make qemu-server, run-qemu.sh --serial; login on tty and ttyS0 - das-server: SSH, chrony, NetworkManager/dhcpcd, Docker with Compose, nftables (closed except SSH, own table), fail2ban reading socklog, sshd without root passwords, Docker log rotation, tools - das-server-install: dialog installer in Ukrainian and English, or unattended with --config; GPT + Btrfs subvolumes, GRUB for UEFI and BIOS, serial console, SSH key with optional keys-only logins - das-install-common: mount-source and postinstall shared with Calamares - dsv: runit service manager (list, enable, disable, start, stop, restart, status, logs) with bash completion, also on the desktop - das-update split into a subpackage without GTK; the window and tray icon move to /usr/libexec/das/das-update-gui - das-snapper-setup enables dbus, which snapper needs - TODO: ISO size review with measured numbers and options Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
86 lines
2.5 KiB
Bash
Executable File
86 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Boots a Das OS ISO in QEMU (KVM when available).
|
|
#
|
|
# Usage: scripts/run-qemu.sh [--bios] [--disk] [--serial] [path/to/image.iso]
|
|
# --bios boot with legacy BIOS instead of UEFI
|
|
# --disk attach out/qemu/disk.qcow2 (20 GB, created on first use) to test installing
|
|
# --serial no window: the serial console in this terminal (server ISO), Ctrl-A X quits
|
|
# Without a path the newest desktop ISO in out/iso is used (server ISO with --serial).
|
|
set -euo pipefail
|
|
|
|
root=$(cd "$(dirname "$0")/.." && pwd)
|
|
state=$root/out/qemu
|
|
firmware=uefi
|
|
disk=false
|
|
serial=false
|
|
iso=""
|
|
|
|
die() {
|
|
echo "run-qemu: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
for arg in "$@"; do
|
|
case $arg in
|
|
--bios) firmware=bios ;;
|
|
--disk) disk=true ;;
|
|
--serial) serial=true ;;
|
|
-h | --help)
|
|
sed -n '2,9s/^# \{0,1\}//p' "$0"
|
|
exit 0
|
|
;;
|
|
-*) die "unknown option: $arg" ;;
|
|
*) iso=$arg ;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z $iso ]]; then
|
|
pattern="dasos-[0-9]*.iso"
|
|
[[ $serial == true ]] && pattern="dasos-server-*.iso"
|
|
iso=$(ls -t "$root"/out/iso/$pattern 2>/dev/null | head -n 1) || true
|
|
fi
|
|
[[ -n $iso && -f $iso ]] || die "no ISO found, run 'make iso' first"
|
|
|
|
args=(
|
|
-machine q35 -smp 4 -m 4096
|
|
-device virtio-net-pci,netdev=net0 -netdev user,id=net0
|
|
-cdrom "$iso" -boot order=d
|
|
)
|
|
if [[ $serial == true ]]; then
|
|
# The guest's ttyS0 and the QEMU monitor share this terminal
|
|
args+=(-nographic -serial mon:stdio)
|
|
else
|
|
args+=(-device virtio-vga -display gtk,zoom-to-fit=on -device qemu-xhci -device usb-tablet)
|
|
fi
|
|
|
|
if [[ -w /dev/kvm ]]; then
|
|
args+=(-accel kvm -cpu host)
|
|
else
|
|
echo "run-qemu: /dev/kvm is not accessible, falling back to slow emulation" >&2
|
|
args+=(-accel tcg -cpu max)
|
|
fi
|
|
|
|
mkdir -p "$state"
|
|
|
|
if [[ $firmware == uefi ]]; then
|
|
code=""
|
|
# Debian/Ubuntu/Mint, then Arch, then Fedora file names
|
|
for candidate in /usr/share/OVMF/OVMF_CODE_4M.fd /usr/share/edk2/x64/OVMF_CODE.4m.fd /usr/share/edk2/ovmf/OVMF_CODE.fd; do
|
|
[[ -f $candidate ]] && code=$candidate && break
|
|
done
|
|
[[ -n $code ]] || die "UEFI firmware (OVMF) not found, install the ovmf package or use --bios"
|
|
vars_template=$(dirname "$code")/$(basename "$code" | sed 's/CODE/VARS/')
|
|
[[ -f $state/OVMF_VARS.fd ]] || cp "$vars_template" "$state/OVMF_VARS.fd"
|
|
args+=(
|
|
-drive "if=pflash,format=raw,readonly=on,file=$code"
|
|
-drive "if=pflash,format=raw,file=$state/OVMF_VARS.fd"
|
|
)
|
|
fi
|
|
|
|
if [[ $disk == true ]]; then
|
|
[[ -f $state/disk.qcow2 ]] || qemu-img create -f qcow2 "$state/disk.qcow2" 20G
|
|
args+=(-drive "file=$state/disk.qcow2,if=virtio,format=qcow2")
|
|
fi
|
|
|
|
exec qemu-system-x86_64 "${args[@]}"
|