Skip to content

Commit

Permalink
Add menu for console-only boot.
Browse files Browse the repository at this point in the history
  • Loading branch information
ScoobiFreeBSD committed Feb 9, 2016
1 parent 4a8d8f7 commit 2376fc1
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
33 changes: 32 additions & 1 deletion etc/rc.subr
Expand Up @@ -170,6 +170,28 @@ checkyesno()
esac
}

checkkenvyesno()
{
_value=`/bin/kenv -q ${1}`
debug "checkyesno: $1 is set to $_value."
case $_value in

# "yes", "true", "on", or "1"
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
return 0
;;

# "no", "false", "off", or "0"
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
return 1
;;
*)
warn "\$${1} is not set properly - see rc.conf(5)."
return 1
;;
esac
}

#
# reverse_list list
# print the list in reverse order
Expand Down Expand Up @@ -1290,7 +1312,7 @@ run_rc_script()
unset name command command_args command_interpreter \
extra_commands pidfile procname \
rcvar rcvars rcvars_obsolete required_dirs required_files \
required_vars
required_vars required_kvars
eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd

case "$_file" in
Expand Down Expand Up @@ -1974,6 +1996,15 @@ check_required_before()
fi
done

for _f in $required_kvars; do
if ! checkkenvyesno $_f; then
warn "\$${_f} is not set in kernel environment."
if [ -z "$rc_force" ]; then
return 1
fi
fi
done

for _f in $required_dirs; do
if [ ! -d "${_f}/." ]; then
warn "${_f} is not a directory."
Expand Down
39 changes: 39 additions & 0 deletions sys/boot/forth/menu-commands.4th
Expand Up @@ -243,6 +243,45 @@ also menu-namespace also menu-command-helpers
TRUE \ loop menu again
;

\
\ Console Boot
\

: console_enabled? ( -- flag )
s" boot_console" getenv -1 <> dup if
swap drop ( c-addr flag -- flag )
then
;

: console_enable ( -- )
s" set boot_console=YES" evaluate
;

: console_disable ( -- )
s" boot_console" unsetenv
;

: init_console ( N -- N )
console_enabled? if
toggle_menuitem ( n -- n )
then
;

: toggle_console ( N -- N TRUE )
toggle_menuitem
menu-redraw

\ Now we're going to make the change effective

dup toggle_stateN @ 0= if
console_disable
else
console_enable
then

TRUE \ loop menu again
;

\
\ Escape to Prompt
\
Expand Down
8 changes: 8 additions & 0 deletions sys/boot/forth/menu.rc
Expand Up @@ -126,6 +126,14 @@ set optionsmenu_keycode[6]=118
set optionsansi_caption[6]="^[1mV^[merbose..... ^[34;1mOff^[m"
set optionstoggled_ansi[6]="^[1mV^[merbose..... ^[32;7mOn^[m"

set optionsmenu_init[7]="init_console"
set optionsmenu_caption[7]="[C]onsole mode... off"
set optionstoggled_text[7]="[C]onsole mode... On"
set optionsmenu_command[7]="toggle_console"
set optionsmenu_keycode[7]=99
set optionsansi_caption[7]="Console..... Off"
set optionstoggled_ansi[7]="Console..... On"

\
\ BOOT ENVIRONMENT MENU
\
Expand Down

2 comments on commit 2376fc1

@allanjude
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea, We should talk to the ports people and see what they prefer, then look at the boot menu side of it. The name of the menu option may need more consideration as well

@ScoobiFreeBSD
Copy link
Owner Author

@ScoobiFreeBSD ScoobiFreeBSD commented on 2376fc1 Sep 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I've gone through different variants of the menu option wording and the kernel environment variable naming... figured it's trivial enough to let usability people decide.

I probably should've [cross]posted to freebsd-desktop@, but it doesn't have a lot of traffic. Should I post to freebsd-ports@?

Please sign in to comment.