Skip to content

Commit

Permalink
Allow verbose boot by pressing "v", single by "s", FreeBSD bootloader…
Browse files Browse the repository at this point in the history
… by backspace
  • Loading branch information
probonopd committed Feb 24, 2023
1 parent f682520 commit 2252ca2
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions overlays/boot/boot/lua/local.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
local core = require("core")
local screen = require("screen")

-- loader.* functions are not part of normal lua, where are they documented?
-- Just look at the other lua files for "documentation"

screen.clear()
screen.defcursor()

KEY_LOWER_V = 118
KEY_UPPER_V = 86
KEY_LOWER_S = 115
KEY_UPPER_S = 83

local shouldboot = true

local endtime = loader.time() + 3
local time
local last

repeat
time = endtime - loader.time()

if last == nil or last ~= time then
last = time
end

if io.ischar() then
local ch = io.getchar()

if ch == core.KEY_ENTER then
core.setSingleUser(false)
core.boot()
break
end

if ch == core.KEY_BACKSPACE or ch == core.KEY_DELETE then
loader.setenv("beastie_disable", "NO")
loader.setenv("loader_logo", "none")
loader.setenv("loader_brand", "none")
loader.setenv("autoboot_delay", "NO")
shouldboot = false
break
end

if ch == KEY_LOWER_S or ch == KEY_UPPER_S then
printc("Single user boot")
core.setSingleUser(true)
loader.setenv("kern.vt.color.15.rgb", "0,0,0")
loader.setenv("kern.vt.color.7.rgb", "0,0,0")
core.boot()
break
end

if ch == KEY_LOWER_V or ch == KEY_UPPER_V then
printc("Verbose boot")
loader.unsetenv("boot_mute")
core.setVerbose(true)
loader.setenv("kern.vt.color.15.rgb", "0,0,0")
loader.setenv("kern.vt.color.7.rgb", "0,0,0")
core.boot()
break
end
end

loader.delay(50000)
until time <= 0

if shouldboot == true then
-- Set black font so that we don't see the messages while the kernel is being loaded
printc(core.KEYSTR_CSI .. "3" .. "0" .. "m")
core.boot()
end

0 comments on commit 2252ca2

Please sign in to comment.