qemu-arm/src/display.sh
2024-01-10 17:40:44 +01:00

47 lines
1.1 KiB
Bash

#!/usr/bin/env bash
set -Eeuo pipefail
# Docker environment variables
: ${GPU:='N'} # GPU passthrough
: ${DISPLAY:='none'} # Display type
case "${DISPLAY,,}" in
vnc)
DISPLAY_OPTS="-display vnc=:0 -vga virtio"
;;
web)
addPackage "novnc" "web-based VNC client"
ln -sfn /usr/share/novnc/vnc_lite.html /usr/share/novnc/index.html
DISPLAY_OPTS="-display vnc=:0 -vga virtio"
;;
*)
DISPLAY_OPTS="-display $DISPLAY -vga none"
;;
esac
if [[ "$GPU" != [Yy1]* ]] || [[ "$ARCH" != "amd64" ]]; then
return 0
fi
DISPLAY_OPTS="-display egl-headless,rendernode=/dev/dri/renderD128 -vga virtio"
[[ "${DISPLAY,,}" == "vnc" || "${DISPLAY,,}" == "web" ]] && DISPLAY_OPTS="$DISPLAY_OPTS -vnc :0"
[ ! -d /dev/dri ] && mkdir -m 755 /dev/dri
if [ ! -c /dev/dri/card0 ]; then
if mknod /dev/dri/card0 c 226 0; then
chmod 666 /dev/dri/card0
fi
fi
if [ ! -c /dev/dri/renderD128 ]; then
if mknod /dev/dri/renderD128 c 226 128; then
chmod 666 /dev/dri/renderD128
fi
fi
addPackage "xserver-xorg-video-intel" "Intel GPU drivers"
addPackage "qemu-system-modules-opengl" "OpenGL module"
return 0