35 lines
891 B
Lua
35 lines
891 B
Lua
local addr = computer.getBootAddress()
|
|
local _component = component -- gets overridden later
|
|
local function loadfile(file)
|
|
local handle = assert(_component.invoke(addr, "open", file))
|
|
local buffer = ""
|
|
|
|
repeat
|
|
local data = _component.invoke(addr, "read", handle, math.maxinteger or math.huge)
|
|
buffer = buffer .. (data or "")
|
|
until not data
|
|
|
|
_component.invoke(addr, "close", handle)
|
|
return load(buffer, "=" .. file, "bt", _G)
|
|
end
|
|
|
|
local function hcf()
|
|
local ts = os.time()
|
|
while 1 do
|
|
if os.time() - ts >= 0.5 then
|
|
coroutine.yield()
|
|
end
|
|
end
|
|
end
|
|
|
|
|
|
local function rom_invoke(a, m, ...)
|
|
return _component.invoke(a, m, ...)
|
|
end
|
|
|
|
loadfile("/etc/system/boot.lua")(loadfile, hcf, rom_invoke)
|
|
--if loadfile("/sbin/de.lua")() == 0 then -- success
|
|
-- computer.shutdown()
|
|
--else
|
|
loadfile("/sbin/bsh.lua")(loadfile)
|
|
--end |