Display IP info

This commit is contained in:
Kroese 2023-05-08 21:18:38 +02:00 committed by GitHub
parent b797e72b28
commit d45fea5eba

View File

@ -227,8 +227,25 @@ if [[ "${DHCP}" == [Yy1]* ]]; then
configureDHCP
pkill -f server.sh || true
/run/server.sh 80 ipinfo > /dev/null &
/run/server.sh 5000 ipinfo > /dev/null &
SH_SCRIPT="/run/ipinfo.sh"
{ echo "#!/bin/bash"
echo "INFO=\$(curl -s -m 5 -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 "BODY=\"The location of DSM is <a href=\"http://\${IP}:\${PORT}\">http://\${IP}:\${PORT}</a><script>\\"
echo "setTimeout(function(){ window.location.assign('http://\${IP}:\${PORT}'); }, 3000);</script>\""
echo "HTML=\"<!DOCTYPE html><HTML><HEAD><TITLE>VirtualDSM</TITLE><STYLE>body { color: white; background-color: #125bdb; font-family: Verdana,\\"
echo "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 "LENGTH=\"\${#HTML}\"; RESPONSE=\"HTTP/1.1 200 OK\\nContent-Length: \${LENGTH}\\nConnection: close\\n\\n\$HTML\\n\\n\""
echo "echo -e \"\$RESPONSE\""
} > "$SH_SCRIPT"
chmod +x "$SH_SCRIPT"
/run/server.sh 80 "$SH_SCRIPT" > /dev/null &
/run/server.sh 5000 "$SH_SCRIPT" > /dev/null &
else