Internal webserver

Internal webserver
This commit is contained in:
Kroese 2023-05-11 20:27:33 +02:00 committed by GitHub
commit 6c939ca68d
3 changed files with 26 additions and 25 deletions

View File

@ -2,7 +2,6 @@
set -Eeuo pipefail set -Eeuo pipefail
# Display wait message # Display wait message
/run/server.sh 80 install &
/run/server.sh 5000 install & /run/server.sh 5000 install &
# Download the required files from the Synology website # Download the required files from the Synology website

View File

@ -199,9 +199,8 @@ if [[ "${DHCP}" == [Yy1]* ]]; then
# Configuration for DHCP IP # Configuration for DHCP IP
configureDHCP configureDHCP
# Display IP on port 80 and 5000
{ pkill -f server.sh || true; } 2>/dev/null { pkill -f server.sh || true; } 2>/dev/null
/run/server.sh 80 /run/ip.sh &
/run/server.sh 5000 /run/ip.sh & /run/server.sh 5000 /run/ip.sh &
else else

View File

@ -33,9 +33,12 @@ if [[ "$2" != "/"* ]]; then
HTML=$(html "$BODY") HTML=$(html "$BODY")
printf '%b' "HTTP/1.1 200 OK\nContent-Length: ${#HTML}\nConnection: close\n\n$HTML" > "$TMP_FILE" 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:"${1:-5000}",reuseaddr,fork,crlf SYSTEM:"cat ${TMP_FILE}" 2> /dev/null & wait $! socat TCP4-LISTEN:"${1:-5000}",reuseaddr,fork,crlf SYSTEM:"cat ${TMP_FILE}" 2> /dev/null & wait $!
else exit
fi
if [[ "$2" != "/run/ip.sh" ]]; then if [[ "$2" != "/run/ip.sh" ]]; then
@ -60,6 +63,6 @@ else
fi fi
chmod +x "$TMP_FILE" chmod +x "$TMP_FILE"
socat TCP4-LISTEN:"${1:-5000}",reuseaddr,fork,crlf SYSTEM:"$TMP_FILE" 2> /dev/null & wait $!
fi socat TCP4-LISTEN:80,reuseaddr,fork,crlf SYSTEM:"$TMP_FILE" 2> /dev/null &
socat TCP4-LISTEN:"${1:-5000}",reuseaddr,fork,crlf SYSTEM:"$TMP_FILE" 2> /dev/null & wait $!