From 003181333cb6d1984df45021ddbd4afbfcbd4f68 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sun, 7 Jan 2024 22:37:58 +0100 Subject: [PATCH] feat: Add webbased VNC viewer (#306) --- Dockerfile | 5 ++++- src/entry.sh | 5 +++++ src/install.sh | 20 ++++++++++---------- src/network.sh | 3 ++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index bdb4e95..2cb4b55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,18 +2,21 @@ FROM debian:trixie-slim ARG DEBCONF_NOWARNINGS="yes" ARG DEBIAN_FRONTEND noninteractive +ARG DEBCONF_NONINTERACTIVE_SEEN true RUN apt-get update \ && apt-get --no-install-recommends -y install \ tini \ wget \ ovmf \ + novnc \ procps \ iptables \ iproute2 \ dnsmasq \ net-tools \ qemu-utils \ + websockify \ ca-certificates \ netcat-openbsd \ qemu-system-x86 \ @@ -24,7 +27,7 @@ COPY ./src /run/ RUN chmod +x /run/*.sh VOLUME /storage -EXPOSE 22 5900 +EXPOSE 22 5900 8006 ENV CPU_CORES "1" ENV RAM_SIZE "1G" diff --git a/src/entry.sh b/src/entry.sh index 4160422..538e57f 100755 --- a/src/entry.sh +++ b/src/entry.sh @@ -16,6 +16,11 @@ cd /run . config.sh # Configure arguments trap - ERR + +if [[ "${DISPLAY,,}" == "vnc" ]]; then + websockify -D --web /usr/share/novnc/ 8006 localhost:5900 +fi + info "Booting image using $VERS..." [[ "$DEBUG" == [Yy1]* ]] && set -x diff --git a/src/install.sh b/src/install.sh index bb2ff90..d124c42 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1,16 +1,6 @@ #!/usr/bin/env bash set -Eeuo pipefail -BASE="boot.img" -[ -f "$STORAGE/$BASE" ] && return 0 - -if [ -z "$BOOT" ]; then - error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64 -fi - -BASE=$(basename "$BOOT") -[ -f "$STORAGE/$BASE" ] && return 0 - # Check if running with interactive TTY or redirected to docker log if [ -t 1 ]; then PROGRESS="--progress=bar:noscroll" @@ -34,6 +24,16 @@ if [[ "${BOOT_MODE,,}" == "windows" ]]; then fi fi +BASE="boot.img" +[ -f "$STORAGE/$BASE" ] && return 0 + +if [ -z "$BOOT" ]; then + error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64 +fi + +BASE=$(basename "$BOOT") +[ -f "$STORAGE/$BASE" ] && return 0 + TMP="$STORAGE/${BASE%.*}.tmp" rm -f "$TMP" diff --git a/src/network.sh b/src/network.sh index 9396920..c5c9727 100644 --- a/src/network.sh +++ b/src/network.sh @@ -95,9 +95,10 @@ getPorts() { local list=$1 local vnc="5900" + local novnc="8006" if [[ "${DISPLAY,,}" == "vnc" ]] && [[ "$list" != *"$vnc"* ]]; then - [ -z "$list" ] && list="$vnc" || list="$list,$vnc" + [ -z "$list" ] && list="$vnc,$novnc" || list="$list,$vnc,$novnc" fi [ -z "$list" ] && return 0