2018-02-12 15:32:00 +00:00
|
|
|
--
|
|
|
|
-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
|
2018-02-19 18:11:35 +00:00
|
|
|
-- Copyright (C) 2018 Kyle Evans <kevans@FreeBSD.org>
|
2018-02-12 15:32:00 +00:00
|
|
|
-- All rights reserved.
|
|
|
|
--
|
|
|
|
-- Redistribution and use in source and binary forms, with or without
|
|
|
|
-- modification, are permitted provided that the following conditions
|
|
|
|
-- are met:
|
|
|
|
-- 1. Redistributions of source code must retain the above copyright
|
|
|
|
-- notice, this list of conditions and the following disclaimer.
|
|
|
|
-- 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
-- notice, this list of conditions and the following disclaimer in the
|
|
|
|
-- documentation and/or other materials provided with the distribution.
|
|
|
|
--
|
|
|
|
-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
-- SUCH DAMAGE.
|
|
|
|
--
|
|
|
|
-- $FreeBSD$
|
|
|
|
--
|
|
|
|
|
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local core = require("core")
|
|
|
|
local color = require("color")
|
|
|
|
local config = require("config")
|
|
|
|
local screen = require("screen")
|
|
|
|
local drawer = require("drawer")
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local menu = {}
|
2018-02-19 17:54:22 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local skip
|
|
|
|
local run
|
|
|
|
local autoboot
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-20 14:36:28 +00:00
|
|
|
local OnOff = function(str, b)
|
|
|
|
if (b) then
|
|
|
|
return str .. color.escapef(color.GREEN) .. "On" ..
|
2018-02-21 01:10:03 +00:00
|
|
|
color.escapef(color.WHITE)
|
2018-02-20 14:36:28 +00:00
|
|
|
else
|
|
|
|
return str .. color.escapef(color.RED) .. "off" ..
|
2018-02-21 01:10:03 +00:00
|
|
|
color.escapef(color.WHITE)
|
2018-02-20 14:36:28 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-20 14:45:58 +00:00
|
|
|
-- Module exports
|
2018-02-20 03:40:16 +00:00
|
|
|
menu.handlers = {
|
|
|
|
-- Menu handlers take the current menu and selected entry as parameters,
|
|
|
|
-- and should return a boolean indicating whether execution should
|
|
|
|
-- continue or not. The return value may be omitted if this entry should
|
|
|
|
-- have no bearing on whether we continue or not, indicating that we
|
|
|
|
-- should just continue after execution.
|
|
|
|
[core.MENU_ENTRY] = function(current_menu, entry)
|
|
|
|
-- run function
|
2018-02-21 01:10:03 +00:00
|
|
|
entry.func()
|
2018-02-20 03:40:16 +00:00
|
|
|
end,
|
|
|
|
[core.MENU_CAROUSEL_ENTRY] = function(current_menu, entry)
|
|
|
|
-- carousel (rotating) functionality
|
2018-02-21 01:10:03 +00:00
|
|
|
local carid = entry.carousel_id
|
|
|
|
local caridx = config.getCarouselIndex(carid)
|
|
|
|
local choices = entry.items()
|
2018-02-20 03:40:16 +00:00
|
|
|
|
|
|
|
if (#choices > 0) then
|
2018-02-21 01:10:03 +00:00
|
|
|
caridx = (caridx % #choices) + 1
|
|
|
|
config.setCarouselIndex(carid, caridx)
|
|
|
|
entry.func(caridx, choices[caridx], choices)
|
2018-02-20 03:40:16 +00:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
[core.MENU_SUBMENU] = function(current_menu, entry)
|
|
|
|
-- recurse
|
2018-02-21 01:10:03 +00:00
|
|
|
return menu.run(entry.submenu())
|
2018-02-20 03:40:16 +00:00
|
|
|
end,
|
|
|
|
[core.MENU_RETURN] = function(current_menu, entry)
|
|
|
|
-- allow entry to have a function/side effect
|
|
|
|
if (entry.func ~= nil) then
|
2018-02-21 01:10:03 +00:00
|
|
|
entry.func()
|
2018-02-20 03:40:16 +00:00
|
|
|
end
|
2018-02-21 01:10:03 +00:00
|
|
|
return false
|
2018-02-20 03:40:16 +00:00
|
|
|
end,
|
2018-02-21 01:10:03 +00:00
|
|
|
}
|
2018-02-19 15:49:27 +00:00
|
|
|
-- loader menu tree is rooted at menu.welcome
|
2018-02-12 15:32:00 +00:00
|
|
|
|
|
|
|
menu.boot_options = {
|
2018-02-19 16:25:43 +00:00
|
|
|
entries = {
|
|
|
|
-- return to welcome menu
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_RETURN,
|
|
|
|
name = function()
|
|
|
|
return "Back to main menu" ..
|
2018-02-21 01:10:03 +00:00
|
|
|
color.highlight(" [Backspace]")
|
2018-02-19 16:25:43 +00:00
|
|
|
end
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
-- load defaults
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_ENTRY,
|
|
|
|
name = function()
|
|
|
|
return "Load System " .. color.highlight("D") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"efaults"
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
core.setDefaults()
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"d", "D"}
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
{
|
|
|
|
entry_type = core.MENU_SEPARATOR,
|
|
|
|
name = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
return ""
|
2018-02-19 16:25:43 +00:00
|
|
|
end
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
{
|
|
|
|
entry_type = core.MENU_SEPARATOR,
|
|
|
|
name = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
return "Boot Options:"
|
2018-02-19 16:25:43 +00:00
|
|
|
end
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
-- acpi
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_ENTRY,
|
2018-02-20 19:21:34 +00:00
|
|
|
visible = core.isSystem386,
|
2018-02-19 16:25:43 +00:00
|
|
|
name = function()
|
2018-02-19 16:42:06 +00:00
|
|
|
return OnOff(color.highlight("A") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"CPI :", core.acpi)
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
core.setACPI()
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"a", "A"}
|
|
|
|
},
|
|
|
|
-- safe mode
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_ENTRY,
|
|
|
|
name = function()
|
|
|
|
return OnOff("Safe " .. color.highlight("M") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"ode :", core.sm)
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
core.setSafeMode()
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"m", "M"}
|
|
|
|
},
|
|
|
|
-- single user
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_ENTRY,
|
|
|
|
name = function()
|
2018-02-19 16:42:06 +00:00
|
|
|
return OnOff(color.highlight("S") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"ingle user:", core.su)
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
core.setSingleUser()
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"s", "S"}
|
|
|
|
},
|
|
|
|
-- verbose boot
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_ENTRY,
|
|
|
|
name = function()
|
2018-02-19 16:42:06 +00:00
|
|
|
return OnOff(color.highlight("V") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"erbose :", core.verbose)
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
core.setVerbose()
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"v", "V"}
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
},
|
2018-02-21 01:10:03 +00:00
|
|
|
}
|
2018-02-12 15:32:00 +00:00
|
|
|
|
|
|
|
menu.welcome = {
|
2018-02-19 16:36:29 +00:00
|
|
|
entries = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
local menu_entries = menu.welcome.all_entries
|
2018-02-19 16:36:29 +00:00
|
|
|
-- Swap the first two menu items on single user boot
|
|
|
|
if (core.isSingleUserBoot()) then
|
2018-02-19 22:29:16 +00:00
|
|
|
-- We'll cache the swapped menu, for performance
|
|
|
|
if (menu.welcome.swapped_menu ~= nil) then
|
2018-02-21 01:10:03 +00:00
|
|
|
return menu.welcome.swapped_menu
|
2018-02-19 22:29:16 +00:00
|
|
|
end
|
2018-02-19 17:40:19 +00:00
|
|
|
-- Shallow copy the table
|
2018-02-21 01:10:03 +00:00
|
|
|
menu_entries = core.shallowCopyTable(menu_entries)
|
2018-02-19 17:40:19 +00:00
|
|
|
|
2018-02-19 22:29:16 +00:00
|
|
|
-- Swap the first two menu entries
|
2018-02-19 22:56:04 +00:00
|
|
|
menu_entries[1], menu_entries[2] =
|
2018-02-21 01:10:03 +00:00
|
|
|
menu_entries[2], menu_entries[1]
|
2018-02-19 17:40:19 +00:00
|
|
|
|
2018-02-19 22:29:16 +00:00
|
|
|
-- Then set their names to their alternate names
|
|
|
|
menu_entries[1].name, menu_entries[2].name =
|
|
|
|
menu_entries[1].alternate_name,
|
2018-02-21 01:10:03 +00:00
|
|
|
menu_entries[2].alternate_name
|
|
|
|
menu.welcome.swapped_menu = menu_entries
|
2018-02-19 16:36:29 +00:00
|
|
|
end
|
2018-02-21 01:10:03 +00:00
|
|
|
return menu_entries
|
2018-02-19 16:36:29 +00:00
|
|
|
end,
|
|
|
|
all_entries = {
|
2018-02-19 16:25:43 +00:00
|
|
|
-- boot multi user
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_ENTRY,
|
|
|
|
name = function()
|
2018-02-19 16:42:06 +00:00
|
|
|
return color.highlight("B") ..
|
|
|
|
"oot Multi user " ..
|
2018-02-21 01:10:03 +00:00
|
|
|
color.highlight("[Enter]")
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
2018-02-19 17:40:19 +00:00
|
|
|
-- Not a standard menu entry function!
|
|
|
|
alternate_name = function()
|
|
|
|
return color.highlight("B") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"oot Multi user"
|
2018-02-19 17:40:19 +00:00
|
|
|
end,
|
2018-02-19 16:25:43 +00:00
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
core.setSingleUser(false)
|
|
|
|
core.boot()
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"b", "B"}
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
-- boot single user
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_ENTRY,
|
|
|
|
name = function()
|
2018-02-19 16:42:06 +00:00
|
|
|
return "Boot " .. color.highlight("S") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"ingle user"
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
2018-02-19 17:40:19 +00:00
|
|
|
-- Not a standard menu entry function!
|
|
|
|
alternate_name = function()
|
|
|
|
return "Boot " .. color.highlight("S") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"ingle user " .. color.highlight("[Enter]")
|
2018-02-19 17:40:19 +00:00
|
|
|
end,
|
2018-02-19 16:25:43 +00:00
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
core.setSingleUser(true)
|
|
|
|
core.boot()
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"s", "S"}
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
-- escape to interpreter
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_RETURN,
|
|
|
|
name = function()
|
2018-02-19 16:42:06 +00:00
|
|
|
return color.highlight("Esc") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"ape to loader prompt"
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
loader.setenv("autoboot_delay", "NO")
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {core.KEYSTR_ESCAPE}
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
-- reboot
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_ENTRY,
|
|
|
|
name = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
return color.highlight("R") .. "eboot"
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
func = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
loader.perform("reboot")
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"r", "R"}
|
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
{
|
|
|
|
entry_type = core.MENU_SEPARATOR,
|
|
|
|
name = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
return ""
|
2018-02-16 04:31:09 +00:00
|
|
|
end
|
2018-02-19 16:25:43 +00:00
|
|
|
},
|
2018-02-16 04:31:09 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
{
|
|
|
|
entry_type = core.MENU_SEPARATOR,
|
|
|
|
name = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
return "Options:"
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2018-02-19 16:25:43 +00:00
|
|
|
},
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-19 16:25:43 +00:00
|
|
|
-- kernel options
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_CAROUSEL_ENTRY,
|
|
|
|
carousel_id = "kernel",
|
|
|
|
items = core.kernelList,
|
|
|
|
name = function(idx, choice, all_choices)
|
|
|
|
if (#all_choices == 0) then
|
2018-02-21 01:10:03 +00:00
|
|
|
return "Kernel: "
|
2018-02-19 16:25:43 +00:00
|
|
|
end
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local is_default = (idx == 1)
|
|
|
|
local kernel_name = ""
|
|
|
|
local name_color
|
2018-02-19 16:25:43 +00:00
|
|
|
if (is_default) then
|
2018-02-21 01:10:03 +00:00
|
|
|
name_color = color.escapef(color.GREEN)
|
|
|
|
kernel_name = "default/"
|
2018-02-19 16:25:43 +00:00
|
|
|
else
|
2018-02-21 01:10:03 +00:00
|
|
|
name_color = color.escapef(color.BLUE)
|
2018-02-19 16:25:43 +00:00
|
|
|
end
|
2018-02-19 16:42:06 +00:00
|
|
|
kernel_name = kernel_name .. name_color ..
|
2018-02-21 01:10:03 +00:00
|
|
|
choice .. color.default()
|
2018-02-19 17:51:33 +00:00
|
|
|
return color.highlight("K") .. "ernel: " ..
|
2018-02-19 16:42:06 +00:00
|
|
|
kernel_name .. " (" .. idx .. " of " ..
|
2018-02-21 01:10:03 +00:00
|
|
|
#all_choices .. ")"
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
func = function(idx, choice, all_choices)
|
2018-02-21 01:10:03 +00:00
|
|
|
config.selectkernel(choice)
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"k", "K"}
|
|
|
|
},
|
|
|
|
|
|
|
|
-- boot options
|
|
|
|
{
|
|
|
|
entry_type = core.MENU_SUBMENU,
|
|
|
|
name = function()
|
2018-02-19 16:42:06 +00:00
|
|
|
return "Boot " .. color.highlight("O") ..
|
2018-02-21 01:10:03 +00:00
|
|
|
"ptions"
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
submenu = function()
|
2018-02-21 01:10:03 +00:00
|
|
|
return menu.boot_options
|
2018-02-19 16:25:43 +00:00
|
|
|
end,
|
|
|
|
alias = {"o", "O"}
|
|
|
|
},
|
|
|
|
},
|
2018-02-21 01:10:03 +00:00
|
|
|
}
|
2018-02-12 15:32:00 +00:00
|
|
|
|
|
|
|
function menu.run(m)
|
|
|
|
|
|
|
|
if (menu.skip()) then
|
2018-02-21 01:10:03 +00:00
|
|
|
core.autoboot()
|
|
|
|
return false
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if (m == nil) then
|
2018-02-21 01:10:03 +00:00
|
|
|
m = menu.welcome
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
-- redraw screen
|
2018-02-21 01:10:03 +00:00
|
|
|
screen.clear()
|
|
|
|
screen.defcursor()
|
|
|
|
local alias_table = drawer.drawscreen(m)
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
menu.autoboot()
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
cont = true
|
2018-02-17 05:52:25 +00:00
|
|
|
while (cont) do
|
2018-02-21 01:10:03 +00:00
|
|
|
local key = io.getchar()
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-15 18:16:16 +00:00
|
|
|
-- Special key behaviors
|
2018-02-16 17:42:38 +00:00
|
|
|
if ((key == core.KEY_BACKSPACE) or (key == core.KEY_DELETE)) and
|
|
|
|
(m ~= menu.welcome) then
|
2018-02-21 01:10:03 +00:00
|
|
|
break
|
2018-02-16 03:12:24 +00:00
|
|
|
elseif (key == core.KEY_ENTER) then
|
2018-02-21 01:10:03 +00:00
|
|
|
core.boot()
|
2018-02-15 18:16:16 +00:00
|
|
|
-- Should not return
|
2018-02-14 20:18:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
key = string.char(key)
|
2018-02-12 15:32:00 +00:00
|
|
|
-- check to see if key is an alias
|
2018-02-21 01:10:03 +00:00
|
|
|
local sel_entry = nil
|
2018-02-12 15:32:00 +00:00
|
|
|
for k, v in pairs(alias_table) do
|
|
|
|
if (key == k) then
|
2018-02-21 01:10:03 +00:00
|
|
|
sel_entry = v
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- if we have an alias do the assigned action:
|
2018-02-17 05:52:25 +00:00
|
|
|
if (sel_entry ~= nil) then
|
2018-02-20 03:40:16 +00:00
|
|
|
-- Get menu handler
|
2018-02-21 01:10:03 +00:00
|
|
|
local handler = menu.handlers[sel_entry.entry_type]
|
2018-02-20 03:40:16 +00:00
|
|
|
if (handler ~= nil) then
|
|
|
|
-- The handler's return value indicates whether
|
|
|
|
-- we need to exit this menu. An omitted return
|
|
|
|
-- value means "continue" by default.
|
2018-02-21 01:10:03 +00:00
|
|
|
cont = handler(m, sel_entry)
|
2018-02-20 03:40:16 +00:00
|
|
|
if (cont == nil) then
|
2018-02-21 01:10:03 +00:00
|
|
|
cont = true
|
2018-02-16 22:17:30 +00:00
|
|
|
end
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
-- if we got an alias key the screen is out of date:
|
2018-02-21 01:10:03 +00:00
|
|
|
screen.clear()
|
|
|
|
screen.defcursor()
|
|
|
|
alias_table = drawer.drawscreen(m)
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if (m == menu.welcome) then
|
2018-02-21 01:10:03 +00:00
|
|
|
screen.defcursor()
|
|
|
|
print("Exiting menu!")
|
|
|
|
return false
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
return true
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function menu.skip()
|
2018-02-19 15:47:09 +00:00
|
|
|
if (core.isSerialBoot()) then
|
2018-02-21 01:10:03 +00:00
|
|
|
return true
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2018-02-21 01:10:03 +00:00
|
|
|
local c = string.lower(loader.getenv("console") or "")
|
2018-02-17 05:52:25 +00:00
|
|
|
if ((c:match("^efi[ ;]") or c:match("[ ;]efi[ ;]")) ~= nil) then
|
2018-02-21 01:10:03 +00:00
|
|
|
return true
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
c = string.lower(loader.getenv("beastie_disable") or "")
|
|
|
|
print("beastie_disable", c)
|
|
|
|
return c == "yes"
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function menu.autoboot()
|
2018-02-17 05:52:25 +00:00
|
|
|
if (menu.already_autoboot == true) then
|
2018-02-21 01:10:03 +00:00
|
|
|
return
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2018-02-21 01:10:03 +00:00
|
|
|
menu.already_autoboot = true
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local ab = loader.getenv("autoboot_delay")
|
2018-02-17 03:39:55 +00:00
|
|
|
if (ab ~= nil) and (ab:lower() == "no") then
|
2018-02-21 01:10:03 +00:00
|
|
|
return
|
2018-02-17 03:39:55 +00:00
|
|
|
elseif (tonumber(ab) == -1) then
|
2018-02-21 01:10:03 +00:00
|
|
|
core.boot()
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
2018-02-21 01:10:03 +00:00
|
|
|
ab = tonumber(ab) or 10
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local x = loader.getenv("loader_menu_timeout_x") or 5
|
|
|
|
local y = loader.getenv("loader_menu_timeout_y") or 22
|
2018-02-12 15:32:00 +00:00
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
local endtime = loader.time() + ab
|
|
|
|
local time
|
2018-02-12 15:32:00 +00:00
|
|
|
|
|
|
|
repeat
|
2018-02-21 01:10:03 +00:00
|
|
|
time = endtime - loader.time()
|
|
|
|
screen.setcursor(x, y)
|
2018-02-19 15:47:09 +00:00
|
|
|
print("Autoboot in " .. time ..
|
|
|
|
" seconds, hit [Enter] to boot" ..
|
2018-02-21 01:10:03 +00:00
|
|
|
" or any other key to stop ")
|
|
|
|
screen.defcursor()
|
2018-02-17 05:52:25 +00:00
|
|
|
if (io.ischar()) then
|
2018-02-21 01:10:03 +00:00
|
|
|
local ch = io.getchar()
|
2018-02-17 05:52:25 +00:00
|
|
|
if (ch == core.KEY_ENTER) then
|
2018-02-21 01:10:03 +00:00
|
|
|
break
|
2018-02-12 15:32:00 +00:00
|
|
|
else
|
|
|
|
-- erase autoboot msg
|
2018-02-21 01:10:03 +00:00
|
|
|
screen.setcursor(0, y)
|
2018-02-12 15:32:00 +00:00
|
|
|
print(" "
|
2018-02-21 01:10:03 +00:00
|
|
|
.. " ")
|
|
|
|
screen.defcursor()
|
|
|
|
return
|
2018-02-12 15:32:00 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
loader.delay(50000)
|
|
|
|
until time <= 0
|
|
|
|
core.boot()
|
2018-02-12 15:32:00 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-02-21 01:10:03 +00:00
|
|
|
return menu
|