mirror of
https://github.com/DigitalDevices/octonet.git
synced 2023-10-10 13:36:52 +02:00
Webserver javascripts updates
Replaces DOM based dynamic jscript elements with XMLHttpRequests and JSON replies. Not yet on all pages.
This commit is contained in:
parent
f73ea934ff
commit
73bf0bd413
@ -17,7 +17,7 @@ local userver = "download.digital-devices.de/download/linux"
|
|||||||
if query == "set=beta" then
|
if query == "set=beta" then
|
||||||
local file = io.open("/config/updateserver","w")
|
local file = io.open("/config/updateserver","w")
|
||||||
if file then
|
if file then
|
||||||
file:write(userver.."/beta/".."\n")
|
file:write(userver.."/beta".."\n")
|
||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
elseif query == "set=std" then
|
elseif query == "set=std" then
|
||||||
|
@ -8,12 +8,9 @@
|
|||||||
<!-- Add page scripts here -->
|
<!-- Add page scripts here -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
CheckDone = false;
|
|
||||||
DownloadDone = false;
|
|
||||||
VerifyDone = false;
|
|
||||||
UpdateError = false;
|
|
||||||
WaitCounter = 30;
|
WaitCounter = 30;
|
||||||
UpdateInfo = "";
|
UpdateError = false;
|
||||||
|
isReboot = false;
|
||||||
|
|
||||||
function FWVersion(fwdate)
|
function FWVersion(fwdate)
|
||||||
{
|
{
|
||||||
@ -32,56 +29,72 @@ function FWVersion(fwdate)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckUpdateStatus()
|
var xmlhttp = new XMLHttpRequest();
|
||||||
{
|
|
||||||
script = document.getElementById("script1");
|
|
||||||
head = document.getElementsByTagName('head')[0];
|
|
||||||
head.removeChild(script);
|
|
||||||
newscript = document.createElement('script');
|
|
||||||
newscript.id = "script1";
|
|
||||||
newscript.type = "text/javascript";
|
|
||||||
newscript.src = "/update.lua?updatestatus";
|
|
||||||
head.appendChild(newscript);
|
|
||||||
|
|
||||||
if( UpdateError )
|
xmlhttp.onreadystatechange=function() {
|
||||||
|
if (xmlhttp.readyState == 4 )
|
||||||
|
{
|
||||||
|
if ( xmlhttp.status == 200)
|
||||||
|
{
|
||||||
|
myFunction(xmlhttp.responseText);
|
||||||
|
}
|
||||||
|
isChecking = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function Request(url)
|
||||||
|
{
|
||||||
|
xmlhttp.open("GET", url, true);
|
||||||
|
xmlhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function myFunction(response) {
|
||||||
|
if( isReboot ) return;
|
||||||
|
var UpdateStatus = JSON.parse(response);
|
||||||
|
|
||||||
|
if( UpdateStatus.Error )
|
||||||
{
|
{
|
||||||
document.getElementById("UpdateButton").disabled = false;
|
document.getElementById("UpdateButton").disabled = false;
|
||||||
document.getElementById("UpdateButton").value = "Continue";
|
document.getElementById("UpdateButton").value = "Continue";
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = UpdateInfo;
|
document.getElementById("updatestatus").firstChild.nodeValue = UpdateStatus.Status;
|
||||||
|
UpdateError = true;
|
||||||
}
|
}
|
||||||
else if( VerifyDone )
|
else if( UpdateStatus.Status == "Started" )
|
||||||
|
{
|
||||||
|
window.setTimeout(RequestStatus,250);
|
||||||
|
}
|
||||||
|
else if( UpdateStatus.Status == "VerifyDone" )
|
||||||
{
|
{
|
||||||
document.getElementById("UpdateButton").disabled = false;
|
document.getElementById("UpdateButton").disabled = false;
|
||||||
document.getElementById("UpdateButton").value = "Reboot";
|
document.getElementById("UpdateButton").value = "Reboot";
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = "";
|
document.getElementById("updatestatus").firstChild.nodeValue = "";
|
||||||
}
|
}
|
||||||
else if( DownloadDone )
|
else if( UpdateStatus.Status == "DownloadDone" )
|
||||||
{
|
{
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = "***** Verifying ******";
|
document.getElementById("updatestatus").firstChild.nodeValue = "***** Verifying ******";
|
||||||
DownloadDone = false;
|
window.setTimeout(RequestStatus,250);
|
||||||
window.setTimeout(CheckUpdateStatus,250);
|
|
||||||
}
|
}
|
||||||
else if( CheckDone )
|
else if( UpdateStatus.Status == "CheckDone" )
|
||||||
{
|
{
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = "***** Downloading ******";
|
document.getElementById("updatestatus").firstChild.nodeValue = "***** Downloading ******";
|
||||||
CheckDone = false;
|
window.setTimeout(RequestStatus,250);
|
||||||
window.setTimeout(CheckUpdateStatus,250);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
window.setTimeout(CheckUpdateStatus,250);
|
window.setTimeout(RequestStatus,250);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function RequestStatus()
|
||||||
|
{
|
||||||
|
xmlhttp.open("GET", "/update.lua?updatestatus", true);
|
||||||
|
xmlhttp.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
function DoUpdate()
|
function DoUpdate()
|
||||||
{
|
{
|
||||||
CheckDone = false;
|
CheckDone = false;
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = "***** Checking ******";
|
document.getElementById("updatestatus").firstChild.nodeValue = "***** Checking ******";
|
||||||
head = document.getElementsByTagName('head')[0];
|
Request("/update.lua?update");
|
||||||
newscript = document.createElement('script');
|
|
||||||
newscript.id = "script1";
|
|
||||||
newscript.type = "text/javascript";
|
|
||||||
newscript.src = "/update.lua?update";
|
|
||||||
head.appendChild(newscript);
|
|
||||||
window.setTimeout(CheckUpdateStatus,250);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Reboot()
|
function Reboot()
|
||||||
@ -93,12 +106,8 @@ function Reboot()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
head = document.getElementsByTagName('head')[0];
|
isReboot = true;
|
||||||
newscript = document.createElement('script');
|
Request("/reboot.lua?sjiwjsiowjs");
|
||||||
newscript.id = "script2";
|
|
||||||
newscript.type = "text/javascript";
|
|
||||||
newscript.src = "/reboot.lua?sjiwjsiowjs";
|
|
||||||
head.appendChild(newscript);
|
|
||||||
WaitCounter = 70;
|
WaitCounter = 70;
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = WaitCounter;
|
document.getElementById("updatestatus").firstChild.nodeValue = WaitCounter;
|
||||||
window.setTimeout(Wait,1000);
|
window.setTimeout(Wait,1000);
|
||||||
|
@ -103,8 +103,7 @@ function OnLoad()
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
if( Octoserve )
|
if( Octoserve )
|
||||||
document.write(Octoserve.Version);
|
document.write(Octoserve.Version);
|
||||||
if( beta )
|
document.write(" " + suffix);
|
||||||
document.write(" BETA");
|
|
||||||
</script>
|
</script>
|
||||||
</h1>
|
</h1>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
@ -10,6 +10,18 @@
|
|||||||
<!-- Add page scripts here -->
|
<!-- Add page scripts here -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var xmlhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xmlhttp.onreadystatechange=function()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function Request(url)
|
||||||
|
{
|
||||||
|
xmlhttp.open("GET", url, true);
|
||||||
|
xmlhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
function DisableButtons()
|
function DisableButtons()
|
||||||
{
|
{
|
||||||
document.getElementById("RebootButton").disabled = true;
|
document.getElementById("RebootButton").disabled = true;
|
||||||
@ -20,12 +32,7 @@ function DisableButtons()
|
|||||||
function Reboot()
|
function Reboot()
|
||||||
{
|
{
|
||||||
DisableButtons();
|
DisableButtons();
|
||||||
head = document.getElementsByTagName('head')[0];
|
Request("/reboot.lua?sjiwjsiowjs");
|
||||||
newscript = document.createElement('script');
|
|
||||||
newscript.id = "script2";
|
|
||||||
newscript.type = "text/javascript";
|
|
||||||
newscript.src = "/reboot.lua?sjiwjsiowjs";
|
|
||||||
head.appendChild(newscript);
|
|
||||||
WaitCounter = 20;
|
WaitCounter = 20;
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = WaitCounter;
|
document.getElementById("updatestatus").firstChild.nodeValue = WaitCounter;
|
||||||
window.setTimeout(Wait,1000);
|
window.setTimeout(Wait,1000);
|
||||||
@ -34,12 +41,7 @@ function Reboot()
|
|||||||
function RestartOcto()
|
function RestartOcto()
|
||||||
{
|
{
|
||||||
DisableButtons();
|
DisableButtons();
|
||||||
head = document.getElementsByTagName('head')[0];
|
Request("/reboot.lua?restart_octo");
|
||||||
newscript = document.createElement('script');
|
|
||||||
newscript.id = "script2";
|
|
||||||
newscript.type = "text/javascript";
|
|
||||||
newscript.src = "/reboot.lua?restart_octo";
|
|
||||||
head.appendChild(newscript);
|
|
||||||
WaitCounter = 4;
|
WaitCounter = 4;
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = WaitCounter;
|
document.getElementById("updatestatus").firstChild.nodeValue = WaitCounter;
|
||||||
window.setTimeout(Wait,1000);
|
window.setTimeout(Wait,1000);
|
||||||
@ -48,12 +50,7 @@ function RestartOcto()
|
|||||||
function RestartDMS()
|
function RestartDMS()
|
||||||
{
|
{
|
||||||
DisableButtons();
|
DisableButtons();
|
||||||
head = document.getElementsByTagName('head')[0];
|
Request("/reboot.lua?restart_dms");
|
||||||
newscript = document.createElement('script');
|
|
||||||
newscript.id = "script2";
|
|
||||||
newscript.type = "text/javascript";
|
|
||||||
newscript.src = "/reboot.lua?restart_dms";
|
|
||||||
head.appendChild(newscript);
|
|
||||||
WaitCounter = 4;
|
WaitCounter = 4;
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = WaitCounter;
|
document.getElementById("updatestatus").firstChild.nodeValue = WaitCounter;
|
||||||
window.setTimeout(Wait,1000);
|
window.setTimeout(Wait,1000);
|
||||||
|
@ -1,15 +1,36 @@
|
|||||||
#!/usr/bin/lua
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
local host = os.getenv("HTTP_HOST")
|
||||||
print("HTTP/1.0 200 ")
|
local proto = os.getenv("SERVER_PROTOCOL")
|
||||||
print("Pragma: no-cache")
|
|
||||||
print("Content-Type: application/x-javascript")
|
|
||||||
print("")
|
|
||||||
|
|
||||||
local query = os.getenv("QUERY_STRING")
|
local query = os.getenv("QUERY_STRING")
|
||||||
|
local method = os.getenv("REQUEST_METHOD")
|
||||||
|
local clength = os.getenv("CONTENT_LENGTH")
|
||||||
|
local ctype = os.getenv("CONTENT_TYPE")
|
||||||
|
|
||||||
|
function http_print(s)
|
||||||
|
if s then
|
||||||
|
io.stdout:write(tostring(s).."\r\n")
|
||||||
|
else
|
||||||
|
io.stdout:write("\r\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function SendError(err,desc)
|
||||||
|
http_print(proto.." "..err)
|
||||||
|
http_print()
|
||||||
|
local file = io.open("e404.html")
|
||||||
|
if file then
|
||||||
|
local tmp = file:read("*a")
|
||||||
|
tmp = string.gsub(tmp,"404 Not Found",err .. " " .. desc)
|
||||||
|
http_print(tmp)
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rebooting = "false"
|
||||||
|
|
||||||
if( query == "sjiwjsiowjs" ) then
|
if( query == "sjiwjsiowjs" ) then
|
||||||
print("Rebooting = true")
|
Rebooting = "true";
|
||||||
local uImage = io.open("/boot/uImage")
|
local uImage = io.open("/boot/uImage")
|
||||||
if( uImage ) then
|
if( uImage ) then
|
||||||
uImage:close()
|
uImage:close()
|
||||||
@ -24,11 +45,18 @@ if( query == "sjiwjsiowjs" ) then
|
|||||||
os.execute("sync")
|
os.execute("sync")
|
||||||
os.execute("reboot")
|
os.execute("reboot")
|
||||||
elseif( query == "restart_octo" ) then
|
elseif( query == "restart_octo" ) then
|
||||||
print("Rebooting = true")
|
Rebooting = "true";
|
||||||
os.execute("/etc/init.d/S99octo restartoctonet")
|
os.execute("/etc/init.d/S99octo restartoctonet")
|
||||||
elseif( query == "restart_dms" ) then
|
elseif( query == "restart_dms" ) then
|
||||||
print("Rebooting = true")
|
Rebooting = "true";
|
||||||
os.execute("/etc/init.d/S92dms restart")
|
os.execute("/etc/init.d/S92dms restart")
|
||||||
else
|
|
||||||
print("Rebooting = false")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
JSONData = "{\"Rebooting\":"..Rebooting.."}"
|
||||||
|
|
||||||
|
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",#JSONData))
|
||||||
|
http_print()
|
||||||
|
http_print(JSONData)
|
||||||
|
@ -43,10 +43,15 @@ end
|
|||||||
local fwdate = "";
|
local fwdate = "";
|
||||||
if images[1] then fwdate = images[1] end
|
if images[1] then fwdate = images[1] end
|
||||||
|
|
||||||
beta = "false"
|
suffix = ""
|
||||||
tmp = io.open("/config/updateserver")
|
tmp = io.open("/config/updateserver")
|
||||||
if tmp then
|
if tmp then
|
||||||
beta = "true"
|
local updateserver = tmp:read("*l")
|
||||||
|
if updateserver == "download.digital-devices.de/download/linux/beta" then
|
||||||
|
suffix = "BETA"
|
||||||
|
else
|
||||||
|
suffix = "("..updateserver..")"
|
||||||
|
end
|
||||||
tmp:close()
|
tmp:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -57,4 +62,4 @@ http_print(string.format("var fpgatype = \"%0X\";",registers[3] / 65536))
|
|||||||
-- http_print(string.format("var fpgatype = \"%0X\";",registers[3] >> 16))
|
-- http_print(string.format("var fpgatype = \"%0X\";",registers[3] >> 16))
|
||||||
http_print(string.format("var fwdate = \"%s\";",fwdate))
|
http_print(string.format("var fwdate = \"%s\";",fwdate))
|
||||||
http_print(string.format("var host = \"%s\";",host))
|
http_print(string.format("var host = \"%s\";",host))
|
||||||
http_print(string.format("var beta = %s;",beta))
|
http_print(string.format("var suffix = \"%s\";",suffix))
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
isChecking = false;
|
isChecking = false;
|
||||||
UpdateInfo = "";
|
|
||||||
CheckDone = false;
|
|
||||||
UpdateAvailable = false;
|
UpdateAvailable = false;
|
||||||
|
|
||||||
function FWVersion(fwdate)
|
function FWVersion(fwdate)
|
||||||
@ -37,31 +35,37 @@ function FWVersion(fwdate)
|
|||||||
return ("?");
|
return ("?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var xmlhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
function CheckUpdateDone()
|
xmlhttp.onreadystatechange=function() {
|
||||||
{
|
if (xmlhttp.readyState == 4 )
|
||||||
if( CheckDone )
|
|
||||||
{
|
{
|
||||||
script = document.getElementById("script1");
|
if ( xmlhttp.status == 200)
|
||||||
head = document.getElementsByTagName('head')[0];
|
{
|
||||||
head.removeChild(script);
|
myFunction(xmlhttp.responseText);
|
||||||
|
}
|
||||||
|
isChecking = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( UpdateInfo != "" )
|
function Request(url)
|
||||||
|
{
|
||||||
|
xmlhttp.open("GET", url, true);
|
||||||
|
xmlhttp.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function myFunction(response) {
|
||||||
|
var UpdateStatus = JSON.parse(response);
|
||||||
|
if( UpdateStatus.Info != "" )
|
||||||
{
|
{
|
||||||
document.getElementById("UpdateButton").value = "Update";
|
document.getElementById("UpdateButton").value = "Update";
|
||||||
document.getElementById("updatemsg").firstChild.nodeValue = "New firmware/system package available";
|
document.getElementById("updatemsg").firstChild.nodeValue = "New firmware/system package available";
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = "Version: " + FWVersion(UpdateInfo);
|
document.getElementById("updatestatus").firstChild.nodeValue = "Version: " + FWVersion(UpdateStatus.Info);
|
||||||
UpdateAvailable = true;
|
UpdateAvailable = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = "No update available";
|
document.getElementById("updatestatus").firstChild.nodeValue = "No update available";
|
||||||
isChecking = false;
|
|
||||||
document.getElementById("UpdateButton").disabled = false;
|
document.getElementById("UpdateButton").disabled = false;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
window.setTimeout(CheckUpdateDone,100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckUpdate()
|
function CheckUpdate()
|
||||||
@ -76,15 +80,7 @@ function CheckUpdate()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CheckDone = false;
|
Request("/update.lua?check");
|
||||||
document.getElementById("updatestatus").firstChild.nodeValue = "***** Checking ******";
|
|
||||||
head = document.getElementsByTagName('head')[0];
|
|
||||||
newscript = document.createElement('script');
|
|
||||||
newscript.id = "script1";
|
|
||||||
newscript.type = "text/javascript";
|
|
||||||
newscript.src = "/update.lua?check";
|
|
||||||
head.appendChild(newscript);
|
|
||||||
window.setTimeout(CheckUpdateDone,100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,34 @@
|
|||||||
#!/usr/bin/lua
|
#!/usr/bin/lua
|
||||||
|
|
||||||
local query = ""
|
local host = os.getenv("HTTP_HOST")
|
||||||
|
local proto = os.getenv("SERVER_PROTOCOL")
|
||||||
|
local query = os.getenv("QUERY_STRING")
|
||||||
|
local method = os.getenv("REQUEST_METHOD")
|
||||||
|
local clength = os.getenv("CONTENT_LENGTH")
|
||||||
|
local ctype = os.getenv("CONTENT_TYPE")
|
||||||
|
|
||||||
|
function http_print(s)
|
||||||
|
if s then
|
||||||
|
io.stdout:write(tostring(s).."\r\n")
|
||||||
|
else
|
||||||
|
io.stdout:write("\r\n")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function SendError(err,desc)
|
||||||
|
http_print(proto.." "..err)
|
||||||
|
http_print()
|
||||||
|
local file = io.open("e404.html")
|
||||||
|
if file then
|
||||||
|
local tmp = file:read("*a")
|
||||||
|
tmp = string.gsub(tmp,"404 Not Found",err .. " " .. desc)
|
||||||
|
http_print(tmp)
|
||||||
|
file:close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not query then query = "" end
|
||||||
|
if not proto then proto = "HTTP/1.0" end
|
||||||
local DoUpdate = false
|
local DoUpdate = false
|
||||||
local DoCheck = false
|
local DoCheck = false
|
||||||
|
|
||||||
@ -11,8 +39,6 @@ if arg[1] then
|
|||||||
else
|
else
|
||||||
query = arg[1]
|
query = arg[1]
|
||||||
end
|
end
|
||||||
else
|
|
||||||
query = os.getenv("QUERY_STRING")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if query == "check" then
|
if query == "check" then
|
||||||
@ -97,45 +123,45 @@ if DoUpdate then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
print("HTTP/1.0 200 ")
|
JSONData = ""
|
||||||
print("Pragma: no-cache")
|
|
||||||
print("Content-Type: application/x-javascript")
|
|
||||||
print("")
|
|
||||||
|
|
||||||
if query == "check" then
|
if query == "check" then
|
||||||
|
|
||||||
|
JSONData = "{ \"Info\":\""
|
||||||
if NewImage > CurImage then
|
if NewImage > CurImage then
|
||||||
print(string.format("UpdateInfo = \"%s\";",string.match(NewImage,"octonet%.(%d+)")))
|
JSONData = JSONData .. string.match(NewImage,"octonet%.(%d+)")
|
||||||
else
|
|
||||||
print("UpdateInfo = \"\";")
|
|
||||||
end
|
end
|
||||||
print("CheckDone = true;")
|
JSONData = JSONData .. "\"}"
|
||||||
|
|
||||||
elseif query == "update" then
|
elseif query == "update" then
|
||||||
|
|
||||||
os.remove("/tmp/updatestatus")
|
os.remove("/tmp/updatestatus")
|
||||||
print("UpdateStarted = true;")
|
JSONData = "{ \"Status\":\"Started\", \"Error\":false }"
|
||||||
os.execute("lua update.lua doupdate >/dev/null 2>/dev/null &")
|
os.execute("lua update.lua doupdate >/dev/null 2>/dev/null &")
|
||||||
|
|
||||||
elseif query == "updatestatus" then
|
elseif query == "updatestatus" then
|
||||||
|
|
||||||
local tmp = io.open("/tmp/updatestatus")
|
local tmp = io.open("/tmp/updatestatus")
|
||||||
local updatestatus = ""
|
local updatestatus = ""
|
||||||
if tmp then
|
if tmp then
|
||||||
updatestatus = tmp:read()
|
updatestatus = tmp:read()
|
||||||
tmp:close()
|
tmp:close()
|
||||||
end
|
end
|
||||||
if updatestatus == "CheckDone" then
|
UpdateError = "false"
|
||||||
print("CheckDone = true;")
|
if string.match(updatestatus,"(Error)") then
|
||||||
elseif updatestatus == "DownloadDone" then
|
UpdateError = "true"
|
||||||
print("DownloadDone = true;")
|
|
||||||
elseif updatestatus == "VerifyDone" then
|
|
||||||
print("VerifyDone = true;")
|
|
||||||
elseif string.match(updatestatus,"(Error)") then
|
|
||||||
print(string.format("UpdateInfo = \'%s\';",updatestatus))
|
|
||||||
print("UpdateError = true;")
|
|
||||||
end
|
end
|
||||||
|
JSONData = "{ \"Status\":\""..updatestatus.."\", \"Error\":"..UpdateError.." }"
|
||||||
|
|
||||||
else
|
else
|
||||||
print(string.format("UpdateInfo = \'%s\';",query))
|
JSONData = "{ \"Status\":\""..query.."\", \"Error\":true }"
|
||||||
print("UpdateError = true;")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
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",#JSONData))
|
||||||
|
http_print()
|
||||||
|
http_print(JSONData)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user