Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Sep 2000 01:23:51 +0900
From:      "Daniel C. Sobral" <dcs@newsguy.com>
To:        bp@freebsd.org, hackers@freebsd.org
Subject:   Multiple kernels selector...
Message-ID:  <39B51E16.E8AD4BC8@newsguy.com>

next in thread | raw e-mail | index | archive | help
This is an adaptation from menuconf.4th:

\ Simple greeting screen, presenting basic options.
\ XXX This is far too trivial - I don't have time now to think
\ XXX about something more fancy... :-/
\ $FreeBSD: /c/ncvs/src/share/examples/bootforth/menuconf.4th,v 1.4
1999/09/29 04:46:01 dcs Exp $

: title
        ." Welcome to BootFORTH!" cr cr
;

: menu
        ." 1.  Start FreeBSD with /boot/stable.conf." cr
        ." 2.  Start FreeBSD with /boot/current.conf." cr
        ." 3.  Start FreeBSD with standard configuration. " cr
        ." 4.  Reboot." cr cr
;

: tkey  ( d -- flag | char )
        seconds +
        begin 1 while
            dup seconds u< if
                drop
                -1
                exit
            then
            key? if
                drop
                key
                exit
            then
        repeat
;

: prompt
        ." Enter your option (1,2,3,4): "
        10 tkey
        dup 32 = if
            drop key
        then
        dup 0< if
            drop 51
        then
        dup emit cr
;

: (reboot) 0 reboot ;

: main_menu
        begin 1 while
                title
                menu
                prompt
                cr cr
                dup 49 = if
                        drop
                        ." Loading /boot/stable.conf. Please wait..." cr
                        s" /boot/stable.conf" read-conf
                        0 boot-conf exit
                then
                dup 50 = if
                        drop
                        ." Loading /boot/current.conf. Please wait..."
cr
                        s" /boot/current.conf" read-conf
                        0 boot-conf exit
                then
                dup 51 = if
                        drop
                        ." Proceeding with standard boot. Please
wait..." cr
                        0 boot-conf exit
                then
                dup 52 = if
                        drop
                        ['] (reboot) catch abort" Error rebooting"
                then
                ." Key " emit ."  is not a valid option!" cr
                ." Press any key to continue..."
                key drop cr
        repeat
;

This reads stable.conf or current.conf depending on option 1 or 2 (or
standard boot for option 3), and then boots. You can simplify it in the
following way. Replace the lines

                        s" /boot/stable.conf" read-conf
                        0 boot-conf exit

(and similar for current.conf) with the line

			s" kernel.stable" 1 boot-conf exit

and you'll just try to boot the standard configuration using the kernel
named kernel.stable. If you need to match modules to kernels, keep both
kernel and modules in the same directory, under either root or /boot,
for each kernel/modules set. Then, if you want to boot the kernel and
modules inside the directory /boot/stable or /stable, for example, you
replace the two lines with:

			s" stable" 1 boot-conf exit

You can, of course, add more options easily. And you can mix all of the
above options: .conf files names, kernel names and directory names,
depending on what option you choose.

Put this stuff in a file (asciimenu.4th, for example) and then replace
the "start" on loader.rc with the following:

s" /boot/asciimenu.4th" fopen dup fload fclose
initialize drop
main_menu

-- 
Daniel C. Sobral			(8-DCS)
dcs@newsguy.com
dcs@freebsd.org
capo@white.bunnies.bsdconspiracy.net

	OK, so the solar flares are my fault.. I am sorry, ok?!?!


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?39B51E16.E8AD4BC8>