1 \
2 \ This file and its contents are supplied under the terms of the
3 \ Common Development and Distribution License ("CDDL"), version 1.0.
4 \ You may only use this file in accordance with the terms of version
5 \ 1.0 of the CDDL.
6 \
7 \ A full copy of the text of the CDDL should have accompanied this
8 \ source. A copy of the CDDL is also available via the Internet at
9 \ http://www.illumos.org/license/CDDL.
10
11 \ Copyright 2017 Toomas Soome <tsoome@me.com>
12 \ Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
13
14 \ This module is implementing the beadm user command to support listing
15 \ and switching Boot Environments (BE) from command line and
16 \ support words to provide data for BE menu in loader menu system.
17 \ Note: this module needs an update to provide proper BE vocabulary.
18
19 only forth also support-functions also file-processing
20 also file-processing definitions also parser
21 also line-reading definitions also builtins definitions
22
23 variable page_count
24 variable page_remainder
25 0 page_count !
26 0 page_remainder !
27
28 \ from menu.4th
29 : +c! ( N C-ADDR/U K -- C-ADDR/U )
30 3 pick 3 pick ( n c-addr/u k -- n c-addr/u k n c-addr )
31 rot + c! ( n c-addr/u k n c-addr -- n c-addr/u )
32 rot drop ( n c-addr/u -- c-addr/u )
229 2dup s" currdev" setenv
230 drop free-memory
231 else
232 ." No such BE in menu.lst or menu.lst is missing." cr
233 exit
234 then
235 then
236
237 \ reset BE menu
238 0 page_count !
239 \ need to do:
240 0 unload drop
241 free-module-options
242 \ unset the env variables with kernel arguments
243 s" acpi-user-options" unsetenv
244 s" boot-args" unsetenv
245 s" boot_ask" unsetenv
246 s" boot_single" unsetenv
247 s" boot_verbose" unsetenv
248 s" boot_kmdb" unsetenv
249 s" boot_debug" unsetenv
250 s" boot_reconfigure" unsetenv
251 start \ load config, kernel and modules
252 ." Current boot device: " s" currdev" getenv type cr
253 ;
254
255 \ beadm list [device]
256 \ beadm activate BE [device] | device
257 \
258 \ lists BE's from current or specified device /boot/menu.lst file
259 \ activates specified BE by unloading modules, setting currdev and
260 \ running start to load configuration.
261 : beadm ( -- ) ( throws: abort )
262 0= if ( interpreted ) get_arguments then
263
264 dup 0= if
265 ." Usage:" cr
266 ." beadm activate {beName [device] | device}" cr
267 ." beadm list [device]" cr
268 ." Use lsdev to get device names." cr
269 drop exit
|
1 \
2 \ This file and its contents are supplied under the terms of the
3 \ Common Development and Distribution License ("CDDL"), version 1.0.
4 \ You may only use this file in accordance with the terms of version
5 \ 1.0 of the CDDL.
6 \
7 \ A full copy of the text of the CDDL should have accompanied this
8 \ source. A copy of the CDDL is also available via the Internet at
9 \ http://www.illumos.org/license/CDDL.
10
11 \ Copyright 2017 Toomas Soome <tsoome@me.com>
12 \ Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
13 \ Copyright 2019 Joyent, Inc.
14
15 \ This module is implementing the beadm user command to support listing
16 \ and switching Boot Environments (BE) from command line and
17 \ support words to provide data for BE menu in loader menu system.
18 \ Note: this module needs an update to provide proper BE vocabulary.
19
20 only forth also support-functions also file-processing
21 also file-processing definitions also parser
22 also line-reading definitions also builtins definitions
23
24 variable page_count
25 variable page_remainder
26 0 page_count !
27 0 page_remainder !
28
29 \ from menu.4th
30 : +c! ( N C-ADDR/U K -- C-ADDR/U )
31 3 pick 3 pick ( n c-addr/u k -- n c-addr/u k n c-addr )
32 rot + c! ( n c-addr/u k n c-addr -- n c-addr/u )
33 rot drop ( n c-addr/u -- c-addr/u )
230 2dup s" currdev" setenv
231 drop free-memory
232 else
233 ." No such BE in menu.lst or menu.lst is missing." cr
234 exit
235 then
236 then
237
238 \ reset BE menu
239 0 page_count !
240 \ need to do:
241 0 unload drop
242 free-module-options
243 \ unset the env variables with kernel arguments
244 s" acpi-user-options" unsetenv
245 s" boot-args" unsetenv
246 s" boot_ask" unsetenv
247 s" boot_single" unsetenv
248 s" boot_verbose" unsetenv
249 s" boot_kmdb" unsetenv
250 s" boot_drop_into_kmdb" unsetenv
251 s" boot_reconfigure" unsetenv
252 start \ load config, kernel and modules
253 ." Current boot device: " s" currdev" getenv type cr
254 ;
255
256 \ beadm list [device]
257 \ beadm activate BE [device] | device
258 \
259 \ lists BE's from current or specified device /boot/menu.lst file
260 \ activates specified BE by unloading modules, setting currdev and
261 \ running start to load configuration.
262 : beadm ( -- ) ( throws: abort )
263 0= if ( interpreted ) get_arguments then
264
265 dup 0= if
266 ." Usage:" cr
267 ." beadm activate {beName [device] | device}" cr
268 ." beadm list [device]" cr
269 ." Use lsdev to get device names." cr
270 drop exit
|