Webserver updates

This commit is contained in:
Kroese 2023-04-20 16:23:57 +02:00 committed by GitHub
commit 5a372bc98e
3 changed files with 21 additions and 5 deletions

View File

@ -2,7 +2,7 @@
set -eu
# Display wait message on port 5000
/run/server.sh 5000 > /dev/null &
/run/server.sh 5000 "Please wait while Virtual DSM is installing..." > /dev/null &
DL="https://global.synologydownload.com/download/DSM"

View File

@ -179,6 +179,9 @@ else
# Configuration for DHCP IP
configureDHCP
# Display the received IP on port 5000
/run/server.sh 5000 "The location of DSM is http://${DHCP_IP}:5000" > /dev/null &
fi
NET_OPTS="${NET_OPTS} -device virtio-net-pci,romfile=,netdev=hostnet0,mac=${VM_NET_MAC},id=net0"

View File

@ -1,10 +1,23 @@
#!/usr/bin/env bash
set -eu
trap exit SIGINT SIGTERM
HTML="<HTML><BODY><H1><CENTER>Please wait while Virtual DSM is installing...</CENTER></H1></BODY></HTML>"
RESPONSE="HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n$HTML\r\n"
# Close any previous instances
script_name=${BASH_SOURCE[0]}
while { echo -en "$RESPONSE"; } | nc -lN "${1:-8080}"; do
echo "================================================"
for pid in $(pidof -x $script_name); do
if [ $pid != $$ ]; then
kill -15 $pid 2> /dev/null
wait $pid 2> /dev/null
fi
done
# Serve the page
HTML="<HTML><HEAD><STYLE>body { color: white; background-color: #00BFFF; } </STYLE></HEAD><BODY><BR><BR><H1><CENTER>$2</CENTER></H1></BODY></HTML>"
LENGTH="${#HTML}"
RESPONSE="HTTP/1.1 200 OK\nContent-Length: ${LENGTH}\nConnection: close\n\n$HTML\n\n"
while true; do
echo -en "$RESPONSE" | nc -N -lp "${1:-8080}";
done