From cbec868c99f4e85f51864d0cb5a6228fa842e751 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Jan 2024 18:46:56 +0100 Subject: [PATCH 1/7] feat: Display wait message --- src/server.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/server.sh diff --git a/src/server.sh b/src/server.sh new file mode 100644 index 00000000..d3db4559 --- /dev/null +++ b/src/server.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +set -eu + +TMP_FILE=$(mktemp -q /tmp/server.XXXXXX) + +stop() { + trap - SIGINT EXIT + { pkill -f socat || true; } 2>/dev/null + [ -f "$TMP_FILE" ] && rm -f "$TMP_FILE" +} + +trap 'stop' EXIT SIGINT SIGTERM SIGHUP + +html() +{ + local h="$2" + h="$h" + h="$h

$1

" + + echo "$h" +} + +BODY="$1" + +HTML=$(html "$BODY" "$2") +printf '%b' "HTTP/1.1 200 OK\nContent-Length: ${#HTML}\nConnection: close\n\n$HTML" > "$TMP_FILE" + +socat TCP4-LISTEN:80,reuseaddr,fork,crlf SYSTEM:"cat $TMP_FILE" 2> /dev/null & +socat TCP4-LISTEN:8006,reuseaddr,fork,crlf SYSTEM:"cat $TMP_FILE" 2> /dev/null & wait $! + +exit From 59b168e885f5b2ee94bf86c9cdf748b5942e5658 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Jan 2024 18:47:51 +0100 Subject: [PATCH 2/7] build: Add socat --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 09ec71f2..c27c58da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,13 @@ FROM debian:trixie-slim ARG DEBCONF_NOWARNINGS="yes" ARG DEBIAN_FRONTEND "noninteractive" ARG DEBCONF_NONINTERACTIVE_SEEN "true" - +BODY="Please wait while the ISO is being downloaded..." RUN apt-get update \ && apt-get --no-install-recommends -y install \ tini \ wget \ ovmf \ + socat \ procps \ iptables \ iproute2 \ From 6585885554c2d09401edf376e823e6b3945d74bc Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Jan 2024 18:52:14 +0100 Subject: [PATCH 3/7] fix: Server parameters --- src/server.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server.sh b/src/server.sh index d3db4559..19dc6446 100644 --- a/src/server.sh +++ b/src/server.sh @@ -21,9 +21,9 @@ html() echo "$h" } -BODY="$1" +BODY="$2" -HTML=$(html "$BODY" "$2") +HTML=$(html "$BODY" "$1") printf '%b' "HTTP/1.1 200 OK\nContent-Length: ${#HTML}\nConnection: close\n\n$HTML" > "$TMP_FILE" socat TCP4-LISTEN:80,reuseaddr,fork,crlf SYSTEM:"cat $TMP_FILE" 2> /dev/null & From 74116148bb380f16cf75cba6a5fa562cf8d0c1cb Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Jan 2024 18:53:55 +0100 Subject: [PATCH 4/7] feat: Display wait message --- src/install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/install.sh b/src/install.sh index d124c42c..d935da83 100644 --- a/src/install.sh +++ b/src/install.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bash set -Eeuo pipefail +# Display wait message +MSG="Please wait while the ISO is being downloaded..." +/run/server.sh "QEMU" "$MSG" & + # Check if running with interactive TTY or redirected to docker log if [ -t 1 ]; then PROGRESS="--progress=bar:noscroll" From 01a9429dd861d4be01cfd7636d95bac5eeea2677 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Jan 2024 18:57:43 +0100 Subject: [PATCH 5/7] feat: Store in shared memory --- src/server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server.sh b/src/server.sh index 19dc6446..2c77fa64 100644 --- a/src/server.sh +++ b/src/server.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -eu -TMP_FILE=$(mktemp -q /tmp/server.XXXXXX) +TMP_FILE=$(mktemp -q /dev/shm/server.XXXXXX) stop() { trap - SIGINT EXIT From f53e8fc29ca65054ce729bc7a8fcf36518a4173b Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Jan 2024 19:01:26 +0100 Subject: [PATCH 6/7] feat: Close server --- src/network.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/network.sh b/src/network.sh index ef6e4dd5..07e6a751 100644 --- a/src/network.sh +++ b/src/network.sh @@ -202,6 +202,8 @@ closeNetwork() { if [[ "$DHCP" == [Yy1]* ]]; then + fKill "server.sh" + ip link set "$VM_NET_TAP" down || true ip link delete "$VM_NET_TAP" || true @@ -253,6 +255,8 @@ getInfo() { # Configure Network # ###################################### +fKill "server.sh" + if [ ! -c /dev/vhost-net ]; then if mknod /dev/vhost-net c 10 238; then chmod 660 /dev/vhost-net From 483d6ed7895ba6bb73ccaefc971d89bf9e2c8536 Mon Sep 17 00:00:00 2001 From: Kroese Date: Tue, 16 Jan 2024 19:02:37 +0100 Subject: [PATCH 7/7] fix: Remove leftover --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c27c58da..2cae9250 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM debian:trixie-slim ARG DEBCONF_NOWARNINGS="yes" ARG DEBIAN_FRONTEND "noninteractive" ARG DEBCONF_NONINTERACTIVE_SEEN "true" -BODY="Please wait while the ISO is being downloaded..." + RUN apt-get update \ && apt-get --no-install-recommends -y install \ tini \