diff --git a/octoserve/var/www/updateserver.html b/octoserve/var/www/updateserver.html new file mode 100644 index 0000000..2c98087 --- /dev/null +++ b/octoserve/var/www/updateserver.html @@ -0,0 +1,79 @@ + + + + +OctopusNet + + + + + + + + + + + + + + + + + + + +
+ DD +
 
+
+ +

Select Local Update Server

+ + + + + + + + + +
+

+

+ http:// + + /octonet/ +
+
+

+

+ + +
+
 
+ + + diff --git a/octoserve/var/www/updateserver.lua b/octoserve/var/www/updateserver.lua new file mode 100644 index 0000000..5226e03 --- /dev/null +++ b/octoserve/var/www/updateserver.lua @@ -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 +