Advertisement
osmarks

OC Drone Netboot

May 26th, 2020
883
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.57 KB | None | 0 0
  1. local net = component.proxy(component.list "internet"())
  2. local eeprom = component.proxy(component.list "eeprom"())
  3.  
  4. local function fetch(url)
  5.     local res, err = net.request(url)
  6.     if not res then error(url .. " error: " .. err) end
  7.     local out = {}
  8.     while true do
  9.         local chunk, err = res.read()
  10.         if err then error(url .. " error: " .. err) end
  11.         if chunk then table.insert(out, chunk)
  12.         else return table.concat(out) end
  13.     end
  14. end
  15.  
  16. local eepromdata = eeprom.getData()
  17. if eepromdata == "" then error "No URL loaded" end
  18. local fn = assert(load(fetch(eepromdata)))
  19. fn()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement