This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
FREAX/boot/ofbl

84 lines
2.1 KiB
Text
Raw Normal View History

2022-07-18 19:33:40 +02:00
--rawset(_G, "nativepullevent", os.pullEvent)
os.pullEvent = os.pullEventRaw
enableSleeps = true
function string2table(string_convert)
local table = {}
string_convert:sub(".",function(c) table.insert(table,c) end)
return table
end
if not term.isColour() then
printError("ofbl: OFBL and FREAX only supports")
printError("ofbl: advanced (pocket) computers")
sleep(3)
os.shutdown()
end
print("ofbl: conf: Loading")
if enableSleeps then sleep(0.3) else sleep(0.1) end
local config = {}
local name = nil
local initrd = nil
local kernel = nil
local kerneldraw = nil
if fs.exists("/boot/ofbl.conf") then
settings.load("/boot/ofbl.conf")
--config.oslist = string2table(settings.get("oslist"))
name = settings.get("os0.name")
initrd = settings.get("os0.initrd")
kernel = settings.get("os0.kernel")
kerneldraw = settings.get("os0.kerneldraw")
if name == nil then
print("ofbl: conf: name is null")
return
end
if initrd == nil then
print("ofbl: conf: initrd is null")
return
end
if kernel == nil then
print("ofbl: conf: kernel is null")
return
end
if kerneldraw == nil then
print("ofbl: conf: kerneldraw is null")
return
end
else
print("ofbl: conf: Not found")
return
end
print("ofbl: Copying kernel and initrd.img into RAM")
if enableSleeps then sleep(0.1) else sleep(0.1) end
fs.delete("/var/boot")
if not fs.isDir("/var") and not fs.exists("/var/boot") and not fs.isDir("/var/boot") then
fs.makeDir("/var")
fs.makeDir("/var/boot")
end
if fs.exists(kernel) then
if fs.exists(kerneldraw) then
if fs.exists(initrd) then
fs.copy(initrd,"/var/boot/initrd")
fs.copy(kernel,"/var/boot/kernel")
fs.copy(kerneldraw,"/var/boot/kerneldraw")
else
print("ofbl: " .. initrd .. " not found")
return
end
else
print("ofbl: " .. kerneldraw .. " not found")
return
end
else
print("ofbl: " .. kernel .. " not found")
return
end
if enableSleeps then sleep(1.95) else sleep(0.1) end
print("ofbl: Loading kernel")
if enableSleeps then sleep(3.25) else sleep(0.1) end
os.loadAPI("/var/boot/kernel")
os.loadAPI("/var/boot/kerneldraw")
print("ofbl: Loading initrd.img")
if enableSleeps then sleep(2.65) else sleep(0.1) end
shell.execute(initrd)