git: 9b17aa27406f - main - lualoader: Add loader_menu_multi_user_prompt config variable

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Fri, 02 Sep 2022 19:36:30 UTC
The branch main has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=9b17aa27406f3716383e71c6687d53599a8f8d8a

commit 9b17aa27406f3716383e71c6687d53599a8f8d8a
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2022-09-02 19:30:40 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-09-02 19:30:40 +0000

    lualoader: Add loader_menu_multi_user_prompt config variable
    
    This allows the "Multi user" in "[B]oot Multi user" to be substituted
    with another string, for example with "Installer" in installer media.
    Note that this is lua-only at the moment, since loader.4th's menu.rc
    defines the alternate name as Boot [M]ulti User, unlike lualoader which
    leaves it as [B]oot Multi user. Ideally loader.4th would adopt the newer
    and simpler lualoader behaviour and then it could gain support for this
    option, but loader.4th is on the way out and isn't used by any official
    installer media so this is not a significant concern.
    
    Reviewed by:    kevans, rpokala
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D36418
---
 stand/lua/menu.lua | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/stand/lua/menu.lua b/stand/lua/menu.lua
index f1a4f07a8d73..400dbf3d469b 100644
--- a/stand/lua/menu.lua
+++ b/stand/lua/menu.lua
@@ -60,6 +60,10 @@ local function bootenvSet(env)
 	config.reload()
 end
 
+local function multiUserPrompt()
+	return loader.getenv("loader_menu_multi_user_prompt") or "Multi user"
+end
+
 -- Module exports
 menu.handlers = {
 	-- Menu handlers take the current menu and selected entry as parameters,
@@ -263,11 +267,16 @@ menu.welcome = {
 	all_entries = {
 		multi_user = {
 			entry_type = core.MENU_ENTRY,
-			name = color.highlight("B") .. "oot Multi user " ..
-			    color.highlight("[Enter]"),
+			name = function()
+				return color.highlight("B") .. "oot " ..
+				    multiUserPrompt() .. " " ..
+				    color.highlight("[Enter]")
+			end,
 			-- Not a standard menu entry function!
-			alternate_name = color.highlight("B") ..
-			    "oot Multi user",
+			alternate_name = function()
+				return color.highlight("B") .. "oot " ..
+				    multiUserPrompt()
+			end,
 			func = function()
 				core.setSingleUser(false)
 				core.boot()