mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-02-24 13:30:02 +08:00
IP Discovery
This commit is contained in:
parent
ff0b77873c
commit
17c1ea794f
@ -14,8 +14,8 @@ trap 'stop' EXIT SIGINT SIGTERM SIGHUP
|
|||||||
html()
|
html()
|
||||||
{
|
{
|
||||||
local h="<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE>"
|
local h="<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE>"
|
||||||
h="${h} <STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,Arial,sans-serif; }"
|
h="${h} <STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,"
|
||||||
h="${h} a, a:hover, a:active, a:visited { color: white; }</STYLE></HEAD>"
|
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>"
|
h="${h}<BODY><BR><BR><H1><CENTER>$1</CENTER></H1></BODY></HTML>"
|
||||||
|
|
||||||
echo "$h"
|
echo "$h"
|
||||||
@ -26,7 +26,8 @@ if [[ "$2" != "/"* ]]; then
|
|||||||
BODY="$2"
|
BODY="$2"
|
||||||
|
|
||||||
if [[ "$BODY" == "install" ]]; then
|
if [[ "$BODY" == "install" ]]; then
|
||||||
BODY="Please wait while Virtual DSM is installing...<script>setTimeout(() => { document.location.reload(); }, 9999);</script>"
|
BODY="Please wait while Virtual DSM is being installed..."
|
||||||
|
BODY="$BODY<script>setTimeout(() => { document.location.reload(); }, 9999);</script>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HTML=$(html "$BODY")
|
HTML=$(html "$BODY")
|
||||||
@ -44,14 +45,15 @@ else
|
|||||||
|
|
||||||
BODY="The location of DSM is <a href='http://\${IP}:\${PORT}'>http://\${IP}:\${PORT}</a><script>"
|
BODY="The location of DSM is <a href='http://\${IP}:\${PORT}'>http://\${IP}:\${PORT}</a><script>"
|
||||||
BODY="${BODY}setTimeout(function(){ window.location.assign('http://\${IP}:\${PORT}'); }, 3000);</script>"
|
BODY="${BODY}setTimeout(function(){ window.location.assign('http://\${IP}:\${PORT}'); }, 3000);</script>"
|
||||||
|
WAIT="Please wait while discovering IP...<script>setTimeout(() => { document.location.reload(); }, 4999);</script>"
|
||||||
|
|
||||||
HTML=$(html "xxx")
|
HTML=$(html "xxx")
|
||||||
|
|
||||||
{ 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 2 -S http://127.0.0.1:2210/read?command=10 2>/dev/null)"
|
||||||
echo "rest=\${INFO#*http_port}; rest=\${rest#*:}; rest=\${rest%%,*}; PORT=\${rest%%\\\"*}"
|
echo "rest=\${INFO#*http_port}; rest=\${rest#*:}; rest=\${rest%%,*}; PORT=\${rest%%\\\"*}"
|
||||||
echo "rest=\${INFO#*eth0}; rest=\${rest#*ip}; rest=\${rest#*:}; rest=\${rest#*\\\"}; IP=\${rest%%\\\"*}"
|
echo "rest=\${INFO#*eth0}; rest=\${rest#*ip}; rest=\${rest#*:}; rest=\${rest#*\\\"}; IP=\${rest%%\\\"*}"
|
||||||
echo "HTML=\"$HTML\"; BODY=\"$BODY\"; HTML=\${HTML/xxx/\$BODY}"
|
echo "HTML=\"$HTML\"; [ -z \"\${IP}\" ] && BODY=\"$BODY\" || BODY=\"$WAIT\"; HTML=\${HTML/xxx/\$BODY}"
|
||||||
echo "printf '%b' \"HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\""
|
echo "printf '%b' \"HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\""
|
||||||
} > "$TMP_FILE"
|
} > "$TMP_FILE"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user