Unverified Commit d1df90a9 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

feat: Display wait message (#338)

parent 17157bd0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ RUN apt-get update \
 	tini \
	wget \
        ovmf \
	socat \
	procps \
	iptables \
	iproute2 \
+4 −0
Original line number Diff line number Diff line
#!/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"
+4 −0
Original line number Diff line number Diff line
@@ -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

src/server.sh

0 → 100644
+32 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
set -eu

TMP_FILE=$(mktemp -q /dev/shm/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="<!DOCTYPE html><HTML><HEAD><TITLE>$2</TITLE>"
    h="$h<STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,"
    h="$h Arial,sans-serif; } a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD>"
    h="$h<BODY><BR><BR><H1><CENTER>$1</CENTER></H1></BODY></HTML>"

    echo "$h"
}

BODY="$2<script>setTimeout(() => { document.location.reload(); }, 4999);</script>"

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 &
socat TCP4-LISTEN:8006,reuseaddr,fork,crlf SYSTEM:"cat $TMP_FILE" 2> /dev/null & wait $!

exit