diff --git a/run/server.sh b/run/server.sh
index 045d3d5..c592914 100644
--- a/run/server.sh
+++ b/run/server.sh
@@ -33,33 +33,36 @@ if [[ "$2" != "/"* ]]; then
HTML=$(html "$BODY")
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 $!
+
+ exit
+
+fi
+
+if [[ "$2" != "/run/ip.sh" ]]; then
+
+ cp "$2" "$TMP_FILE"
else
- if [[ "$2" != "/run/ip.sh" ]]; then
+ BODY="The location of DSM is http://\${IP}:\${PORT}"
+ WAIT="Please wait while discovering IP..."
- cp "$2" "$TMP_FILE"
+ HTML=$(html "xxx")
- else
-
- BODY="The location of DSM is http://\${IP}:\${PORT}"
- WAIT="Please wait while discovering IP..."
-
- HTML=$(html "xxx")
-
- { echo "#!/bin/bash"
- 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#*eth0}; rest=\${rest#*ip}; rest=\${rest#*:}; rest=\${rest#*\\\"}; IP=\${rest%%\\\"*}"
- echo "HTML=\"$HTML\"; [ -z \"\${IP}\" ] && BODY=\"$WAIT\" || BODY=\"$BODY\"; HTML=\${HTML/xxx/\$BODY}"
- echo "printf '%b' \"HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\""
- } > "$TMP_FILE"
-
- fi
-
- chmod +x "$TMP_FILE"
- socat TCP4-LISTEN:"${1:-5000}",reuseaddr,fork,crlf SYSTEM:"$TMP_FILE" 2> /dev/null & wait $!
+ { echo "#!/bin/bash"
+ 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#*eth0}; rest=\${rest#*ip}; rest=\${rest#*:}; rest=\${rest#*\\\"}; IP=\${rest%%\\\"*}"
+ echo "HTML=\"$HTML\"; [ -z \"\${IP}\" ] && BODY=\"$WAIT\" || BODY=\"$BODY\"; HTML=\${HTML/xxx/\$BODY}"
+ echo "printf '%b' \"HTTP/1.1 200 OK\\nContent-Length: \${#HTML}\\nConnection: close\\n\\n\$HTML\""
+ } > "$TMP_FILE"
fi
+
+chmod +x "$TMP_FILE"
+
+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 $!