mirror of
https://github.com/DigitalDevices/octonet.git
synced 2023-10-10 13:36:52 +02:00
Added local updateserver selection
This commit is contained in:
parent
f23745b146
commit
162de68b21
79
octoserve/var/www/updateserver.html
Normal file
79
octoserve/var/www/updateserver.html
Normal file
@ -0,0 +1,79 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>OctopusNet</title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css">
|
||||
<script type="text/javascript" src="/menu.js"></script>
|
||||
<!-- Add included scripts here -->
|
||||
<!-- Add page scripts here -->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
var url = "/updateserver.lua";
|
||||
|
||||
xmlhttp.onreadystatechange=function() {
|
||||
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||
myFunction(xmlhttp.responseText);
|
||||
}
|
||||
}
|
||||
|
||||
function myFunction(response) {
|
||||
var p = JSON.parse(response);
|
||||
var el = document.getElementById("userver");
|
||||
el.value = p.UpdateServer;
|
||||
}
|
||||
|
||||
function OnLoad()
|
||||
{
|
||||
xmlhttp.open("GET", url, true);
|
||||
xmlhttp.send();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="OnLoad()">
|
||||
|
||||
<table class="maintable" align="center">
|
||||
<colgroup>
|
||||
<col width="182px"/>
|
||||
<col width="728px"/>
|
||||
</colgroup>
|
||||
<tr><td class="maintd" colspan="2">
|
||||
<a href="http://www.digitaldevices.de"><img src="/BannerDD.jpg" alt="DD" width="910" height="130" /></a>
|
||||
</td></tr>
|
||||
<tr><td class="maintd" colspan="2"> </td></tr>
|
||||
<tr>
|
||||
<td class="maintd"><script type="text/javascript">CreateMenu();</script></td>
|
||||
<td class="content">
|
||||
<div>
|
||||
<!-- Begin Content -->
|
||||
<h3 align="center">Select Local Update Server</h3>
|
||||
<table class="table" align="center">
|
||||
<tr>
|
||||
<td>
|
||||
<p/>
|
||||
<form action="updateserver.lua" method="get">
|
||||
http://
|
||||
<input id="userver" type="text" name="set" size="30" value="" >
|
||||
/octonet/
|
||||
<br><input type="submit" value="Select Local Update Server">
|
||||
</form>
|
||||
<p/>
|
||||
<form action="updateserver.lua" method="get">
|
||||
<input type="hidden" name="set" value="std" >
|
||||
<input type="submit" value="Select Standard Update Server">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- End Content -->
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td colspan="2"> </td></tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
76
octoserve/var/www/updateserver.lua
Normal file
76
octoserve/var/www/updateserver.lua
Normal file
@ -0,0 +1,76 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local host = os.getenv("HTTP_HOST")
|
||||
local proto = os.getenv("SERVER_PROTOCOL")
|
||||
local query = os.getenv("QUERY_STRING")
|
||||
|
||||
function http_print(s)
|
||||
if s then
|
||||
io.stdout:write(tostring(s).."\r\n")
|
||||
else
|
||||
io.stdout:write("\r\n")
|
||||
end
|
||||
end
|
||||
|
||||
local userver = "download.digital-devices.de/download/linux"
|
||||
local data = nil
|
||||
local delimages = false
|
||||
|
||||
if query == "set=beta" then
|
||||
local file = io.open("/config/updateserver","w")
|
||||
if file then
|
||||
file:write(userver.."/beta".."\n")
|
||||
file:close()
|
||||
delimages = true
|
||||
end
|
||||
elseif query == "set=std" then
|
||||
local tmp = io.open("/config/updateserver","r")
|
||||
if tmp then
|
||||
file:close()
|
||||
os.remove("/config/updateserver")
|
||||
delimages = true
|
||||
end
|
||||
elseif query:sub(1,4) == "set=" then
|
||||
userver = query:sub(5)
|
||||
if userver ~= "" then
|
||||
local file = io.open("/config/updateserver","w")
|
||||
if file then
|
||||
file:write(userver.."\n")
|
||||
file:close()
|
||||
delimages = true
|
||||
end
|
||||
else
|
||||
os.remove("/config/updateserver")
|
||||
delimages = true
|
||||
end
|
||||
else
|
||||
data = "{ \"UpdateServer\":\""
|
||||
local file = io.open("/config/updateserver","r")
|
||||
if file then
|
||||
local tmp = file:read("*l")
|
||||
file:close()
|
||||
if tmp ~= userver.."/beta" then
|
||||
data = data .. tmp
|
||||
end
|
||||
end
|
||||
data = data.."\" }"
|
||||
end
|
||||
|
||||
if delimages then
|
||||
os.execute("rm -f /config/octonet.*.img")
|
||||
os.execute("rm -f /config/octonet.*.sha")
|
||||
end
|
||||
|
||||
if data then
|
||||
http_print(proto.." 200" )
|
||||
http_print("Pragma: no-cache")
|
||||
http_print("Content-Type: application/json; charset=UTF-8")
|
||||
http_print(string.format("Content-Length: %d",#data))
|
||||
http_print()
|
||||
http_print(data)
|
||||
else
|
||||
http_print(proto.." 303")
|
||||
http_print("Location: http://"..host.."/update.html")
|
||||
http_print("")
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user