|
@@ -15,6 +15,7 @@ Literature dealing with the network protocols:
|
15
|
15
|
FILE_LICENCE ( GPL2_OR_LATER );
|
16
|
16
|
|
17
|
17
|
#include <stdio.h>
|
|
18
|
+#include <stdlib.h>
|
18
|
19
|
#include <ipxe/init.h>
|
19
|
20
|
#include <ipxe/features.h>
|
20
|
21
|
#include <ipxe/shell.h>
|
|
@@ -28,6 +29,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
28
|
29
|
#define BOLD "\033[1m"
|
29
|
30
|
#define CYAN "\033[36m"
|
30
|
31
|
|
|
32
|
+/** The "scriptlet" setting */
|
|
33
|
+struct setting scriptlet_setting __setting ( SETTING_MISC ) = {
|
|
34
|
+ .name = "scriptlet",
|
|
35
|
+ .description = "Boot scriptlet",
|
|
36
|
+ .tag = DHCP_EB_SCRIPTLET,
|
|
37
|
+ .type = &setting_type_string,
|
|
38
|
+};
|
|
39
|
+
|
31
|
40
|
/**
|
32
|
41
|
* Prompt for shell entry
|
33
|
42
|
*
|
|
@@ -51,6 +60,7 @@ static int shell_banner ( void ) {
|
51
|
60
|
__asmcall int main ( void ) {
|
52
|
61
|
struct feature *feature;
|
53
|
62
|
struct image *image;
|
|
63
|
+ char *scriptlet;
|
54
|
64
|
|
55
|
65
|
/* Some devices take an unreasonably long time to initialise */
|
56
|
66
|
printf ( PRODUCT_SHORT_NAME " initialising devices..." );
|
|
@@ -82,11 +92,16 @@ __asmcall int main ( void ) {
|
82
|
92
|
if ( ( image = first_image() ) != NULL ) {
|
83
|
93
|
/* We have an embedded image; execute it */
|
84
|
94
|
image_exec ( image );
|
|
95
|
+ } else if ( shell_banner() ) {
|
|
96
|
+ /* User wants shell; just give them a shell */
|
|
97
|
+ shell();
|
85
|
98
|
} else {
|
86
|
|
- /* Prompt for shell */
|
87
|
|
- if ( shell_banner() ) {
|
88
|
|
- /* User wants shell; just give them a shell */
|
89
|
|
- shell();
|
|
99
|
+ fetch_string_setting_copy ( NULL, &scriptlet_setting,
|
|
100
|
+ &scriptlet );
|
|
101
|
+ if ( scriptlet ) {
|
|
102
|
+ /* User has defined a scriptlet; execute it */
|
|
103
|
+ system ( scriptlet );
|
|
104
|
+ free ( scriptlet );
|
90
|
105
|
} else {
|
91
|
106
|
/* Try booting. If booting fails, offer the
|
92
|
107
|
* user another chance to enter the shell.
|