Skip to content

Commit 70c3d70

Browse files
authored
Namespace our KCL args, organize parsing (#120)
* Namespace our KCL args, organize parsing * Update new option names, new options, deprecated options
1 parent 8215e32 commit 70c3d70

File tree

3 files changed

+45
-29
lines changed

3 files changed

+45
-29
lines changed

90zfsbootmenu/zfsbootmenu-parse-commandline.sh

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,45 @@ else
1616
warn "ZFSBootMenu: Pools may not import correctly."
1717
fi
1818

19+
# Use the last defined console= to control menu output
20+
control_term=$( getarg console=)
21+
if [ -n "${control_term}" ]; then
22+
info "ZFSBootMenu: Setting controlling terminal to: ${control_term}"
23+
control_term="/dev/${control_term}"
24+
else
25+
control_term="/dev/tty1"
26+
info "ZFSBootMenu: Defaulting controlling terminal to: ${control_term}"
27+
fi
28+
29+
# Use loglevel to determine logging to /dev/kmsg
30+
loglevel=$( getarg loglevel=)
31+
if [ -n "${loglevel}" ]; then
32+
info "ZFSBootMenu: setting log level from command line: ${loglevel}"
33+
else
34+
loglevel=3
35+
fi
36+
1937
# Force import pools only when explicitly told to do so
20-
if getargbool 0 force_import ; then
38+
if getargbool 0 zbm.force_import -d force_import ; then
2139
# shellcheck disable=SC2034
2240
force_import="yes"
2341
info "ZFSBootMenu: Enabling force import of ZFS pools"
2442
fi
2543

26-
# Set a menu timeout, to allow immediate booting
27-
menu_timeout=$( getarg timeout=)
44+
# zbm.timeout= overrides timeout=
45+
menu_timeout=$( getarg zbm.timeout -d timeout )
2846
if [ -n "${menu_timeout}" ]; then
2947
info "ZFSBootMenu: Setting menu timeout from command line: ${menu_timeout}"
48+
elif getargbool 0 zbm.show ; then
49+
menu_timeout=-1;
50+
info "ZFSBootMenu: forcing display of menu"
51+
elif getargbool 0 zbm.skip ; then
52+
menu_timeout=0;
53+
info "ZFSBootMenu: skipping display of menu"
3054
else
3155
menu_timeout=10
3256
fi
3357

34-
control_term=$( getarg console=)
35-
if [ -n "${control_term}" ]; then
36-
info "ZFSBootMenu: Setting controlling terminal to: ${control_term}"
37-
control_term="/dev/${control_term}"
38-
else
39-
control_term="/dev/tty1"
40-
info "ZFSBootMenu: Defaulting controlling terminal to: ${control_term}"
41-
fi
42-
4358
# Allow setting of console size; there are no defaults here
4459
# shellcheck disable=SC2034
4560
zbm_lines=$( getarg zbm.lines=)
@@ -53,13 +68,6 @@ if getargbool 0 zbm.tmux ; then
5368
info "ZFSBootMenu: Enabling tmux integrations"
5469
fi
5570

56-
loglevel=$( getarg loglevel=)
57-
if [ -n "${loglevel}" ]; then
58-
info "ZFSBootMenu: setting log level from command line: ${loglevel}"
59-
else
60-
loglevel=3
61-
fi
62-
6371
wait_for_zfs=0
6472
case "${root}" in
6573
""|zfsbootmenu|zfsbootmenu:)

pod/zfsbootmenu.7.pod

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,50 @@ These options are set on the kernel command line when booting the initramfs or U
1212

1313
=over 4
1414

15+
=item B<root=zfsbootmenu:POOL=E<lt>poolE<gt>>
16+
17+
By default, ZFSBootMenu will look for the I<bootfs> property on the first pool it imports to select the default boot environment. If you have multiple pools, substitute the name of your preferred pool for B<E<lt>poolE<gt>> in the argument B<root=zfsbootmenu:POOL=E<lt>poolE<gt>>.
18+
1519
=item B<spl_hostid=E<lt>hostidE<gt>>
1620

1721
When creating an initramfs or UEFI bundle, the I<hostid> from the system is copied into the target. If this image will be used on another system with a different I<hostid>, it can be overridden with this option.
1822

1923
Replace B<E<lt>hostidE<gt>> with an eight-digit hexadecimal number.
2024

21-
=item B<force_import=1>
25+
=item B<zbm.force_import=1>
2226

2327
Set this option to attempt to force pool imports. When set, this invokes I<zpool import -f> in place of the regular I<zpool import> command, which will attempt to import a pool that's potentially in use on another system. Use this option with caution!
2428

25-
Omit this option or explicitly specify B<force_import=0> to disable forced imports.
29+
Omit this option or explicitly specify B<zbm.force_import=0> to disable forced imports.
2630

27-
=item B<timeout>
31+
=item B<force_import=1>
32+
33+
Deprecated; use B<zbm.force_import>.
34+
35+
=item B<zbm.timeout>
2836

2937
This option accepts numeric values that control whether and when the
3038
boot-environment menu should be displayed.
3139

3240
=over 2
3341

34-
=item B<timeout=0>
42+
=item B<zbm.timeout=0> | B<zbm.skip>
3543

3644
When possible, bypass the menu and immediately boot a configured I<bootfs> pool property.
3745

38-
=item B<timeout=-1>
46+
=item B<zbm.timeout=-1> | B<zbm.show>
3947

4048
Rather than present a countdown timer for automatic selection, immediately display the boot-environment menu.
4149

42-
=item B<timeout=E<lt>positive integerE<gt>>
50+
=item B<zbm.timeout=E<lt>positive integerE<gt>>
4351

4452
Display a countdown timer for the specified number of seconds before booting the configured I<bootfs> boot environment.
4553

4654
=back
4755

48-
=item B<root=zfsbootmenu:POOL=E<lt>poolE<gt>>
56+
=item B<timeout>
4957

50-
By default, ZFSBootMenu will look for the I<bootfs> property on the first pool it imports to select the default boot environment. If you have multiple pools, substitute the name of your preferred pool for B<E<lt>poolE<gt>> in the argument B<root=zfsbootmenu:POOL=E<lt>poolE<gt>>.
58+
Deprecated; use B<zbm.timeout>.
5159

5260
=item B<zbm.tmux>
5361

testing/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ case "$(uname -m)" in
4949
BIN="qemu-system-ppc64"
5050
KERNEL="${TESTDIR}/vmlinux-bootmenu"
5151
MACHINE="pseries,accel=kvm,kvm-type=HV,cap-hpt-max-page-size=4096"
52-
APPEND="loglevel=7 timeout=5 root=zfsbootmenu:POOL=ztest"
52+
APPEND="loglevel=7 zbm.timeout=5 root=zfsbootmenu:POOL=ztest"
5353
SERDEV="hvc0"
5454
;;
5555
x86_64)
5656
BIN="qemu-system-x86_64"
5757
KERNEL="${TESTDIR}/vmlinuz-bootmenu"
5858
MACHINE="type=q35,accel=kvm"
59-
APPEND="loglevel=7 timeout=5 root=zfsbootmenu:POOL=ztest"
59+
APPEND="loglevel=7 zbm.timeout=5 root=zfsbootmenu:POOL=ztest"
6060
SERDEV="ttyS0"
6161
;;
6262
esac

0 commit comments

Comments
 (0)