mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 21:40:01 +08:00
Page generation
Page generation
This commit is contained in:
commit
b19da263bb
@ -1,14 +1,9 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
# Display wait message on port 5000
|
# Display wait message
|
||||||
HTML="Please wait while Virtual DSM is installing...<script>\
|
/run/server.sh 80 install &
|
||||||
setTimeout(() => { document.location.reload(); }, 9999);</script>"
|
/run/server.sh 5000 install &
|
||||||
|
|
||||||
{ pkill -f server.sh || true; } 2>/dev/null
|
|
||||||
|
|
||||||
/run/server.sh 80 "${HTML}" &
|
|
||||||
/run/server.sh 5000 "${HTML}" &
|
|
||||||
|
|
||||||
# Download the required files from the Synology website
|
# Download the required files from the Synology website
|
||||||
DL="https://global.synologydownload.com/download/DSM"
|
DL="https://global.synologydownload.com/download/DSM"
|
||||||
|
@ -11,9 +11,29 @@ stop() {
|
|||||||
|
|
||||||
trap 'stop' EXIT SIGINT SIGTERM SIGHUP
|
trap 'stop' EXIT SIGINT SIGTERM SIGHUP
|
||||||
|
|
||||||
if [[ "$2" == "/"* ]]; then
|
if [[ "$2" != "/"* ]]; then
|
||||||
|
|
||||||
if [[ "$2" == "/run/ip.sh" ]]; then
|
BODY="$2"
|
||||||
|
|
||||||
|
if [[ "$BODY" == "install" ]]; then
|
||||||
|
|
||||||
|
BODY="Please wait while Virtual DSM is installing...<script>setTimeout(() => { document.location.reload(); }, 9999);</script>"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
HTML="<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE><STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,\
|
||||||
|
Arial,sans-serif; } a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD><BODY><BR><BR><H1><CENTER>$BODY</CENTER></H1></BODY></HTML>"
|
||||||
|
|
||||||
|
echo -en "HTTP/1.1 200 OK\nContent-Length: ${#HTML}\nConnection: close\n\n$HTML" > "$TMP_FILE"
|
||||||
|
socat TCP4-LISTEN:"${1:-5000}",reuseaddr,fork,crlf SYSTEM:"cat ${TMP_FILE}" 2> /dev/null & wait $!
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
if [[ "$2" != "/run/ip.sh" ]]; then
|
||||||
|
|
||||||
|
cp "$2" "$TMP_FILE"
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
{ echo "#!/bin/bash"
|
{ echo "#!/bin/bash"
|
||||||
echo "INFO=\$(curl -s -m 5 -S http://127.0.0.1:2210/read?command=10 2>/dev/null)"
|
echo "INFO=\$(curl -s -m 5 -S http://127.0.0.1:2210/read?command=10 2>/dev/null)"
|
||||||
@ -26,21 +46,9 @@ if [[ "$2" == "/"* ]]; then
|
|||||||
echo "echo -e \"\HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\""
|
echo "echo -e \"\HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\""
|
||||||
} > "$TMP_FILE"
|
} > "$TMP_FILE"
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cp "$2" "$TMP_FILE"
|
|
||||||
|
|
||||||
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 $!
|
socat TCP4-LISTEN:"${1:-5000}",reuseaddr,fork,crlf SYSTEM:"$TMP_FILE" 2> /dev/null & wait $!
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
HTML="<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE><STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,\
|
|
||||||
Arial,sans-serif; } a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD><BODY><BR><BR><H1><CENTER>$2</CENTER></H1></BODY></HTML>"
|
|
||||||
|
|
||||||
echo -en "HTTP/1.1 200 OK\nContent-Length: ${#HTML}\nConnection: close\n\n$HTML" > "$TMP_FILE"
|
|
||||||
socat TCP4-LISTEN:"${1:-5000}",reuseaddr,fork,crlf SYSTEM:"cat ${TMP_FILE}" 2> /dev/null & wait $!
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user