mirror of
				https://github.com/DigitalDevices/octonet.git
				synced 2023-10-10 11:36:52 +00:00 
			
		
		
		
	Merge branch 'internal' of https://github.com/DigitalDevices/internal_octonet into internal
This commit is contained in:
		
							
								
								
									
										2
									
								
								dddvb
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								dddvb
									
									
									
									
									
								
							 Submodule dddvb updated: 72c8f0a166...f7de9178c1
									
								
							| @@ -17,7 +17,7 @@ local userver = "download.digital-devices.de/download/linux" | ||||
| if query == "set=beta" then | ||||
|   local file = io.open("/config/updateserver","w") | ||||
|   if file then | ||||
|     file:write(userver.."/beta/".."\n") | ||||
|     file:write(userver.."/beta".."\n") | ||||
|     file:close() | ||||
|   end | ||||
| elseif query == "set=std" then | ||||
|   | ||||
| @@ -8,12 +8,9 @@ | ||||
| <!-- Add page scripts here --> | ||||
| <script type="text/javascript"> | ||||
|  | ||||
| CheckDone = false; | ||||
| DownloadDone = false; | ||||
| VerifyDone = false; | ||||
| UpdateError = false; | ||||
| WaitCounter = 30; | ||||
| UpdateInfo = ""; | ||||
| UpdateError = false; | ||||
| isReboot = false; | ||||
|  | ||||
| function FWVersion(fwdate) | ||||
| { | ||||
| @@ -32,56 +29,72 @@ function FWVersion(fwdate) | ||||
|  | ||||
| } | ||||
|  | ||||
| function CheckUpdateStatus() | ||||
| { | ||||
|   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); | ||||
| var xmlhttp = new XMLHttpRequest(); | ||||
|  | ||||
|   if( UpdateError ) | ||||
|   { | ||||
|       document.getElementById("UpdateButton").disabled  = false;     | ||||
|       document.getElementById("UpdateButton").value  = "Continue";     | ||||
|       document.getElementById("updatestatus").firstChild.nodeValue  = UpdateInfo;     | ||||
|   }   | ||||
|   else if( VerifyDone ) | ||||
|   { | ||||
|       document.getElementById("UpdateButton").disabled  = false;     | ||||
|       document.getElementById("UpdateButton").value  = "Reboot";     | ||||
|       document.getElementById("updatestatus").firstChild.nodeValue  = "";     | ||||
|   } | ||||
|   else if( DownloadDone ) | ||||
|   { | ||||
|       document.getElementById("updatestatus").firstChild.nodeValue  = "***** Verifying ******";     | ||||
|       DownloadDone = false; | ||||
|       window.setTimeout(CheckUpdateStatus,250);   | ||||
|   } | ||||
|   else if( CheckDone ) | ||||
|   { | ||||
|       document.getElementById("updatestatus").firstChild.nodeValue  = "***** Downloading ******";     | ||||
|       CheckDone = false; | ||||
|       window.setTimeout(CheckUpdateStatus,250);   | ||||
|   } | ||||
|   else   | ||||
|     window.setTimeout(CheckUpdateStatus,250);   | ||||
| 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").value  = "Continue";     | ||||
|      document.getElementById("updatestatus").firstChild.nodeValue  = UpdateStatus.Status;    | ||||
|      UpdateError = true; | ||||
|    }     | ||||
|    else if( UpdateStatus.Status == "Started" ) | ||||
|    { | ||||
|      window.setTimeout(RequestStatus,250);   | ||||
|    } | ||||
|    else if( UpdateStatus.Status == "VerifyDone" ) | ||||
|    { | ||||
|      document.getElementById("UpdateButton").disabled  = false;     | ||||
|      document.getElementById("UpdateButton").value  = "Reboot";     | ||||
|      document.getElementById("updatestatus").firstChild.nodeValue  = "";     | ||||
|    } | ||||
|    else if( UpdateStatus.Status == "DownloadDone" ) | ||||
|    { | ||||
|      document.getElementById("updatestatus").firstChild.nodeValue  = "***** Verifying ******";     | ||||
|      window.setTimeout(RequestStatus,250);   | ||||
|    } | ||||
|    else if( UpdateStatus.Status == "CheckDone" ) | ||||
|    { | ||||
|      document.getElementById("updatestatus").firstChild.nodeValue  = "***** Downloading ******";     | ||||
|      window.setTimeout(RequestStatus,250);   | ||||
|    } | ||||
|    else   | ||||
|      window.setTimeout(RequestStatus,250);   | ||||
|      | ||||
| } | ||||
|  | ||||
| function RequestStatus() | ||||
| { | ||||
|    xmlhttp.open("GET", "/update.lua?updatestatus", true); | ||||
|    xmlhttp.send(); | ||||
| } | ||||
|  | ||||
| function DoUpdate() | ||||
| { | ||||
|   CheckDone = false; | ||||
|   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?update"; | ||||
|   head.appendChild(newscript); | ||||
|   window.setTimeout(CheckUpdateStatus,250);   | ||||
|   Request("/update.lua?update"); | ||||
| } | ||||
|  | ||||
| function Reboot() | ||||
| @@ -93,12 +106,8 @@ function Reboot() | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     head = document.getElementsByTagName('head')[0]; | ||||
|     newscript = document.createElement('script'); | ||||
|     newscript.id = "script2"; | ||||
|     newscript.type = "text/javascript"; | ||||
|     newscript.src = "/reboot.lua?sjiwjsiowjs"; | ||||
|     head.appendChild(newscript);   | ||||
|     isReboot = true; | ||||
|     Request("/reboot.lua?sjiwjsiowjs"); | ||||
|     WaitCounter = 70; | ||||
|     document.getElementById("updatestatus").firstChild.nodeValue  = WaitCounter; | ||||
|     window.setTimeout(Wait,1000);   | ||||
|   | ||||
| @@ -103,8 +103,7 @@ function OnLoad() | ||||
|               <script type="text/javascript"> | ||||
|                 if( Octoserve ) | ||||
|                   document.write(Octoserve.Version); | ||||
|                 if( beta )  | ||||
|                   document.write(" BETA"); | ||||
|                 document.write(" " + suffix); | ||||
|               </script> | ||||
|             </h1> | ||||
|           </td></tr> | ||||
|   | ||||
| @@ -10,6 +10,18 @@ | ||||
| <!-- Add page scripts here --> | ||||
| <script type="text/javascript"> | ||||
|  | ||||
| var xmlhttp = new XMLHttpRequest(); | ||||
|  | ||||
| xmlhttp.onreadystatechange=function() | ||||
| { | ||||
| } | ||||
|  | ||||
| function Request(url)  | ||||
| { | ||||
|    xmlhttp.open("GET", url, true); | ||||
|    xmlhttp.send(); | ||||
| } | ||||
|  | ||||
| function DisableButtons() | ||||
| { | ||||
|   document.getElementById("RebootButton").disabled  = true;     | ||||
| @@ -20,12 +32,7 @@ function DisableButtons() | ||||
| function Reboot() | ||||
| { | ||||
|   DisableButtons(); | ||||
|   head = document.getElementsByTagName('head')[0]; | ||||
|   newscript = document.createElement('script'); | ||||
|   newscript.id = "script2"; | ||||
|   newscript.type = "text/javascript"; | ||||
|   newscript.src = "/reboot.lua?sjiwjsiowjs"; | ||||
|   head.appendChild(newscript);   | ||||
|   Request("/reboot.lua?sjiwjsiowjs"); | ||||
|   WaitCounter = 20; | ||||
|   document.getElementById("updatestatus").firstChild.nodeValue  = WaitCounter; | ||||
|   window.setTimeout(Wait,1000);   | ||||
| @@ -34,12 +41,7 @@ function Reboot() | ||||
| function RestartOcto() | ||||
| { | ||||
|   DisableButtons(); | ||||
|   head = document.getElementsByTagName('head')[0]; | ||||
|   newscript = document.createElement('script'); | ||||
|   newscript.id = "script2"; | ||||
|   newscript.type = "text/javascript"; | ||||
|   newscript.src = "/reboot.lua?restart_octo"; | ||||
|   head.appendChild(newscript);   | ||||
|   Request("/reboot.lua?restart_octo"); | ||||
|   WaitCounter = 4; | ||||
|   document.getElementById("updatestatus").firstChild.nodeValue  = WaitCounter; | ||||
|   window.setTimeout(Wait,1000);   | ||||
| @@ -48,12 +50,7 @@ function RestartOcto() | ||||
| function RestartDMS() | ||||
| { | ||||
|   DisableButtons(); | ||||
|   head = document.getElementsByTagName('head')[0]; | ||||
|   newscript = document.createElement('script'); | ||||
|   newscript.id = "script2"; | ||||
|   newscript.type = "text/javascript"; | ||||
|   newscript.src = "/reboot.lua?restart_dms"; | ||||
|   head.appendChild(newscript);   | ||||
|   Request("/reboot.lua?restart_dms"); | ||||
|   WaitCounter = 4; | ||||
|   document.getElementById("updatestatus").firstChild.nodeValue  = WaitCounter; | ||||
|   window.setTimeout(Wait,1000);   | ||||
|   | ||||
| @@ -1,15 +1,36 @@ | ||||
| #!/usr/bin/lua | ||||
|  | ||||
|  | ||||
| print("HTTP/1.0 200 ") | ||||
| print("Pragma: no-cache") | ||||
| print("Content-Type: application/x-javascript") | ||||
| print("") | ||||
|  | ||||
| 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 | ||||
|  | ||||
| Rebooting = "false" | ||||
|  | ||||
| if( query == "sjiwjsiowjs" ) then | ||||
|   print("Rebooting = true") | ||||
|   Rebooting = "true"; | ||||
|   local uImage = io.open("/boot/uImage") | ||||
|   if( uImage ) then | ||||
|     uImage:close() | ||||
| @@ -24,11 +45,18 @@ if( query == "sjiwjsiowjs" ) then | ||||
|   os.execute("sync") | ||||
|   os.execute("reboot") | ||||
| elseif( query == "restart_octo" ) then | ||||
|   print("Rebooting = true") | ||||
|   Rebooting = "true"; | ||||
|   os.execute("/etc/init.d/S99octo restartoctonet") | ||||
| elseif( query == "restart_dms" ) then | ||||
|   print("Rebooting = true") | ||||
|   Rebooting = "true"; | ||||
|   os.execute("/etc/init.d/S92dms restart") | ||||
| else | ||||
|   print("Rebooting = false") | ||||
| 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,11 +43,16 @@ end | ||||
| local fwdate = ""; | ||||
| if images[1] then fwdate = images[1] end | ||||
|  | ||||
| beta = "false" | ||||
| suffix = "" | ||||
| tmp = io.open("/config/updateserver") | ||||
| if tmp then | ||||
|   beta = "true" | ||||
|   tmp:close() | ||||
|    local updateserver = tmp:read("*l") | ||||
|    if updateserver == "download.digital-devices.de/download/linux/beta" then | ||||
|       suffix = "BETA" | ||||
|    else | ||||
|       suffix = "("..updateserver..")" | ||||
|    end | ||||
|    tmp:close() | ||||
| end | ||||
|  | ||||
| http_print(string.format("var linuxver = \"%s\";",uname)) | ||||
| @@ -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 fwdate = \"%s\";",fwdate)) | ||||
| 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"> | ||||
|  | ||||
| isChecking = false; | ||||
| UpdateInfo = ""; | ||||
| CheckDone = false; | ||||
| UpdateAvailable = false; | ||||
|  | ||||
| function FWVersion(fwdate) | ||||
| @@ -37,31 +35,37 @@ function FWVersion(fwdate) | ||||
|   return ("?"); | ||||
| } | ||||
|  | ||||
| var xmlhttp = new XMLHttpRequest(); | ||||
|  | ||||
| function CheckUpdateDone() | ||||
| xmlhttp.onreadystatechange=function() { | ||||
|     if (xmlhttp.readyState == 4 ) | ||||
|     { | ||||
|       if ( xmlhttp.status == 200) | ||||
|       { | ||||
|         myFunction(xmlhttp.responseText); | ||||
|       } | ||||
|       isChecking = false; | ||||
|     } | ||||
| } | ||||
|  | ||||
| function Request(url)  | ||||
| { | ||||
|   if( CheckDone ) | ||||
|   { | ||||
|     script = document.getElementById("script1"); | ||||
|     head = document.getElementsByTagName('head')[0]; | ||||
|     head.removeChild(script); | ||||
|      | ||||
|     if( UpdateInfo != "" )     | ||||
|    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("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; | ||||
|     } | ||||
|     else | ||||
|       document.getElementById("updatestatus").firstChild.nodeValue  = "No update available";     | ||||
|     isChecking = false; | ||||
|     document.getElementById("UpdateButton").disabled  = false;     | ||||
|   } | ||||
|   else | ||||
|   { | ||||
|     window.setTimeout(CheckUpdateDone,100);   | ||||
|   } | ||||
| } | ||||
|  | ||||
| function CheckUpdate() | ||||
| @@ -76,15 +80,7 @@ function CheckUpdate() | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|       CheckDone = false; | ||||
|       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);   | ||||
|       Request("/update.lua?check"); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,6 +1,34 @@ | ||||
| #!/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 DoCheck = false | ||||
|  | ||||
| @@ -11,8 +39,6 @@ if arg[1] then | ||||
|   else | ||||
|     query = arg[1] | ||||
|   end | ||||
| else | ||||
|   query = os.getenv("QUERY_STRING") | ||||
| end | ||||
|  | ||||
| if query == "check" then | ||||
| @@ -97,45 +123,45 @@ if DoUpdate then | ||||
|   return | ||||
| end | ||||
|  | ||||
| print("HTTP/1.0 200 ") | ||||
| print("Pragma: no-cache") | ||||
| print("Content-Type: application/x-javascript") | ||||
| print("") | ||||
|  | ||||
| JSONData = "" | ||||
| if query == "check" then | ||||
|  | ||||
|   if NewImage > CurImage then | ||||
|     print(string.format("UpdateInfo = \"%s\";",string.match(NewImage,"octonet%.(%d+)"))) | ||||
|   else | ||||
|     print("UpdateInfo = \"\";") | ||||
|   end | ||||
|   print("CheckDone = true;") | ||||
|    JSONData = "{ \"Info\":\"" | ||||
|    if NewImage > CurImage then | ||||
|       JSONData = JSONData .. string.match(NewImage,"octonet%.(%d+)") | ||||
|    end | ||||
|    JSONData = JSONData .. "\"}" | ||||
|    | ||||
| elseif query == "update" then | ||||
|   os.remove("/tmp/updatestatus") | ||||
|   print("UpdateStarted = true;") | ||||
|   os.execute("lua update.lua doupdate >/dev/null 2>/dev/null &") | ||||
|  | ||||
|    os.remove("/tmp/updatestatus") | ||||
|    JSONData = "{ \"Status\":\"Started\", \"Error\":false }" | ||||
|    os.execute("lua update.lua doupdate >/dev/null 2>/dev/null &") | ||||
|     | ||||
| elseif query == "updatestatus" then | ||||
|   local tmp = io.open("/tmp/updatestatus") | ||||
|   local updatestatus = "" | ||||
|   if tmp then | ||||
|     updatestatus = tmp:read() | ||||
|     tmp:close() | ||||
|   end | ||||
|   if updatestatus == "CheckDone" then | ||||
|     print("CheckDone = true;")     | ||||
|   elseif updatestatus == "DownloadDone" then | ||||
|     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 | ||||
|  | ||||
|    local tmp = io.open("/tmp/updatestatus") | ||||
|    local updatestatus = "" | ||||
|    if tmp then | ||||
|       updatestatus = tmp:read() | ||||
|       tmp:close() | ||||
|    end | ||||
|    UpdateError = "false" | ||||
|       if string.match(updatestatus,"(Error)") then | ||||
|    UpdateError = "true" | ||||
|    end | ||||
|    JSONData = "{ \"Status\":\""..updatestatus.."\", \"Error\":"..UpdateError.." }" | ||||
|    | ||||
| else | ||||
|   print(string.format("UpdateInfo = \'%s\';",query)) | ||||
|   print("UpdateError = true;") | ||||
|    JSONData = "{ \"Status\":\""..query.."\", \"Error\":true }" | ||||
| 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) | ||||
|  | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user