Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Chameleon EFI
- v1.0
- ]]--
- fs.delete("/boot.log")
- local w, h = term.getSize()
- isDebug = false
- Chameleon = {
- Log = {
- l = function(level, msg)
- local msg = "\n[" .. os.time() .. "] [" .. level .. "] " .. tostring(msg)
- if isDebug then
- print(msg)
- end
- local h = fs.open("/boot.log", "a")
- h.write(msg)
- h.close()
- end,
- },
- printc = function(text, y)
- local w, h = term.getSize()
- x = math.ceil(math.ceil((w / 2) - (#text / 2)), 0)+1
- term.setCursorPos(x, y)
- write(text)
- return x
- end,
- drawlogo = function(x,y)
- local bg = term.getBackgroundColor()
- local fg = term.getTextColor()
- if term.isColor() then
- paintutils.drawLine(x,y,x,y+2, colors.lime)
- paintutils.drawLine(x,y+2,x+2,y+2, colors.lime)
- paintutils.drawLine(x,y,x+1,y,colors.lime)
- paintutils.drawPixel(x+2,y,colors.white)
- paintutils.drawPixel(x+3,y,colors.black)
- else
- paintutils.drawLine(x,y,x,y+3, colors.white)
- paintutils.drawLine(x,y+3,x+2,y+3, colors.white)
- paintutils.drawLine(x,y,x+1,y,colors.white)
- paintutils.drawPixel(x+2,y,colors.white)
- paintutils.drawPixel(x+3,y,colors.white)
- end
- term.setBackgroundColor(bg)
- term.setTextColor(fg)
- end,
- Status = "",
- Running = true
- }
- startupKey = function()
- while true do
- local event, arg = os.pullEvent()
- if event=='chameleon_ready' then
- Chameleon.Log.l("BOOT", "No key. Starting normally.")
- return nil
- elseif event == "key" then
- Chameleon.Log.l("BOOT", "Boot Key: "..arg)
- return arg
- end
- end
- end
- local function BootScreen()
- local c = 0
- while Chameleon.Running do
- paintutils.drawFilledBox(1,h - 6, w, h, colors.gray)
- if c == 0 then
- term.setCursorPos(w / 2 - 1, h - 3)
- term.write("0 o o")
- elseif c == 1 then
- term.setCursorPos(w / 2 - 1, h - 3)
- term.write("o 0 o")
- elseif c == 2 then
- term.setCursorPos(w / 2 - 1, h - 3)
- term.write("o o 0")
- end
- c = c + 1
- if c > 2 then
- c = 0
- end
- term.setTextColor(colors.lightGray)
- Chameleon.printc(Chameleon.Status, h - 5)
- term.setTextColor(colors.white)
- Chameleon.drawlogo(w / 2, h / 2 - 2)
- sleep(0.5)
- end
- end
- parallel.waitForAll(function() sleep(2) os.queueEvent('chameleon_ready') end, function() key = startupKey() end)
- if key == keys.z then
- Chameleon.Log.l("BOOT", "Starting shell, goodbye!")
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- term.setCursorPos(1,1)
- print("Chameleon is no longer running.")
- print("You are in the system shell, run exit to reboot.")
- os.run(getfenv(), "/rom/programs/shell")
- os.reboot()
- elseif key == keys.x then
- Chameleon.Log.l("BOOT", "Custom boot script")
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.lightGray)
- term.clear()
- Chameleon.printc("Custom Bootup Script", h - 3)
- Chameleon.printc("Please type in a boot script to start.", h - 2)
- term.setCursorPos(1,h)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clearLine()
- script = read()
- pcall(function()shell.run(script)end) --this is a placeholder by the way, give me slack.
- os.reboot()
- end
- term.setBackgroundColor(colors.gray)
- term.clear()
- parallel.waitForAll(function() BootScreen() end, function() os.run(getfenv(), "/boot") end)
- local r = ChameleonDone() --this is called after the startup script is done executing
- --ChameleonDone is used for executing the actual code.
- print(r[2])
Advertisement
Add Comment
Please, Sign In to add comment