mirror of
https://github.com/ipxe/ipxe
synced 2025-12-23 05:21:49 +03:00
[menu] Add menu commands
Allow iPXE scripts to create menus. For example:
#!ipxe
menu iSCSI boot demonstration
item install Install Fedora to ${root-path}
item --default boot Boot from ${root-path}
item shell Enter iPXE shell
item exit Exit to BIOS
choose label && goto ${label}
:boot
sanboot ${root-path}
:install
sanhook ${root-path}
chain http://${next-server}/fedora.ipxe
:shell
shell
:exit
Inspired-by: Robin Smidsrød <robin@smidsrod.no>
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <ipxe/netdevice.h>
|
||||
#include <ipxe/menu.h>
|
||||
#include <ipxe/parseopt.h>
|
||||
|
||||
/** @file
|
||||
@@ -113,6 +114,29 @@ int parse_netdev ( const char *text, struct net_device **netdev ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse menu name
|
||||
*
|
||||
* @v text Text
|
||||
* @ret menu Menu
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int parse_menu ( const char *text, struct menu **menu ) {
|
||||
|
||||
/* Find menu */
|
||||
*menu = find_menu ( text );
|
||||
if ( ! *menu ) {
|
||||
if ( text ) {
|
||||
printf ( "\"%s\": no such menu\n", text );
|
||||
} else {
|
||||
printf ( "No default menu\n" );
|
||||
}
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse flag
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user