feat: Display wait message (#338)

This commit is contained in:
Kroese 2024-01-16 19:05:48 +01:00 committed by GitHub
parent 17157bd078
commit d1df90a9f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 0 deletions

View file

@ -9,6 +9,7 @@ RUN apt-get update \
tini \ tini \
wget \ wget \
ovmf \ ovmf \
socat \
procps \ procps \
iptables \ iptables \
iproute2 \ iproute2 \

View file

@ -1,6 +1,10 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -Eeuo pipefail 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 # Check if running with interactive TTY or redirected to docker log
if [ -t 1 ]; then if [ -t 1 ]; then
PROGRESS="--progress=bar:noscroll" PROGRESS="--progress=bar:noscroll"

View file

@ -202,6 +202,8 @@ closeNetwork() {
if [[ "$DHCP" == [Yy1]* ]]; then if [[ "$DHCP" == [Yy1]* ]]; then
fKill "server.sh"
ip link set "$VM_NET_TAP" down || true ip link set "$VM_NET_TAP" down || true
ip link delete "$VM_NET_TAP" || true ip link delete "$VM_NET_TAP" || true
@ -253,6 +255,8 @@ getInfo() {
# Configure Network # Configure Network
# ###################################### # ######################################
fKill "server.sh"
if [ ! -c /dev/vhost-net ]; then if [ ! -c /dev/vhost-net ]; then
if mknod /dev/vhost-net c 10 238; then if mknod /dev/vhost-net c 10 238; then
chmod 660 /dev/vhost-net chmod 660 /dev/vhost-net

32
src/server.sh Normal file
View file

@ -0,0 +1,32 @@
#!/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